Sorted issues with static missions

Removed most debugging code.
Static missions randomly selected from a list of available missions.
See changelog for details.
This commit is contained in:
Ghostrider [GRG] 2023-10-16 15:35:01 -04:00
parent 2a7304960c
commit 22a6fc572a
14 changed files with 185 additions and 140 deletions

View File

@ -18,7 +18,8 @@ private "_markers";
"_markerColor",
"_markerType", // Use either the name of the icon or "ELLIPSE" or "RECTANGLE" where non-icon markers are used
["_markerSize",[0,0]],
["_markerBrush","GRID"]
["_markerBrush","GRID"],
["_showMarkers",true]
];
if (GMS_debugLevel > 3) then
@ -41,22 +42,28 @@ if (GMS_debugLevel > 3) 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];
//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];
};

View File

@ -43,8 +43,9 @@ GMS_spawnHelisPass = 0;
//GMS_aiKilled = false;
GMS_triggered = false;
GMS_revealMode = "detailed"; //""basic" /*group or vehicle level reveals*/,detailed /*unit by unit reveals*/";
GMS_dynamicMissionsSpawned = 0;
GMS_MissionsSpawned = 0;
GMS_missionData = [];
GMS_initializedMissionsList = [];
GMS_landVehiclePatrols = [];
GMS_aircraftPatrols = [];

View File

@ -26,7 +26,9 @@ private ["_abort","_crates","_aiGroup","_objects","_groupPatrolRadius","_mission
"_chanceMissionSpawned",
"_rewardVehicles",
// New private Variables from 10-15-23
"_timeoutMsg"
"_timeoutMsg",
"_missionLandscapeMode",
"_showMarker"
];
params["_markerName",["_aiDifficultyLevel","Red"]];
@ -92,6 +94,7 @@ if (isNil "_missionemplacedweapons") then {_missionemplacedweapons = []};
// Allow for and capture any custom difficult setting in the mission
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"]];
private _paraSkill = _aiDifficultyLevel;
@ -100,12 +103,12 @@ private _paraSkill = _aiDifficultyLevel;
if !(_spawnCratesTiming in GMS_validLootSpawnTimings) then
{
[format['Invalid crate spawn timing %1 found in mission %2 :: default value atMissionSpawnGround used',_spawnCratesTiming,_markerMissionName],"<WARNING>"] call GMS_fnc_log;
_spawnCratesTiming = atMissionSpawnGround;
_spawnCratesTiming = "atMissionSpawnGround";
};
if !(_loadCratesTiming in GMS_validLootLoadTimings) then
{
[format['Invalid crate loading timing %1 found in mission %2 :: default atMissionSpawn value used',_loadCratesTiming,_markerMissionName],"<WARNING>"] call GMS_fnc_log;
_loadCratesTiming = atMissionSpawn;
_loadCratesTiming = "atMissionSpawn";
};
if !(_endCondition in GMS_validEndStates) then
{
@ -119,7 +122,8 @@ private _markerConfigs = [
_markerType,
_markerColor,
_markerSize,
_markerBrush
_markerBrush,
_showMarker
];
private _paraConfigs = [

View File

@ -22,13 +22,13 @@ if (_isStatic) then {
_waitTime = diag_tickTime + (_tMin) + random((_tMax) - (_tMin));
};
diag_log format["_addMissionToQue: _waitTime = %1",_waitTime];
//diag_log format["_addMissionToQue: _waitTime = %1",_waitTime];
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];
//diag_log format["_addMissionToQue: _missionFile = %1",_missionFile];
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
{
@ -36,10 +36,10 @@ private _missionsData = []; // Parameters definine each of the missions for this
if !(isNil "_data") then
{
_missionsData pushBack _data;
diag_log format["_addMissionToQue: _data = %1",_data];
//diag_log format["_addMissionToQue: _data = %1",_data];
};
} else {
diag_log format["bad path\mission combination %1",_missionFile];
//diag_log format["bad path\mission combination %1",_missionFile];
};
} forEach _missionList;
@ -56,7 +56,7 @@ private _missions = [
_missionsData, // Array of data about individual missions that could be spawned. The data table for each mission is defined in _missionSpawner
_isStatic
];
diag_log format["_addMissionToQue (55): _missions = %1",_missions];
//diag_log format["_addMissionToQue (55): _missions = %1",_missions];
GMS_missionData pushBack _missions;

