From c4a9b3f1b2560ee98d41204d813e8feeae56ba8e Mon Sep 17 00:00:00 2001 From: eraser1 Date: Sun, 22 May 2016 15:15:38 -0500 Subject: [PATCH] Fixes + Additions --- @ExileServer/addons/a3_dms/config.cpp | 3 +- @ExileServer/addons/a3_dms/config.sqf | 1 + .../a3_dms/scripts/fn_FindSuppressor.sqf | 4 ++- .../a3_dms/scripts/fn_FreezeManager.sqf | 12 ++++--- .../addons/a3_dms/scripts/fn_FreezeToggle.sqf | 33 +++++++++++++++++++ .../addons/a3_dms/scripts/fn_SpawnAIGroup.sqf | 5 +++ .../scripts/fn_SpawnAIGroup_MultiPos.sqf | 5 +++ .../a3_dms/scripts/fn_SpawnAISoldier.sqf | 2 +- .../a3_dms/scripts/fn_SpawnAIStaticMG.sqf | 5 +++ .../a3_dms/scripts/fn_SpawnAIVehicle.sqf | 11 +++++++ README.md | 11 +++++++ 11 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 @ExileServer/addons/a3_dms/scripts/fn_FreezeToggle.sqf diff --git a/@ExileServer/addons/a3_dms/config.cpp b/@ExileServer/addons/a3_dms/config.cpp index 4debdb6..e6c54d8 100644 --- a/@ExileServer/addons/a3_dms/config.cpp +++ b/@ExileServer/addons/a3_dms/config.cpp @@ -4,7 +4,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; - a3_DMS_version = "May 22, 2016 (TEST)"; + a3_DMS_version = "May 22, 2016 (2) (TEST)"; requiredVersion = 1.36; requiredAddons[] = {"exile_client","exile_server_config"}; }; @@ -42,6 +42,7 @@ class CfgFunctions class FindSafePos_InRange {}; class FindSuppressor {}; class FreezeManager {}; + class FreezeToggle {}; class GetAllUnits {}; class GetCenter {}; class GetEmptySeats {}; diff --git a/@ExileServer/addons/a3_dms/config.sqf b/@ExileServer/addons/a3_dms/config.sqf index 4be267e..ae52452 100644 --- a/@ExileServer/addons/a3_dms/config.sqf +++ b/@ExileServer/addons/a3_dms/config.sqf @@ -343,6 +343,7 @@ DMS_SpawnMissions_Scheduled = false; // Whether or not to spawn missions in a sc DMS_ai_unfreezingDistance = 3500; // If there are players within this distance of the leader of an AI group, then the AI group will be "un-frozen". DMS_ai_offloadOnUnfreeze = true; // Whether or not to offload AI to clients once they have been "un-frozen". NOTE: This config will be ignored if "DMS_ai_offload_to_client" is set to false. DMS_ai_freezeCheckingDelay = 30; // How often (in seconds) DMS will check whether to freeze/un-freeze AI. + DMS_ai_freezeOnSpawn = true; // Whether or not to freeze an AI group when initially spawned. DMS_ai_share_info = true; // Share info about killer DMS_ai_share_info_distance = 300; // The distance killer's info will be shared to other AI diff --git a/@ExileServer/addons/a3_dms/scripts/fn_FindSuppressor.sqf b/@ExileServer/addons/a3_dms/scripts/fn_FindSuppressor.sqf index d22cf83..188c4f4 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_FindSuppressor.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_FindSuppressor.sqf @@ -16,7 +16,7 @@ private _weaponName = getText (configFile >> "cfgWeapons" >> _weapon >> "displa switch (true) do { // Zafir accepts no suppressors :( - case ((_weapon find "Zafir")>-1) : {""}; + //case ((_weapon find "Zafir")>-1) : {""}; case ((_weaponName find "6.5") > -1) : { @@ -41,4 +41,6 @@ switch (true) do case ((_weaponName find ".338") > -1) : {selectRandom ["muzzle_snds_338_black","muzzle_snds_338_green","muzzle_snds_338_sand"]}; case ((_weaponName find "9.3 mm") > -1) : {selectRandom ["muzzle_snds_93mmg","muzzle_snds_93mmg_tan"]}; + + default {""}; }; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_FreezeManager.sqf b/@ExileServer/addons/a3_dms/scripts/fn_FreezeManager.sqf index fcc9e77..3074056 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_FreezeManager.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_FreezeManager.sqf @@ -24,12 +24,12 @@ private _recentlyUnfrozen = []; private _leader = leader _x; if ([_leader,DMS_ai_unfreezingDistance] call DMS_fnc_IsPlayerNearby) then { - {_x enableSimulationGlobal true} forEach (units _x); + [_x,false] call DMS_fnc_FreezeToggle; _recentlyUnfrozen pushBack _x; if (DMS_ai_offloadOnUnfreeze) then { - [_group, _leader] call DMS_fnc_SetAILocality; + [_x, _leader] call DMS_fnc_SetAILocality; }; if (DMS_DEBUG) then @@ -51,8 +51,12 @@ private _recentlyUnfrozen = []; if ((!isNull _leader) && {alive _leader} && {!(isPlayer _leader)} && {!([_leader,DMS_ai_freezingDistance] call DMS_fnc_IsPlayerNearby)}) then { - {_x enableSimulationGlobal false} forEach (units _group); - DMS_FrozenAIGroups pushBack _group; + [_group,true] call DMS_fnc_FreezeToggle; + + if (DMS_DEBUG) then + { + format["FreezeManager :: Froze AI Group: %1",_group] call DMS_fnc_DebugLog; + }; // So that we don't check this group for freezing later on. _group setVariable ["DMS_AllowFreezing",false]; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_FreezeToggle.sqf b/@ExileServer/addons/a3_dms/scripts/fn_FreezeToggle.sqf new file mode 100644 index 0000000..1d9199b --- /dev/null +++ b/@ExileServer/addons/a3_dms/scripts/fn_FreezeToggle.sqf @@ -0,0 +1,33 @@ +/* + DMS_fnc_FreezeToggle + created by eraser1 + + Usage: + [ + _group, // GROUP: The AI Group to be frozen + _freeze // BOOL: "true" if you want to freeze, false if you want to un-freeze + ] call DMS_fnc_FreezeToggle; + + Freezes/un-freezes a specified group. +*/ + +if !(params +[ + "_group", + "_freeze" +]) exitWith +{ + diag_log format["DMS ERROR :: Calling DMS_fnc_FreezeToggle with invalid parameters: %1",_this]; +}; + +if (_freeze) then +{ + {_x enableSimulationGlobal false} forEach (units _group); + _group setVariable ["DMS_isGroupFrozen",true]; + DMS_FrozenAIGroups pushBack _group; +} +else +{ + {_x enableSimulationGlobal true} forEach (units _group); + _group setVariable ["DMS_isGroupFrozen",false]; +}; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup.sqf index c95caa3..52e490c 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup.sqf @@ -122,6 +122,11 @@ _group setFormation "WEDGE"; [_group,_pos,_difficulty,"COMBAT"] call DMS_fnc_SetGroupBehavior; +if (DMS_ai_freezeOnSpawn) then +{ + [_group,true] call DMS_fnc_FreezeToggle; +}; + diag_log format ["DMS_SpawnAIGroup :: Spawned %1 AI at %2.",_count,_pos]; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup_MultiPos.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup_MultiPos.sqf index ea653f4..01f635a 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup_MultiPos.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIGroup_MultiPos.sqf @@ -138,6 +138,11 @@ _group setFormation "WEDGE"; [_group,_positions select 0,_difficulty,"COMBAT"] call DMS_fnc_SetGroupBehavior; +if (DMS_ai_freezeOnSpawn) then +{ + [_group,true] call DMS_fnc_FreezeToggle; +}; + diag_log format ["DMS_SpawnAIGroup_MultiPos :: Spawned %1 AI using positions parameter: %2.",_count,_positions]; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAISoldier.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAISoldier.sqf index 257d997..cda8d1d 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAISoldier.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAISoldier.sqf @@ -210,7 +210,7 @@ if (_customGearSet isEqualTo []) then if((random 100) <= (missionNamespace getVariable [format["DMS_%1_suppressor_chance",_class],0])) then { private _suppressor = _weapon call DMS_fnc_FindSuppressor; - if(_suppressor != "") then + if (_suppressor != "") then { _unit addPrimaryWeaponItem _suppressor; }; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIStaticMG.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIStaticMG.sqf index 6fff976..6515ccf 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIStaticMG.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIStaticMG.sqf @@ -66,6 +66,11 @@ private _guns = _positions apply reload _unit; _unit setVariable ["DMS_AssignedVeh",_gun]; + if (_group getVariable ["DMS_isGroupFrozen",false]) then + { + _unit enableSimulationGlobal false; + }; + if (DMS_DEBUG) then { (format ["SpawnAIStaticMG :: Created unit %1 at %2 as static gunner in %3",_unit,_x,_gun]) call DMS_fnc_DebugLog; diff --git a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIVehicle.sqf b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIVehicle.sqf index bc59e9b..68cfb5e 100644 --- a/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIVehicle.sqf +++ b/@ExileServer/addons/a3_dms/scripts/fn_SpawnAIVehicle.sqf @@ -65,15 +65,26 @@ _veh lock 2; _group addVehicle _veh; +private _toFreeze = _group getVariable ["DMS_isGroupFrozen",false]; + private _driver = [_group,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; _driver moveInDriver _veh; _driver setVariable ["DMS_AssignedVeh",_veh]; +if (_toFreeze) then +{ + _driver enableSimulationGlobal false; +}; + private _crewCount = { private _unit = [_group,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; _unit moveInTurret [_veh, _x]; _unit setVariable ["DMS_AssignedVeh",_veh]; + if (_toFreeze) then + { + _unit enableSimulationGlobal false; + }; true } count (allTurrets [_veh, true]); diff --git a/README.md b/README.md index 197b8b6..120b6ee 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,17 @@ ___ # Changelog: ### Test Branch: +#### May 22, 2016 (3:15 PM CST-America): +* **NEW CONFIG VALUES:** + DMS_ai_freezeOnSpawn +* Added the ability to freeze AI groups immediately upon spawn. +* Units spawned to a group that has been frozen should now also be frozen. +* Fixed an issue where "FindSuppressor" would return a boolean instead of empty string. +* Fixed an issue with undefined variable when "DMS_ai_offloadOnUnfreeze" was set to true. +* Added debug message when a group is frozen. +* Created a new function "DMS_fnc_FreezeToggle" that actually handles freezing/unfreezing. +* DMS will now apply a variable "DMS_isGroupFrozen" to groups that are frozen. + #### May 22, 2016 (12:00 AM CST-America): * **NEW CONFIG VALUES:** DMS_ai_allowFreezing