From 641d40c1578a7c3032a4bdc30f0b0c81211e0fef Mon Sep 17 00:00:00 2001 From: eraser1 Date: Sun, 30 Aug 2015 23:51:06 -0500 Subject: [PATCH] DMSv1 is Live :D Still a few things left to do but... the system works! ;) --- @ExileServer/addons/a3_dms/fn_DMS_preInit.sqf | 1 + .../addons/a3_dms/missions/mission1.sqf | 67 ++++++++++++++----- .../addons/a3_dms/missions/mission2.sqf | 67 ++++++++++++++----- .../addons/a3_dms/missions/mission3.sqf | 67 ++++++++++++++----- .../addons/a3_dms/missions/mission4.sqf | 67 ++++++++++++++----- .../addons/a3_dms/missions/mission_init.sqf | 2 +- .../a3_dms/scripts/AddMissionToMonitor.sqf | 2 +- .../addons/a3_dms/scripts/CleanUp.sqf | 2 +- .../addons/a3_dms/scripts/FindSuppressor.sqf | 40 +++++++++++ .../addons/a3_dms/scripts/SpawnAISoldier.sqf | 2 +- 10 files changed, 241 insertions(+), 76 deletions(-) create mode 100644 @ExileServer/addons/a3_dms/scripts/FindSuppressor.sqf diff --git a/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf b/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf index 60393b6..bbed460 100644 --- a/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf +++ b/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf @@ -31,6 +31,7 @@ DMS_OnKilled = compileFinal preprocessFileLineNumbers "\x\addons\dms\script DMS_SetGroupBehavior = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\SetGroupBehavior.sqf"; DMS_AddMissionToMonitor = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\AddMissionToMonitor.sqf"; DMS_CreateMarker = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\CreateMarker.sqf"; +DMS_FindSuppressor = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\FindSuppressor.sqf";//<--- TODO Improve //Load config #include "config.sqf"; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/missions/mission1.sqf b/@ExileServer/addons/a3_dms/missions/mission1.sqf index 9e689fb..9dddc4a 100644 --- a/@ExileServer/addons/a3_dms/missions/mission1.sqf +++ b/@ExileServer/addons/a3_dms/missions/mission1.sqf @@ -5,7 +5,7 @@ Called from DMS_selectMission */ -private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_markers", "_time", "_added"]; +private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_missionAIUnits", "_missionObjs", "_markers", "_time", "_added"]; // For logging purposes _num = DMS_MissionCount; @@ -49,17 +49,31 @@ _crate_loot_values = ]; -// Setup Mission Start message +// Define mission-spawned AI Units +_missionAIUnits = +[ + _group // We only spawned the single group for this mission +]; + +// Define mission-spawned objects and loot values +_missionObjs = +[ + [], // No spawned buildings + [_crate], + _crate_loot_values +]; + +// Define Mission Start message _msgStart = format["A group of mercenaries has been spotted at %1! Kill them and take their equipment!",mapGridPosition _pos]; -// Setup Mission Win message +// Define Mission Win message _msgWIN = format["Convicts have successfully eliminated the mercenaries at %1!",mapGridPosition _pos]; -// Setup Mission Lose message -_msgWIN = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; +// Define Mission Lose message +_msgLOSE = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; -// Set mission name (for map marker and logging) +// Define mission name (for map marker and logging) _missionName = "Mercenary Group"; // Create Markers @@ -70,7 +84,10 @@ _markers = _difficulty ] call DMS_CreateMarker; +// Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly) _time = diag_tickTime; + +// Parse and add mission info to missions monitor _added = [ _pos, @@ -82,28 +99,42 @@ _added = [ "playerNear", [_pos,DMS_playerNearRadius] - ], + ] ], [ _time, (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0)) ], - [ - _group - ], - [ - [], // No spawned buildings - [_crate], - [_crate_loot_values] - ], - [_msgWIN,_msgLose], + _missionAIUnits, + _missionObjs, + [_msgWIN,_msgLOSE], _markers, _side ] call DMS_AddMissionToMonitor; +// Check to see if it was added correctly, otherwise delete the stuff if !(_added) exitWith { - diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor",_missionName]; + diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor! Deleting mission objects and resetting DMS_MissionCount.",_missionName]; + + // Delete AI units and the crate. I could do it in one line but I just made a little function that should work for every mission (provided you defined everything correctly) + _cleanup = []; + { + _cleanup pushBack _x; + false; + } count _missionAIUnits; + + _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); + + _cleanup call DMS_CleanUp; + + + // Delete the markers directly + {deleteMarker _x;false;} count _markers; + + + // Reset the mission count + DMS_MissionCount = DMS_MissionCount - 1; }; @@ -114,5 +145,5 @@ _msgStart call DMS_BroadcastMissionStatus; if (DMS_DEBUG) then { - diag_log format ["DMS_DEBUG %1 :: Mission #%2 started at %3 with %4 AI units and %5 difficulty",_missionName,_num,_pos,_AICount,_difficulty]; + diag_log format ["DMS_DEBUG MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]; }; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/missions/mission2.sqf b/@ExileServer/addons/a3_dms/missions/mission2.sqf index 922012e..171be52 100644 --- a/@ExileServer/addons/a3_dms/missions/mission2.sqf +++ b/@ExileServer/addons/a3_dms/missions/mission2.sqf @@ -2,7 +2,7 @@ Sample mission (duplicate for testing purposes) */ -private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_markers", "_time", "_added"]; +private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_missionAIUnits", "_missionObjs", "_markers", "_time", "_added"]; // For logging purposes _num = DMS_MissionCount; @@ -46,17 +46,31 @@ _crate_loot_values = ]; -// Setup Mission Start message +// Define mission-spawned AI Units +_missionAIUnits = +[ + _group // We only spawned the single group for this mission +]; + +// Define mission-spawned objects and loot values +_missionObjs = +[ + [], // No spawned buildings + [_crate], + _crate_loot_values +]; + +// Define Mission Start message _msgStart = format["A group of mercenaries has been spotted at %1! Kill them and take their equipment!",mapGridPosition _pos]; -// Setup Mission Win message +// Define Mission Win message _msgWIN = format["Convicts have successfully eliminated the mercenaries at %1!",mapGridPosition _pos]; -// Setup Mission Lose message -_msgWIN = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; +// Define Mission Lose message +_msgLOSE = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; -// Set mission name (for map marker and logging) +// Define mission name (for map marker and logging) _missionName = "Mercenary Group2"; // Create Markers @@ -67,7 +81,10 @@ _markers = _difficulty ] call DMS_CreateMarker; +// Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly) _time = diag_tickTime; + +// Parse and add mission info to missions monitor _added = [ _pos, @@ -79,28 +96,42 @@ _added = [ "playerNear", [_pos,DMS_playerNearRadius] - ], + ] ], [ _time, (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0)) ], - [ - _group - ], - [ - [], // No spawned buildings - [_crate], - [_crate_loot_values] - ], - [_msgWIN,_msgLose], + _missionAIUnits, + _missionObjs, + [_msgWIN,_msgLOSE], _markers, _side ] call DMS_AddMissionToMonitor; +// Check to see if it was added correctly, otherwise delete the stuff if !(_added) exitWith { - diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor",_missionName]; + diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor! Deleting mission objects and resetting DMS_MissionCount.",_missionName]; + + // Delete AI units and the crate. I could do it in one line but I just made a little function that should work for every mission (provided you defined everything correctly) + _cleanup = []; + { + _cleanup pushBack _x; + false; + } count _missionAIUnits; + + _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); + + _cleanup call DMS_CleanUp; + + + // Delete the markers directly + {deleteMarker _x;false;} count _markers; + + + // Reset the mission count + DMS_MissionCount = DMS_MissionCount - 1; }; @@ -111,5 +142,5 @@ _msgStart call DMS_BroadcastMissionStatus; if (DMS_DEBUG) then { - diag_log format ["DMS_DEBUG %1 :: Mission #%2 started at %3 with %4 AI units and %5 difficulty",_missionName,_num,_pos,_AICount,_difficulty]; + diag_log format ["DMS_DEBUG MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]; }; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/missions/mission3.sqf b/@ExileServer/addons/a3_dms/missions/mission3.sqf index ece2f6f..a5e84c2 100644 --- a/@ExileServer/addons/a3_dms/missions/mission3.sqf +++ b/@ExileServer/addons/a3_dms/missions/mission3.sqf @@ -2,7 +2,7 @@ Sample mission (duplicate for testing purposes) */ -private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_markers", "_time", "_added"]; +private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_missionAIUnits", "_missionObjs", "_markers", "_time", "_added"]; // For logging purposes _num = DMS_MissionCount; @@ -46,17 +46,31 @@ _crate_loot_values = ]; -// Setup Mission Start message +// Define mission-spawned AI Units +_missionAIUnits = +[ + _group // We only spawned the single group for this mission +]; + +// Define mission-spawned objects and loot values +_missionObjs = +[ + [], // No spawned buildings + [_crate], + _crate_loot_values +]; + +// Define Mission Start message _msgStart = format["A group of mercenaries has been spotted at %1! Kill them and take their equipment!",mapGridPosition _pos]; -// Setup Mission Win message +// Define Mission Win message _msgWIN = format["Convicts have successfully eliminated the mercenaries at %1!",mapGridPosition _pos]; -// Setup Mission Lose message -_msgWIN = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; +// Define Mission Lose message +_msgLOSE = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; -// Set mission name (for map marker and logging) +// Define mission name (for map marker and logging) _missionName = "Mercenary Group3"; // Create Markers @@ -67,7 +81,10 @@ _markers = _difficulty ] call DMS_CreateMarker; +// Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly) _time = diag_tickTime; + +// Parse and add mission info to missions monitor _added = [ _pos, @@ -79,28 +96,42 @@ _added = [ "playerNear", [_pos,DMS_playerNearRadius] - ], + ] ], [ _time, (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0)) ], - [ - _group - ], - [ - [], // No spawned buildings - [_crate], - [_crate_loot_values] - ], - [_msgWIN,_msgLose], + _missionAIUnits, + _missionObjs, + [_msgWIN,_msgLOSE], _markers, _side ] call DMS_AddMissionToMonitor; +// Check to see if it was added correctly, otherwise delete the stuff if !(_added) exitWith { - diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor",_missionName]; + diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor! Deleting mission objects and resetting DMS_MissionCount.",_missionName]; + + // Delete AI units and the crate. I could do it in one line but I just made a little function that should work for every mission (provided you defined everything correctly) + _cleanup = []; + { + _cleanup pushBack _x; + false; + } count _missionAIUnits; + + _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); + + _cleanup call DMS_CleanUp; + + + // Delete the markers directly + {deleteMarker _x;false;} count _markers; + + + // Reset the mission count + DMS_MissionCount = DMS_MissionCount - 1; }; @@ -111,5 +142,5 @@ _msgStart call DMS_BroadcastMissionStatus; if (DMS_DEBUG) then { - diag_log format ["DMS_DEBUG %1 :: Mission #%2 started at %3 with %4 AI units and %5 difficulty",_missionName,_num,_pos,_AICount,_difficulty]; + diag_log format ["DMS_DEBUG MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]; }; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/missions/mission4.sqf b/@ExileServer/addons/a3_dms/missions/mission4.sqf index 677f987..7803ac9 100644 --- a/@ExileServer/addons/a3_dms/missions/mission4.sqf +++ b/@ExileServer/addons/a3_dms/missions/mission4.sqf @@ -2,7 +2,7 @@ Sample mission (duplicate for testing purposes) */ -private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_markers", "_time", "_added"]; +private ["_num", "_side", "_pos", "_difficulty", "_AICount", "_group", "_crate", "_crate_loot_values", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_missionAIUnits", "_missionObjs", "_markers", "_time", "_added"]; // For logging purposes _num = DMS_MissionCount; @@ -46,17 +46,31 @@ _crate_loot_values = ]; -// Setup Mission Start message +// Define mission-spawned AI Units +_missionAIUnits = +[ + _group // We only spawned the single group for this mission +]; + +// Define mission-spawned objects and loot values +_missionObjs = +[ + [], // No spawned buildings + [_crate], + _crate_loot_values +]; + +// Define Mission Start message _msgStart = format["A group of mercenaries has been spotted at %1! Kill them and take their equipment!",mapGridPosition _pos]; -// Setup Mission Win message +// Define Mission Win message _msgWIN = format["Convicts have successfully eliminated the mercenaries at %1!",mapGridPosition _pos]; -// Setup Mission Lose message -_msgWIN = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; +// Define Mission Lose message +_msgLOSE = format["The mercenaries are no longer at %1!",mapGridPosition _pos]; -// Set mission name (for map marker and logging) +// Define mission name (for map marker and logging) _missionName = "Mercenary Group4"; // Create Markers @@ -67,7 +81,10 @@ _markers = _difficulty ] call DMS_CreateMarker; +// Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly) _time = diag_tickTime; + +// Parse and add mission info to missions monitor _added = [ _pos, @@ -79,28 +96,42 @@ _added = [ "playerNear", [_pos,DMS_playerNearRadius] - ], + ] ], [ _time, (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0)) ], - [ - _group - ], - [ - [], // No spawned buildings - [_crate], - [_crate_loot_values] - ], - [_msgWIN,_msgLose], + _missionAIUnits, + _missionObjs, + [_msgWIN,_msgLOSE], _markers, _side ] call DMS_AddMissionToMonitor; +// Check to see if it was added correctly, otherwise delete the stuff if !(_added) exitWith { - diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor",_missionName]; + diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor! Deleting mission objects and resetting DMS_MissionCount.",_missionName]; + + // Delete AI units and the crate. I could do it in one line but I just made a little function that should work for every mission (provided you defined everything correctly) + _cleanup = []; + { + _cleanup pushBack _x; + false; + } count _missionAIUnits; + + _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); + + _cleanup call DMS_CleanUp; + + + // Delete the markers directly + {deleteMarker _x;false;} count _markers; + + + // Reset the mission count + DMS_MissionCount = DMS_MissionCount - 1; }; @@ -111,5 +142,5 @@ _msgStart call DMS_BroadcastMissionStatus; if (DMS_DEBUG) then { - diag_log format ["DMS_DEBUG %1 :: Mission #%2 started at %3 with %4 AI units and %5 difficulty",_missionName,_num,_pos,_AICount,_difficulty]; + diag_log format ["DMS_DEBUG MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]; }; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/missions/mission_init.sqf b/@ExileServer/addons/a3_dms/missions/mission_init.sqf index 4ca8b49..47e6f41 100644 --- a/@ExileServer/addons/a3_dms/missions/mission_init.sqf +++ b/@ExileServer/addons/a3_dms/missions/mission_init.sqf @@ -18,7 +18,7 @@ DMS_BMissionDelay = (DMS_TimeBetweenMissions select 0) + random((DMS_TimeBetween if (DMS_DEBUG) then { - diag_log format ["DMS_DEBUG mission_init :: Random time between missions is initialized at %1s | DMS_BMissionLastStart: %2",DMS_BMissionDelay,DMS_BMissionLastStart]; + diag_log format ["DMS_DEBUG mission_init :: Random time between missions is initially set to %1s | DMS_BMissionLastStart: %2",DMS_BMissionDelay,DMS_BMissionLastStart]; }; // Set mission frequencies from config diff --git a/@ExileServer/addons/a3_dms/scripts/AddMissionToMonitor.sqf b/@ExileServer/addons/a3_dms/scripts/AddMissionToMonitor.sqf index 78822ac..590fdea 100644 --- a/@ExileServer/addons/a3_dms/scripts/AddMissionToMonitor.sqf +++ b/@ExileServer/addons/a3_dms/scripts/AddMissionToMonitor.sqf @@ -35,7 +35,7 @@ [ [_cleanupObj1,_cleanupObj2,...,_cleanupObjX], [_crate,_vehicle1,_vehicle2,...,_vehicleX], - [_crate_loot_values] + _crate_loot_values ], [_msgWIN,_msgLose], [_markerDot,_markerCircle], diff --git a/@ExileServer/addons/a3_dms/scripts/CleanUp.sqf b/@ExileServer/addons/a3_dms/scripts/CleanUp.sqf index e22a3ca..7e69c38 100644 --- a/@ExileServer/addons/a3_dms/scripts/CleanUp.sqf +++ b/@ExileServer/addons/a3_dms/scripts/CleanUp.sqf @@ -82,7 +82,7 @@ _clean = { if (!isNull _x) then { - // Group cleanup should only be called when mission times out, so no need to check for nearby players + // Group cleanup should only be called when it has to be deleted regardless, so no need to check for nearby players { _x call _clean; false; diff --git a/@ExileServer/addons/a3_dms/scripts/FindSuppressor.sqf b/@ExileServer/addons/a3_dms/scripts/FindSuppressor.sqf new file mode 100644 index 0000000..7f7b81d --- /dev/null +++ b/@ExileServer/addons/a3_dms/scripts/FindSuppressor.sqf @@ -0,0 +1,40 @@ +/* + DMS_FindSuppressor + Taken from WAI + Modified by eraser1 + + Usage: + _weaponClassName call DMS_FindSuppressor; + +*/ + +private["_weapon","_result","_ammoName"]; + +_result = ""; +_weapon = _this; + +// Zafir accepts no suppressors :( +if (_weapon=="LMG_Zafir_F") exitWith {""}; + + +_ammoName = getText (configFile >> "cfgWeapons" >> _weapon >> "displayName"); + + +if ((_ammoName find "5.56") > -1) then +{ + _result = "muzzle_snds_M"; +}; + +if ((_ammoName find "6.5") > -1) then +{ + _result = "muzzle_snds_H"; +}; + +if ((_ammoName find "7.62") > -1) then +{ + _result = "muzzle_snds_H"; +}; + +//TODO Add functionality for 9.3 and .338 + +_result \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/scripts/SpawnAISoldier.sqf b/@ExileServer/addons/a3_dms/scripts/SpawnAISoldier.sqf index 9da1400..a4f7f39 100644 --- a/@ExileServer/addons/a3_dms/scripts/SpawnAISoldier.sqf +++ b/@ExileServer/addons/a3_dms/scripts/SpawnAISoldier.sqf @@ -143,7 +143,7 @@ if (!_useCustomGear) then if((random 100) <= (missionNamespace getVariable [format["DMS_%1_suppressor_chance",_type],0])) then { - _suppressor = _weapon call find_suitable_suppressor; + _suppressor = _weapon call DMS_FindSuppressor; if(_suppressor != "") then { _unit addPrimaryWeaponItem _suppressor;