View File

@ -59,11 +59,28 @@ params[
"_spawnedAt" // index 13
];
#define timesSpawnedIndex 11
//diag_log format["_fnc_initializeMission _chanceMissionRespawned = %1", _chanceMissionSpawned];
// do not initialize if the odds of spawning are not favorable.
if (random(1) > _chanceMissionSpawned) exitWith {-1};
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
_markerConfigs params[
"_markerName", // The unique text identifier for the marker
@ -71,14 +88,12 @@ _markerConfigs params[
"_markerType",
"_markerColor",
"_markerSize",
"_markerBrush"
"_markerBrush",
"_showMarkers"
];
//[format["_initializeMission (39): _markerName %1 | _key %2 | _missionCount %3 | _maxMissionRespawns %4 | _timesSpawned %5",_markerName,_key,_missionCount,_maxMissionRespawns,_timesSpawned]] call GMS_fnc_log;
// 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 {private _initialized = 3; _initialized};
private _initialized = 0;
/*
@ -110,7 +125,7 @@ if (_coords isEqualTo [] || {_coords isEqualTo [0,0,0]}) exitWith
GMS_ActiveMissionCoords pushback _coords;
GMS_missionsRunning = GMS_missionsRunning + 1;
//[format["_initializeMission (70): _coords = %1 | GMS_missionsRunning = %2",_coords,GMS_missionsRunning]] call GMS_fnc_log;
//[format["_initializeMission (118): _coords = %1 | GMS_missionsRunning = %2",_coords,GMS_missionsRunning]] call GMS_fnc_log;
private _markers = [];
@ -142,7 +157,7 @@ if !(GMS_preciseMapMarkers) then
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;
[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";
@ -151,7 +166,7 @@ if !(toLowerANSI (_markerType) in ["ellipse","rectangle"] || {isClass(configFile
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;
[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;
};
@ -166,9 +181,11 @@ private _markers = [
_markerColor,
_markerType,
_markerSize,
_markerBrush] call GMS_fnc_createMissionMarkers;
_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};
//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.
@ -205,6 +222,7 @@ private _missionData = [
lootVehicles, // index 8
_markers // index 9
];
#define spawnPara -1
GMS_initializedMissionsList pushBack [_key, missionTimeoutAt, triggered, _missionData, _missionConfigs, spawnPara,_isStatic];
//[format["_initializeMission (163): count GMS_initializedMissionsList = %1",count GMS_initializedMissionsList]] call GMS_fnc_log;

View File

@ -229,7 +229,7 @@ for "_i" from 1 to (count _missionsList) do
"_missionLootVehicles"
];
if (GMS_debugLevel > 0) then {[format["_monitorSpawnedMissions(234): _exception = %1 | _spawnedAt = %2",_exception,_spawnedAt]] call GMS_fnc_log};
//if (GMS_debugLevel > 0) then {[format["_monitorSpawnedMissions(234): _exception = %1 | _spawnedAt = %2",_exception,_spawnedAt]] call GMS_fnc_log};
switch (_exception) do
{
case 1: { // Normal Mission End

View File

@ -358,7 +358,7 @@ if (_spawnCratesTiming in ["atMissionSpawnGround","atMissionSpawnAir"]) then
if (_loadCratesTiming isEqualTo "atMissionSpawn") then
{
private _crateMoney =(missionNamespace getVariable[format["GMS_crateMoney%1",_difficulty],GMS_rewardsOrange]);
diag_log format["_spawnMissionAssets(395): _crateMoney = %1",_crateMoney];
//diag_log format["_spawnMissionAssets(395): _crateMoney = %1",_crateMoney];
{
[_x,_difficulty,_crateMoney] call GMSCore_fnc_setMoney;
} forEach _crates;

View File

@ -84,12 +84,12 @@ private _units = [];
] call GMSCore_fnc_initializeWaypointsAreaPatrol;
*/
_helis pushBack _aircraft;
if (GMS_debugLevel > 0) then {[format["_spawnMissionHelis: _heli %1 spawned with pilot %2 and crew %2",typeOf _aircraft, currentPilot _aircraft, _crewGroup]] call GMS_fnc_log};
//if (GMS_debugLevel > 0) then {[format["_spawnMissionHelis: _heli %1 spawned with pilot %2 and crew %2",typeOf _aircraft, currentPilot _aircraft, _crewGroup]] call GMS_fnc_log};
} else {
[format["GMS_fnc_spawnMissionHelis: Invalid classname %1 used in _airPatrols", _heli],"warning"] call GMS_fnc_log;
};
} forEach _missionHelis;
[format["GMS_fnc_spawnMissionHelis: count _units = %1 | count _helis = %2", count _units, count _helis]] call GMS_fnc_log;
//[format["GMS_fnc_spawnMissionHelis: count _units = %1 | count _helis = %2", count _units, count _helis]] call GMS_fnc_log;
GMS_spawnHelisPass = GMS_spawnHelisPass + 1;
[_helis,_units]

View File

@ -39,9 +39,9 @@ private _patrolsThisMission = +_missionPatrolVehicles;
{
//diag_log format["_spawnMissionVehiclePatrols(41): _x = %1",_x];
_x params[["_vehName",""],["_pos",[]],["_dir",0]];
diag_log format["_spawnMissionVehiclePatrols(43): _vehName = %1 | _pos = %2 | _dir = %3 | isClass _vehName = %4",_vehName,_pos,_dir, isClass(configFile >> "CfgVehicles" >> _vehName)];
//diag_log format["_spawnMissionVehiclePatrols(43): _vehName = %1 | _pos = %2 | _dir = %3 | isClass _vehName = %4",_vehName,_pos,_dir, isClass(configFile >> "CfgVehicles" >> _vehName)];
_pos = _coords vectorAdd _pos; // else {_pos = (_coords vectorAdd _pos) findEmptyPosition[0,50,_vehName]};
diag_log format["_spawnMissionVehiclePatrols(45): _pos updated to %1",_pos];
//diag_log format["_spawnMissionVehiclePatrols(45): _pos updated to %1",_pos];
if (isClass(configFile >> "CfgVehicles" >> _vehName)) then {
if !(_pos isEqualTo []) then {
@ -122,6 +122,6 @@ private _patrolsThisMission = +_missionPatrolVehicles;
} forEach _patrolsThisMission;
GMS_landVehiclePatrols append _vehicles;
GMS_monitoredVehicles append _vehicles;
[format["GMS_fnc_spawnMissionVehiclePatrols: count _missionAI = %1 | count _vehicles = %2", count _missionAI, count _vehicles]] call GMS_fnc_log;
//[format["GMS_fnc_spawnMissionVehiclePatrols: count _missionAI = %1 | count _vehicles = %2", count _missionAI, count _vehicles]] call GMS_fnc_log;
[_vehicles, _missionAI];

View File

@ -19,13 +19,16 @@ if (GMS_missionsRunning >= GMS_maxSpawnedMissions) exitWith
{
[format["_spawnNewMissions (18): GMS_maxSpawnedMissions of %1 Reached",GMS_maxSpawnedMissions]] call GMS_fnc_log;
};
//[format["_spawnNewMissions (18): time = %1 GMS_debugLevel = %2",diag_tickTime,GMS_debugLevel]] call GMS_fnc_log;
for "_i" from 1 to (count GMS_missionData) do
{
private _missionDescriptors = _x;
if (_i > (count GMS_missionData)) exitWith {};
private _missionDescriptors = GMS_missionData deleteAt 0;
// _missionDescriptor is configures as follows:
/*
private _mission = [
_key,
_key, // We can search for this key or for _missionDescriptors if we need to delete this particular mission.
_difficulty,
_noMissions, // Max no missions of this category
0, // Number active
@ -36,17 +39,18 @@ if (GMS_missionsRunning >= GMS_maxSpawnedMissions) exitWith
_isStatic
];
*/
_missionDescriptors params["_key","_difficulty","_maxMissions","_activeMissions","_tMin","_tMax","_waitTime","_missionsData","_isStatic"];
// 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.
// Note that an element with an empty _missionsData array is not added back for future evaluation.
if !(_missionsData isEqualTo []) then {
/*
{
diag_log format["_spawnNewMission: _this %1 = %2",_forEachIndex, _x];
} forEach _missionDescriptors;
_activeMissions = the number of active missions allowed of this type which can be, for example, blue missions or static missions.
_maxMissions = the maximum number of missions allowed of this type.
_waitTime = at what time can the next mission be spawned.
*/
//diag_log format["_spawnNewMission: _missionsData = %1",_missionsData];
if (_missionsData isEqualTo []) exitWith {-1};
if (_activeMissions < _maxMissions && {diag_tickTime > _waitTime && {GMS_missionsRunning < GMS_maxSpawnedMissions}}) then
{
// time to reset timers and spawn something.
@ -70,38 +74,45 @@ if (GMS_missionsRunning >= GMS_maxSpawnedMissions) exitWith
_spawnedAt // index 14
];
*/
/*{
diag_log format["_spawnNewMission:_missionSelected: _this %1 = %2",_forEachIndex,_x];
} forEach _missionSelected;
*/
/*
params[ // for GMS_fnc_initialiZeMission are
"_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"
];
*/
//diag_log format["_spawnNewMissions: _missionSelected = %1",_missionSelected];
private _missionInitialized = [_key,_missionSelected,GMS_dynamicMissionsSpawned,_isStatic] call GMS_fnc_initializeMission;
if (_missionInitialized == 1) then { // This is a dynamic mission s see if we can spawn another instance of this categore (blue, red, green, orange)
GMS_dynamicMissionsSpawned = GMS_dynamicMissionsSpawned + 1;
private _missionInitialized = [_key,_missionSelected,GMS_MissionsSpawned,_isStatic] call GMS_fnc_initializeMission;
//[format["_spawnNewMissions (78) GMS_fnc_initializeMission returned %1",_missionInitialized]] call GMS_fnc_log;
switch (_missionInitialized) do
{
case -2: {
// Handle the case in which a mission has been spawned _maxmissionRespawns
[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;
[format["_spawnNewMission (85): count _missionsData after deletion = %1", count _missionsData]] call GMS_fnc_log;
#define missionsData 7
_missionDescriptors set [missionsData, _missionsData];
};
case -1: {
#define waitTime 6
private _wt = diag_tickTime + _tmin + (random(_tMax - _tMin));
_missionDescriptors set[waitTime, _wt];
};
case 1: {
GMS_MissionsSpawned = GMS_MissionsSpawned + 1;
#define waitTime 6
#define noActive 3
private _wt = diag_tickTime + _tmin + (random(_tMax - _tMin));
_missionDescriptors set[waitTime, _wt];
_missionDescriptors set[noActive, _activeMissions + 1];
} else {
if (_missionInitialized == -1) then // failed the test about chance of spawning
{
};
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 + _tmin + (random(_tMax - _tMin));
private _wt = diag_tickTime + 60;
_missionDescriptors set[waitTime, _wt];
};
case 3: {
// Nothing to do here at this time.
};
};
};
GMS_missionData pushBack _missionDescriptors;
};
};
} forEach GMS_missionData;
private _exitcode = 1;
_exitCode;

View File

@ -203,10 +203,14 @@ if (GMS_enableStaticMissions > 0 && !(_missionLIstStatics isEqualTo [])) then //
private _isStatic = true;
private _numberStatics = count _missionListStatics;
{
if ((count _staticsToSpawn) > (count _missionLIstStatics)) exitWith {};
private _mission = selectRandom _missionLIstStatics;
[format["_init (206): _missionListStatics %1 = %2",_forEachIndex, _x]] call GMS_fnc_log;
} forEach _missionListStatics;
while {(count _staticsToSpawn) < (count _missionListStatics) && ((count _staticsToSpawn) < (GMS_enableStaticMissions))} do
{
private _mission = selectRandom _missionListStatics;
_staticsToSpawn pushBackUnique _mission;
} forEach _missionLIstStatics;
[format["GMS_fnc_init (209): _mission = %1 | count _staticsToSpawn = %2",_mission, count _staticsToSpawn]] call GMS_fnc_log;
};
/*
params[
["_missionList",[]],
@ -218,7 +222,7 @@ if (GMS_enableStaticMissions > 0 && !(_missionLIstStatics isEqualTo [])) then //
["_noMissions",1],
["_isStatic",false]];
*/
//diag_log format["_init: count _staticsToSpawn = %1 | GMS_enableStaticMissions = %2:",count _staticsToSpawn,GMS_enableStaticMissions];
diag_log format["_init: count _staticsToSpawn = %1 | GMS_enableStaticMissions = %2:",count _staticsToSpawn,GMS_enableStaticMissions];
[_staticsToSpawn,_pathStatics,"StaticsMarker","orange",GMS_TMin_Statics,GMS_TMax_Statics,GMS_enableStaticMissions,_isStatic] call GMS_fnc_addMissionToQue;
};

View File

@ -17,7 +17,7 @@
changing any of these variables may break the mission system
*/
GMS_locationBlackList = []; // Do not touch ...
GMS_debugLevel = 3; // should be set to 0 ...
GMS_debugLevel = 0; // should be set to 0 ...
[format["Loading configurations for Non-militarized servers"]] call GMS_fnc_log;
/*
@ -342,7 +342,7 @@ switch (GMSCore_modType) do
GMS_enableRedMissions = 2;
GMS_enableBlueMissions = 1;
GMS_numberUnderwaterDynamicMissions = 0; // Values from -1 (no UMS) to N (N Underwater missions will be spawned; static UMS units and subs will be spawned.
GMS_enableStaticMissions = 3;
GMS_enableStaticMissions = 2;
#ifdef GRGserver
GMS_enableHunterMissions = 1;

View File

@ -152,7 +152,7 @@ if (GMS_debugLevel > 0) then {
GMS_enableRedMissions = 0; // 10-2-2023 Tested with mission list= "fuelDepot", "junkyardWilly", "TraderBoss", "carThieves", "Ammunition_depot", "IDAP", "Outpost", "Service_Point"
GMS_enableBlueMissions = 0; // 10-2-2023 Tested with mission list= "sniperBase", "survivalSupplies", "Service_point", and "default"
GMS_numberUnderwaterDynamicMissions = 0;
GMS_enableHunterMissions = 0;
GMS_enableHunterMissions = 1;
GMS_enableScoutsMissions = 1;
GMS_enableStaticMissions = 1;
GMS_maxCrashSites = 0;

View File

@ -12,9 +12,9 @@
*/
class GMSBuild {
Version = "7.166";
Build = "271";
Date = "10-15-2023";
Version = "7.17";
Build = "272";
Date = "10-16-2023";
};
class CfgPatches {