From 75fd82987e256c614481ec1ed768eb4423a2af10 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 22 Jan 2019 16:38:05 +0100 Subject: [PATCH 01/30] Removed execVM Replaced with spawn compile preprocessfilelinenumbers --- Vcom/VcomInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vcom/VcomInit.sqf b/Vcom/VcomInit.sqf index 3705a01..2e075da 100644 --- a/Vcom/VcomInit.sqf +++ b/Vcom/VcomInit.sqf @@ -30,7 +30,7 @@ VCOM_MINEARRAY = []; sleep 2; //Begin Artillery function created by Rydygier - https://forums.bohemia.net/forums/topic/159152-fire-for-effect-the-god-of-war-smart-simple-ai-artillery/ - if (VCM_FFEARTILLERY) then {nul = [] execVM "Vcom\RYD_FFE\FFE.sqf";VCM_ARTYENABLE = false;}; + if (VCM_FFEARTILLERY) then {nul = [] spawn (compile preprocessFileLineNumbers "Vcom\RYD_FFE\FFE.sqf");VCM_ARTYENABLE = false;}; [] spawn VCM_fnc_AIDRIVEBEHAVIOR; From e4dfd5f1ef52a53e456dc5e6b0988569720a54e7 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 31 Jan 2019 18:07:45 +0100 Subject: [PATCH 02/30] VCOM Situation Framework This framework is meant to make it easier to check what the AI is currently doing, e.g. flanking, CQC or garrisoned in a single variable. --- Vcom/FSMS/fn_SQUADBEH.fsm | 74 ++++++++++++------- .../Functions/VCM_Functions/fn_ArmStatics.sqf | 1 + .../VCM_Functions/fn_ClearBuilding.sqf | 4 +- .../{ => garrison}/fn_Garrison.sqf | 0 .../{ => garrison}/fn_GarrisonLight.sqf | 34 ++++----- .../garrison/fn_IsPreGarrisoned.sqf | 12 +++ .../VCM_Functions/garrison/fn_UnGarrisonL.sqf | 27 +++++++ .../situation/fn_CheckSituation.sqf | 23 ++++++ .../situation/fn_SetSituation.sqf | 21 ++++++ Vcom/cfgFunctions.hpp | 34 +++++++-- 10 files changed, 178 insertions(+), 52 deletions(-) rename Vcom/Functions/VCM_Functions/{ => garrison}/fn_Garrison.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => garrison}/fn_GarrisonLight.sqf (67%) create mode 100644 Vcom/Functions/VCM_Functions/garrison/fn_IsPreGarrisoned.sqf create mode 100644 Vcom/Functions/VCM_Functions/garrison/fn_UnGarrisonL.sqf create mode 100644 Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf create mode 100644 Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index 20a35b6..a42b28e 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -2,7 +2,7 @@ /*%FSM*/ /* item0[] = {"Begin_State",0,250,50.000000,700.000000,150.000000,750.000000,0.000000,"Begin State"}; -item1[] = {"Cond",4,4314,-100.000000,700.000000,0.000000,750.000000,50.000000,"Cond"}; +item1[] = {"Cond",4,218,-100.000000,700.000000,0.000000,750.000000,50.000000,"Cond"}; item2[] = {"Exit_FSM",1,250,-250.000000,700.000000,-175.000000,750.000000,0.000000,"Exit FSM"}; item3[] = {"Continue",8,218,50.000000,575.000000,150.000000,625.000000,0.000000,"Continue"}; item4[] = {"Start_Point",2,250,50.000000,400.000000,150.000000,450.000000,0.000000,"Start Point"}; @@ -44,7 +44,7 @@ item39[] = {"True",8,218,750.000000,75.000000,850.000000,125.000000,0.000000,"Tr item40[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; item41[] = {"Exit_FSM_2",1,250,700.000000,600.000000,775.000000,650.000000,0.000000,"Exit FSM"}; item42[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; -item43[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; +item43[] = {"Clear_Building",4,4314,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; item44[] = {"Combat_END",4,218,684.709351,384.913361,784.709351,434.913361,90.000000,"Combat END"}; link0[] = {0,1}; link1[] = {0,3}; @@ -113,8 +113,8 @@ link63[] = {40,41}; link64[] = {42,27}; link65[] = {43,27}; link66[] = {44,27}; -globals[] = {0.000000,0,0,0,0,640,480,2,623,6316128,1,-602.326355,300.841248,816.916199,6.357727,985,884,1}; -window[] = {2,-1,-1,-1,-1,1036,136,881,82,3,1003}; +globals[] = {0.000000,0,0,0,0,640,480,2,623,6316128,1,378.398834,1562.328491,774.864380,-69.844208,1239,884,1}; +window[] = {2,-1,-1,-1,-1,1006,52,797,52,3,1257}; *//*%FSM*/ class FSM { @@ -166,8 +166,7 @@ class FSM "private _BackbkC7 = -30;" \n "private _BackbkC8 = -120;" \n "private _BackbkC9 = -300;" \n - "private _CurLGar = false;" \n - "private _VCOM_GARRISONED = false;" \n + "private _situation = ""READY"";" \n "private _Beh = (behaviour _leader);" \n "private _Cover2Cover = -60;" \n "private _WaypointGen = -910;" \n @@ -493,9 +492,14 @@ class FSM "private _index = currentWaypoint _Group;" \n "private _WaypointIs = waypointType [_Group,_index];" \n "" \n - "if (!(_WaypointIs isEqualTo ""HOLD"")) then" \n + "if (!(_WaypointIs isEqualTo ""HOLD"") && {_situation isEqualTo ""GARRISONED""}) then" \n "{" \n - " _VCOM_GARRISONED = false;" \n + " _situation = ""READY"";" \n + "};" \n + "" \n + "if (count waypoints _Group <= 1 && {_situation isEqualTo ""FLANKING""}) then" \n + "{" \n + " _situation = ""READY"";" \n "};" \n "" \n "" \n @@ -530,7 +534,7 @@ class FSM priority = 110.000000; to="Combat_Brain"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_Beh isEqualTo ""COMBAT"")} && {!(_VCOM_GARRISONED)}"/*%FSM*/; + condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_Beh isEqualTo ""COMBAT"")} && {!(_situation isEqualTo ""GARRISON"")}"/*%FSM*/; action=/*%FSM*/"//[_Leader,50] call VCM_fnc_FindCover;" \n "_Cover2Cover = time;" \n "_Beh = ""COMBAT"";" \n @@ -544,7 +548,7 @@ class FSM priority = 100.000000; to="Combat_Brain"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_VCOM_GARRISONED)}"/*%FSM*/; + condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_situation isEqualTo ""GARRISON"")}"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -555,7 +559,7 @@ class FSM priority = 90.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_VCOM_GARRISONED)} && {_leader distance (_leader call VCM_fnc_ClstEmy) > 400}" \n + condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_situation isEqualTo ""GARRISON"")} && {_leader distance (_leader call VCM_fnc_ClstEmy) > 400}" \n ""/*%FSM*/; action=/*%FSM*/"// return behaviour and speed to normal" \n "_Beh = ""SAFE"";" \n @@ -579,13 +583,13 @@ class FSM priority = 48.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"_WaypointIs isEqualTo ""HOLD"" && {!(_VCOM_GARRISONED)}" \n + condition=/*%FSM*/"_WaypointIs isEqualTo ""HOLD"" && {!(_situation isEqualTo ""GARRISONED"")}" \n "" \n "//(waypointScript [_group,_index]) isEqualTo ""Garrison"";" \n ""/*%FSM*/; - action=/*%FSM*/"if (!_VCOM_GARRISONED) then {" \n + action=/*%FSM*/"if !(_situation isEqualTo ""GARRISONED"") then {" \n " _group spawn VCM_fnc_Garrison;" \n - " _VCOM_GARRISONED = true;" \n + " _situation = ""GARRISONED"";" \n "};"/*%FSM*/; }; /*%FSM*/ @@ -665,6 +669,7 @@ class FSM to="Return"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_WaypointGen + 900 < time && " \n + "{_situation isEqualTo ""READY""} &&" \n "{VCM_ADVANCEDMOVEMENT} &&" \n "{" \n " isNil {(waypoints _Group) select 1} ||" \n @@ -672,6 +677,7 @@ class FSM "}"/*%FSM*/; action=/*%FSM*/"[_Leader] spawn VCM_fnc_FlankMove;" \n "_WaypointGen = time;" \n + "_situation = ""FLANKING"";" \n "" \n "if (VCM_Debug) then {systemchat ""VCOM: WAYPOINT GENERATION"";};"/*%FSM*/; }; @@ -683,7 +689,8 @@ class FSM priority = 104.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"_Cover2Cover + 60 < time && {!_CurLGar}"/*%FSM*/; + condition=/*%FSM*/"_Cover2Cover + 60 < time && " \n + "{!(_situation isEqualTo ""LGARRISON"")}"/*%FSM*/; action=/*%FSM*/"_Cover2Cover = time;" \n "[_Leader,100] call VCM_fnc_ForceMove;" \n "" \n @@ -770,7 +777,9 @@ class FSM priority = 91.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"(_BackbkC7 + 30 < time) && {((_NearestEnemy distance2D _leader) < 800)} && {[_Group] call VCM_fnc_EmptyStatic};"/*%FSM*/; + condition=/*%FSM*/"(_BackbkC7 + 30 < time) && " \n + "{((_NearestEnemy distance2D _leader) < 800)} && " \n + "{[_Group] call VCM_fnc_EmptyStatic};"/*%FSM*/; action=/*%FSM*/"_Group call VCM_fnc_ArmStatics;_BackbkC7 = time;" \n "" \n "if (VCM_Debug) then {systemchat ""VCOM: ARM STATICS"";};"/*%FSM*/; @@ -796,14 +805,18 @@ class FSM " };" \n " _rtrn" \n "} &&" \n - "{!_CurLGar}" \n + "{" \n + " _situation isEqualTo ""READY"" ||" \n + " {_situation isEqualTo ""FLANKING""}" \n + "}" \n ""/*%FSM*/; - action=/*%FSM*/"_CurLGar = true;" \n - "_Group call VCM_fnc_GarrisonLight;" \n - "_BackbkC9 = time;" \n + action=/*%FSM*/"_BackbkC9 = time;" \n "private _t = time;" \n "private _Wait = 120;" \n - ""/*%FSM*/; + "if (_Group call VCM_fnc_GarrisonLight) then" \n + "{" \n + " _situation = ""LGARRISON"";" \n + "};"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ @@ -826,6 +839,7 @@ class FSM " };" \n " _rtrn" \n "} &&" \n + "{!(_situation isEqualTo ""LGARRISON"")} &&" \n "{count _MineList > 0}"/*%FSM*/; action=/*%FSM*/"//[_x,(_Vcom_MineObject select 0)]" \n "{" \n @@ -864,7 +878,11 @@ class FSM priority = 84.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"VCM_ARTYENABLE && {(_ArtyT + VCM_ARTYDELAY) < time} && {side _Group in VCM_ARTYSIDES} && {!(_NearestEnemy isEqualTo [0,0,0])} && {count (units (group _NearestEnemy)) > 2}"/*%FSM*/; + condition=/*%FSM*/"VCM_ARTYENABLE && " \n + "{(_ArtyT + VCM_ARTYDELAY) < time} && " \n + "{side _Group in VCM_ARTYSIDES} && " \n + "{!(_NearestEnemy isEqualTo [0,0,0])} && " \n + "{count (units (group _NearestEnemy)) > 2}"/*%FSM*/; action=/*%FSM*/"[_Group,(group _NearestEnemy)] call VCM_fnc_ArtyCall;" \n "switch ((side _Group)) do {" \n " case west: {VCM_ARTYWT = time;};" \n @@ -882,13 +900,17 @@ class FSM priority = 50.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"_BackbkC8 + 15 < time && {!_CurLGar} && {_ClearCnc < 51} && {leader _Group distance2D _NearestEnemy < 100}"/*%FSM*/; + condition=/*%FSM*/"_BackbkC8 + 15 < time && " \n + "{_ClearCnc < 51} && " \n + "{" \n + " _situation isEqualTo ""FLANKING"" ||" \n + " {_situation isEqualTo ""READY""}" \n + "} && " \n + "{leader _Group distance2D _NearestEnemy < 100}"/*%FSM*/; action=/*%FSM*/"[_Group,_NearestEnemy] call VCM_fnc_ClearBuilding;" \n "private _t = time;" \n "private _Wait = 10;" \n - "_BackbkC8 = time;" \n - "" \n - "if (VCM_Debug) then {systemchat ""VCOM: CLEAR BUILDING"";};"/*%FSM*/; + "_BackbkC8 = time;"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ diff --git a/Vcom/Functions/VCM_Functions/fn_ArmStatics.sqf b/Vcom/Functions/VCM_Functions/fn_ArmStatics.sqf index bb5fa3c..83b5c6a 100644 --- a/Vcom/Functions/VCM_Functions/fn_ArmStatics.sqf +++ b/Vcom/Functions/VCM_Functions/fn_ArmStatics.sqf @@ -45,6 +45,7 @@ if (count _assignedPairs isEqualTo 0) exitWith {}; private _assignedGunner = assignedGunner _weap; if (isNull _assignedGunner) then { + _unit enableAI "PATH"; //Overwrites garrison _unit doMove (getposATL _weap); _unit assignAsGunner _weap; [_unit] orderGetIn true; diff --git a/Vcom/Functions/VCM_Functions/fn_ClearBuilding.sqf b/Vcom/Functions/VCM_Functions/fn_ClearBuilding.sqf index 3d268d5..d0d622c 100644 --- a/Vcom/Functions/VCM_Functions/fn_ClearBuilding.sqf +++ b/Vcom/Functions/VCM_Functions/fn_ClearBuilding.sqf @@ -18,6 +18,8 @@ params ["_group","_enemy"]; private _nBuildingLst = nearestObjects [_enemy, ["House", "Building"], 25]; if (count _nBuildingLst < 1) exitWith {}; +if VCM_Debug then {systemChat format ["VCOM: %1 clearing out %2", _group, _enemy]}; + private _buildingPositions = []; { @@ -46,5 +48,5 @@ private _clstP = [_tempA,_enemy,true,"Clear1"] call VCM_fnc_ClstObj; { doStop _x; - _x doMove _clstP; + _x doMove _clstP; } foreach (units _group); \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/fn_Garrison.sqf b/Vcom/Functions/VCM_Functions/garrison/fn_Garrison.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_Garrison.sqf rename to Vcom/Functions/VCM_Functions/garrison/fn_Garrison.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_GarrisonLight.sqf b/Vcom/Functions/VCM_Functions/garrison/fn_GarrisonLight.sqf similarity index 67% rename from Vcom/Functions/VCM_Functions/fn_GarrisonLight.sqf rename to Vcom/Functions/VCM_Functions/garrison/fn_GarrisonLight.sqf index 28873f2..212fb9c 100644 --- a/Vcom/Functions/VCM_Functions/fn_GarrisonLight.sqf +++ b/Vcom/Functions/VCM_Functions/garrison/fn_GarrisonLight.sqf @@ -22,7 +22,7 @@ private _units = units _group; } foreach (nearestObjects [_leader, ["House", "Building"], 50]); //Exit if no compatible buildings found -if (_foundBuildings isEqualTo []) exitWith {(_group getVariable "VCM_SQUADFSM") setFSMVariable ["_CurLGar", false];}; +if (_foundBuildings isEqualTo []) exitWith {false}; private _buildingPositions = [_foundBuildings select 0] call BIS_fnc_buildingPositions; @@ -44,7 +44,7 @@ if VCM_DEBUG then {systemChat format ["VCOM: %1 PERFORMING LIGHT GARRISON", _gro (alive _unit) && {_t + 60 > time} && {_unit distance _buildingPos > 1.3} && - {(_group getVariable "VCM_SQUADFSM") getFSMVariable ["_CurLGar", false]} + {(_group call VCM_fnc_CheckSituation) isEqualTo "LGARRISON"} } do { sleep 3; @@ -54,27 +54,27 @@ if VCM_DEBUG then {systemChat format ["VCOM: %1 PERFORMING LIGHT GARRISON", _gro // If move times out or unit dies, skip. if ( - (alive _unit) && - {_t + 60 > time} && - {(_group getVariable "VCM_SQUADFSM") getFSMVariable ["_CurLGar", false]} + (_unit distance _buildingPos < 1.3) ) then { _unit disableAI "PATH"; - sleep 120; - }; - - // if unit is leader, ungarrison entire group. - if (leader _unit isEqualTo _unit) then - { - private _group = group _unit; - (_group getVariable "VCM_SQUADFSM") setFSMVariable ["_CurLGar", false]; + waitUntil { - _x enableAI "PATH"; - } forEach units _group; - if VCM_DEBUG then {systemChat format ["VCOM: %1 UN-L-GARRISONING BUILDING", _group]}; + sleep 10; + !((_group call VCM_fnc_CheckSituation) isEqualTo "LGARRISON") && + { + if (leader _unit isEqualTo _unit && {_t + 150 > time}) then + { + _group call VCM_fnc_UnGarrisonL; + }; + } + }; }; + }; private _rmv = _buildingPositions findIf {_buildingPos isEqualTo _x}; _buildingPositions deleteAt _rmv; }; -} foreach _units; \ No newline at end of file +} foreach _units; + +true \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/garrison/fn_IsPreGarrisoned.sqf b/Vcom/Functions/VCM_Functions/garrison/fn_IsPreGarrisoned.sqf new file mode 100644 index 0000000..490582f --- /dev/null +++ b/Vcom/Functions/VCM_Functions/garrison/fn_IsPreGarrisoned.sqf @@ -0,0 +1,12 @@ +/* + Author: Genesis, tweaked by Freddo + + Description: + Function for getting AI to garrison buildings and then move around inside them. + + Parameter(s): + ARRAY - Units + + Returns: + NOTHING +*/ \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/garrison/fn_UnGarrisonL.sqf b/Vcom/Functions/VCM_Functions/garrison/fn_UnGarrisonL.sqf new file mode 100644 index 0000000..c50ba3c --- /dev/null +++ b/Vcom/Functions/VCM_Functions/garrison/fn_UnGarrisonL.sqf @@ -0,0 +1,27 @@ +/* + Author: Freddo + + Description: + Function for telling a group to leave a temporarily garrisoned structure + + Parameter(s): + 0: GROUP + + Returns: + NOTHING +*/ + +private _grp = _this; +private _situation = "READY"; + +if (count waypoints _grp > 1) then +{ + _situation = "FLANKING"; +}; +[_grp, _flanking] call VCM_fnc_SetSituation; + +{ + _x enableAI "PATH"; +} forEach units _grp; + +if VCM_DEBUG then {systemChat format ["VCOM: %1 UN-L-GARRISONING BUILDING", _grp]}; \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf b/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf new file mode 100644 index 0000000..086c948 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf @@ -0,0 +1,23 @@ +/* + Author: Freddo + + Description: + Returns current situation/task of the unit + + Parameter(s): + 0: GROUP - Group to check the situation of + + Returns: + STRING +*/ + +private _grp = _this; +private _rtrn = "BUSY"; + +private _fsm = _grp getVariable "VCM_SQUADFSM"; +if !(isNil "_fsm") then +{ + _rtrn = _fsm getFSMVariable "_situation"; +}; + +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf b/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf new file mode 100644 index 0000000..7ebcbc9 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf @@ -0,0 +1,21 @@ +/* + Author: Freddo + + Description: + Sets current situation/task of the unit + + Parameter(s): + 0: GROUP - Group to set the situation of + 1: STRING - Situation to set + + Returns: + STRING +*/ + +params ["_grp", "_newSituation"]; + +private _fsm = _grp getVariable "VCM_SQUADFSM"; +if !(isNull _fsm) then +{ + _fsm setFSMVariable ["_situation", _newSituation]; +}; \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index 8ceef63..d195a75 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -104,12 +104,6 @@ class VCOM // unit call VCM_fnc_FrmChnge; class FrmChnge {}; - // group spawn VCM_fnc_Garrison; - class Garrison {}; - - // group call VCM_fnc_GarrisonLight; - class GarrisonLight {}; - // unit call VCM_fnc_HasMine; class HasMine {}; @@ -175,8 +169,32 @@ class VCOM //[] call VCM_fnc_UpdateDrivers; class UpdateDrivers {}; - }; - + }; + + class Garrison + { + file = "Vcom\Functions\VCM_Functions\garrison"; + + // group call VCM_fnc_GarrisonLight; + class GarrisonLight {}; + + // group spawn VCM_fnc_Garrison; + class Garrison {}; + + // group call VCM_fnc_UnGarrisonL; + class UnGarrisonL {}; + }; + + class Situation_Framework + { + file = "Vcom\Functions\VCM_Functions\situation"; + + // group call CheckSituation; + class CheckSituation {}; + + // group call SetSituation; + class SetSituation {}; + }; }; From 1385e9744587bb78e19279e1585808b1e506b4c8 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 31 Jan 2019 18:09:46 +0100 Subject: [PATCH 03/30] Updated changelog --- Vcom/changelog.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Vcom/changelog.txt b/Vcom/changelog.txt index fc19e1a..656d4a3 100644 --- a/Vcom/changelog.txt +++ b/Vcom/changelog.txt @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [3.3] - 2019-01-31 +### Added +- VCOM Situation Framework + ## [3.2] - 2019-01-20 ### Added From 255fcf03dbd206b4cc62d3cc7fa4848fc0f06b29 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Sat, 9 Feb 2019 09:27:19 +0100 Subject: [PATCH 04/30] Changelog Forgot to mention FFE fix --- Vcom/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Vcom/changelog.txt b/Vcom/changelog.txt index 0381000..6a620b4 100644 --- a/Vcom/changelog.txt +++ b/Vcom/changelog.txt @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - CBA settings would get called despite CBA not being active +- Error in FFE caused by erroneous merge ### Security From 2e8f1dcb19e928e36d2ce43a529ff55911b9999a Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 14 Feb 2019 18:48:51 +0100 Subject: [PATCH 05/30] Categorised functions Functions library should now be neater to look at --- .../VCM_Functions/{ => actions}/fn_AIHIT.sqf | 0 .../{ => actions}/fn_ActRearm.sqf | 0 .../{ => actions}/fn_ArmStatics.sqf | 0 .../{ => actions}/fn_ClearBuilding.sqf | 0 .../{ => actions}/fn_ClstWarn.sqf | 0 .../{ => actions}/fn_HealSelf.sqf | 0 .../{ => actions}/fn_MedicHeal.sqf | 0 .../{ => actions}/fn_PackStatic.sqf | 0 .../{ => actions}/fn_RearmSelf.sqf | 0 .../{ => artillery}/fn_ArtyCall.sqf | 0 .../{ => artillery}/fn_ArtyManage.sqf | 0 .../{ => artillery}/fn_CheckArty.sqf | 0 .../{ => driving}/fn_MovePrediction.sqf | 0 .../{ => driving}/fn_UpdateDrivers.sqf | 0 .../{ => driving}/fn_VehicleDetection.sqf | 0 .../{ => explosives}/fn_HasMine.sqf | 0 .../{ => explosives}/fn_MineMonitor.sqf | 0 .../{ => explosives}/fn_MinePlant.sqf | 0 .../{ => explosives}/fn_SatchelPlant.sqf | 0 .../{ => movement}/fn_FindCover.sqf | 0 .../{ => movement}/fn_FlankMove.sqf | 0 .../{ => movement}/fn_ForceMove.sqf | 0 .../{ => movement}/fn_FrmChnge.sqf | 0 .../{ => scanning}/fn_BoxNrst.sqf | 0 .../{ => scanning}/fn_ClstEmy.sqf | 0 .../{ => scanning}/fn_ClstObj.sqf | 0 .../{ => scanning}/fn_EmptyStatic.sqf | 0 .../{ => scanning}/fn_EnemyArray.sqf | 0 .../{ => scanning}/fn_Heights.sqf | 0 .../{ => scanning}/fn_IRCHECK.sqf | 0 .../{ => scanning}/fn_KnowAbout.sqf | 0 Vcom/cfgFunctions.hpp | 215 +++++++++++------- 32 files changed, 130 insertions(+), 85 deletions(-) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_AIHIT.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_ActRearm.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_ArmStatics.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_ClearBuilding.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_ClstWarn.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_HealSelf.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_MedicHeal.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_PackStatic.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => actions}/fn_RearmSelf.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => artillery}/fn_ArtyCall.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => artillery}/fn_ArtyManage.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => artillery}/fn_CheckArty.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => driving}/fn_MovePrediction.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => driving}/fn_UpdateDrivers.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => driving}/fn_VehicleDetection.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => explosives}/fn_HasMine.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => explosives}/fn_MineMonitor.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => explosives}/fn_MinePlant.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => explosives}/fn_SatchelPlant.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => movement}/fn_FindCover.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => movement}/fn_FlankMove.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => movement}/fn_ForceMove.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => movement}/fn_FrmChnge.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_BoxNrst.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_ClstEmy.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_ClstObj.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_EmptyStatic.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_EnemyArray.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_Heights.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_IRCHECK.sqf (100%) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_KnowAbout.sqf (100%) diff --git a/Vcom/Functions/VCM_Functions/fn_AIHIT.sqf b/Vcom/Functions/VCM_Functions/actions/fn_AIHIT.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_AIHIT.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_AIHIT.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ActRearm.sqf b/Vcom/Functions/VCM_Functions/actions/fn_ActRearm.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ActRearm.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_ActRearm.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ArmStatics.sqf b/Vcom/Functions/VCM_Functions/actions/fn_ArmStatics.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ArmStatics.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_ArmStatics.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ClearBuilding.sqf b/Vcom/Functions/VCM_Functions/actions/fn_ClearBuilding.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ClearBuilding.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_ClearBuilding.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ClstWarn.sqf b/Vcom/Functions/VCM_Functions/actions/fn_ClstWarn.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ClstWarn.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_ClstWarn.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_HealSelf.sqf b/Vcom/Functions/VCM_Functions/actions/fn_HealSelf.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_HealSelf.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_HealSelf.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_MedicHeal.sqf b/Vcom/Functions/VCM_Functions/actions/fn_MedicHeal.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_MedicHeal.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_MedicHeal.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_PackStatic.sqf b/Vcom/Functions/VCM_Functions/actions/fn_PackStatic.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_PackStatic.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_PackStatic.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_RearmSelf.sqf b/Vcom/Functions/VCM_Functions/actions/fn_RearmSelf.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_RearmSelf.sqf rename to Vcom/Functions/VCM_Functions/actions/fn_RearmSelf.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ArtyCall.sqf b/Vcom/Functions/VCM_Functions/artillery/fn_ArtyCall.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ArtyCall.sqf rename to Vcom/Functions/VCM_Functions/artillery/fn_ArtyCall.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ArtyManage.sqf b/Vcom/Functions/VCM_Functions/artillery/fn_ArtyManage.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ArtyManage.sqf rename to Vcom/Functions/VCM_Functions/artillery/fn_ArtyManage.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_CheckArty.sqf b/Vcom/Functions/VCM_Functions/artillery/fn_CheckArty.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_CheckArty.sqf rename to Vcom/Functions/VCM_Functions/artillery/fn_CheckArty.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_MovePrediction.sqf b/Vcom/Functions/VCM_Functions/driving/fn_MovePrediction.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_MovePrediction.sqf rename to Vcom/Functions/VCM_Functions/driving/fn_MovePrediction.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_UpdateDrivers.sqf b/Vcom/Functions/VCM_Functions/driving/fn_UpdateDrivers.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_UpdateDrivers.sqf rename to Vcom/Functions/VCM_Functions/driving/fn_UpdateDrivers.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_VehicleDetection.sqf b/Vcom/Functions/VCM_Functions/driving/fn_VehicleDetection.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_VehicleDetection.sqf rename to Vcom/Functions/VCM_Functions/driving/fn_VehicleDetection.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_HasMine.sqf b/Vcom/Functions/VCM_Functions/explosives/fn_HasMine.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_HasMine.sqf rename to Vcom/Functions/VCM_Functions/explosives/fn_HasMine.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_MineMonitor.sqf b/Vcom/Functions/VCM_Functions/explosives/fn_MineMonitor.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_MineMonitor.sqf rename to Vcom/Functions/VCM_Functions/explosives/fn_MineMonitor.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_MinePlant.sqf b/Vcom/Functions/VCM_Functions/explosives/fn_MinePlant.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_MinePlant.sqf rename to Vcom/Functions/VCM_Functions/explosives/fn_MinePlant.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_SatchelPlant.sqf b/Vcom/Functions/VCM_Functions/explosives/fn_SatchelPlant.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_SatchelPlant.sqf rename to Vcom/Functions/VCM_Functions/explosives/fn_SatchelPlant.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_FindCover.sqf b/Vcom/Functions/VCM_Functions/movement/fn_FindCover.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_FindCover.sqf rename to Vcom/Functions/VCM_Functions/movement/fn_FindCover.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_FlankMove.sqf b/Vcom/Functions/VCM_Functions/movement/fn_FlankMove.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_FlankMove.sqf rename to Vcom/Functions/VCM_Functions/movement/fn_FlankMove.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ForceMove.sqf b/Vcom/Functions/VCM_Functions/movement/fn_ForceMove.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ForceMove.sqf rename to Vcom/Functions/VCM_Functions/movement/fn_ForceMove.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_FrmChnge.sqf b/Vcom/Functions/VCM_Functions/movement/fn_FrmChnge.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_FrmChnge.sqf rename to Vcom/Functions/VCM_Functions/movement/fn_FrmChnge.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_BoxNrst.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_BoxNrst.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_BoxNrst.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_BoxNrst.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ClstEmy.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_ClstEmy.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ClstEmy.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_ClstEmy.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_ClstObj.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_ClstObj.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_EmptyStatic.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_EmptyStatic.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_EmptyStatic.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_EmptyStatic.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_EnemyArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_EnemyArray.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_Heights.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_Heights.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_Heights.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_Heights.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_IRCHECK.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_IRCHECK.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_IRCHECK.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_IRCHECK.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_KnowAbout.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_KnowAbout.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_KnowAbout.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_KnowAbout.sqf diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index d195a75..97b037f 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -2,6 +2,7 @@ class VCOM { tag = "VCM"; + // Initialization functions. These should only run once on startup. class Init { class VcomInit @@ -14,7 +15,7 @@ class VCOM file = "Vcom\VcomInitClient.sqf"; postInit = 1; }; - class CBA_Settings + class CBA_Settings // Only executed if CBA is present { file = "Vcom\Functions\VCM_CBASettings.sqf"; }; @@ -43,124 +44,95 @@ class VCOM }; }; + // Generic functions class Functions { file = "Vcom\Functions\VCM_Functions"; - // [unitToRearm, rearmLocation] spawn VCM_fnc_ActRearm - class ActRearm {}; - - // [unit, source, damage, instigator] call VCM_fnc_AIHIT; - class AIHIT {}; - - // [group] call VCM_fnc_ArmStatics; - class ArmStatics {}; - - // [callGroup, enemyGroup] call VCM_fnc_ArtyCall; - class ArtyCall {}; - - // group call VCM_fnc_ArtyManage; - class ArtyManage {}; - - // [entity, unit] call VCM_fnc_BoxNrst; - class BoxNrst {}; - - // unit call VCM_fnc_CheckArty; - class CheckArty {}; - // [string] call VCM_fnc_Classname; class Classname {}; - // [group, enemy] call VCM_fnc_ClearBuilding; - class ClearBuilding {}; - - // unit call VCM_fnc_ClstEmy; - class ClstEmy {}; + // unit call VCM_fnc_FriendlyArray; + class FriendlyArray {}; - // [list, object, order, script] call VCM_fnc_ClstObj; - class ClstObj {}; + // [unit, weapon, muzzle, mode, ammo, magazine, bullet, gunner] call VCM_fnc_HearingAids; + class HearingAids {}; - // [unit, killer] call VCM_fnc_ClstWarn; - class ClstWarn {}; + // group call VCM_fnc_KitChk; + class KitChk {}; - // [group, searchDistance] call VCM_fnc_EmptyStatic; - class EmptyStatic {}; + // group call VCM_fnc_MedicalHandler + class MedicalHandler {}; - // unit call VCM_fnc_EnemyArray; - class EnemyArray {}; + // group call VCM_fnc_RMedics; + class RMedics {}; - // [groupLeader, moveDistance] call VCM_fnc_FindCover; - class FindCover {}; + // group call VCM_fnc_RStatics; + class RStatics {}; - // [groupLeader] spawn VCM_fnc_FlankMove; - class FlankMove {}; + // group call VCM_fnc_SquadExc; + class SquadExc {}; - // [groupLeader, moveDistance] call VCM_fnc_ForceMove; - class ForceMove {}; + // group call VCM_fnc_WyptChk; + class WyptChk {}; - // unit call VCM_fnc_FriendlyArray; - class FriendlyArray {}; + // unit call VCM_fnc_IsDriver; + class IsDriver {}; + }; + + // Artillery related functions. Deprecated + class Artillery + { + file = "Vcom\Functions\VCM_Functions\artillery"; - // unit call VCM_fnc_FrmChnge; - class FrmChnge {}; + // unit call VCM_fnc_CheckArty; + class CheckArty {}; - // unit call VCM_fnc_HasMine; - class HasMine {}; + // [callGroup, enemyGroup] call VCM_fnc_ArtyCall; + class ArtyCall {}; - // unit call VCM_fnc_HealSelf; - class HealSelf {}; + // group call VCM_fnc_ArtyManage; + class ArtyManage {}; + }; + + // Acttions that can be undertaken by groups/units + class Actions + { + file = "Vcom\Functions\VCM_Functions\actions"; - // [unit, weapon, muzzle, mode, ammo, magazine, bullet, gunner] call VCM_fnc_HearingAids; - class HearingAids {}; + // [unitToRearm, rearmLocation] spawn VCM_fnc_ActRearm + class ActRearm {}; - // [object, searchRadius, precision, sortingOrder] call VCM_fnc_Heights; - class Heights {}; + // [unit, source, damage, instigator] call VCM_fnc_AIHIT; + class AIHIT {}; - // [] call VCM_fnc_IRCHECK; - class IRCHECK {}; + // [group] call VCM_fnc_ArmStatics; + class ArmStatics {}; - // group call VCM_fnc_KitChk; - class KitChk {}; + // [group, enemy] call VCM_fnc_ClearBuilding; + class ClearBuilding {}; - // [array, unitToReveal, revealAmount, _revealLimit] call VCM_fnc_KnowAbout; - class KnowAbout {}; + // [unit, killer] call VCM_fnc_ClstWarn; + class ClstWarn {}; - // group call VCM_fnc_MedicalHandler - class MedicalHandler {}; + // unit call VCM_fnc_HealSelf; + class HealSelf {}; //[medic, injuredUnit] spawn VCM_fnc_MedicHeal; class MedicHeal {}; - // [] spawn VCM_fnc_MineMonitor; - class MineMonitor {}; - - // [unit, mineArray] spawn VCM_fnc_MinePlant; - class MinePlant {}; - // [gunner, backpackClassname, staticWeapon] call VCM_fnc_PackStatic; class PackStatic {}; // group call VCM_fnc_RearmSelf; class RearmSelf {}; + }; + + // Driving related functions + class Driving + { + file = "Vcom\Functions\VCM_Functions\driving"; - // group call VCM_fnc_RMedics; - class RMedics {}; - - // group call VCM_fnc_RStatics; - class RStatics {}; - - // [unit, satchelArray] spawn VCM_fnc_SatchelPlant; - class SatchelPlant {}; - - // group call VCM_fnc_SquadExc; - class SquadExc {}; - - // group call VCM_fnc_WyptChk; - class WyptChk {}; - - // unit call VCM_fnc_IsDriver; - class IsDriver {}; - //unit call VCM_fnc_VehicleDetection; class VehicleDetection {}; @@ -171,6 +143,25 @@ class VCOM class UpdateDrivers {}; }; + // Explosives related functions + class Explosives + { + file = "Vcom\Functions\VCM_Functions\explosives"; + + // unit call VCM_fnc_HasMine; + class HasMine {}; + + // [] spawn VCM_fnc_MineMonitor; + class MineMonitor {}; + + // [unit, mineArray] spawn VCM_fnc_MinePlant; + class MinePlant {}; + + // [unit, satchelArray] spawn VCM_fnc_SatchelPlant; + class SatchelPlant {}; + }; + + // Garrison related functions class Garrison { file = "Vcom\Functions\VCM_Functions\garrison"; @@ -185,6 +176,24 @@ class VCOM class UnGarrisonL {}; }; + class Movement + { + file = "Vcom\Functions\VCM_Functions\movement"; + + // [groupLeader, moveDistance] call VCM_fnc_ForceMove; + class ForceMove {}; + + // [groupLeader, moveDistance] call VCM_fnc_FindCover; + class FindCover {}; + + // unit call VCM_fnc_FrmChnge; + class FrmChnge {}; + + // [groupLeader] spawn VCM_fnc_FlankMove; + class FlankMove {}; + }; + + // Commands related to the task/situation that the AI is currently in class Situation_Framework { file = "Vcom\Functions\VCM_Functions\situation"; @@ -195,6 +204,42 @@ class VCOM // group call SetSituation; class SetSituation {}; }; + + // These functions are generally used to scan for nearby objects, units, groups, etc + class Scanning + { + file = "Vcom\Functions\VCM_Functions\scanning"; + + // [entity, unit] call VCM_fnc_BoxNrst; + class BoxNrst {}; + + // [array, unitToReveal, revealAmount, _revealLimit] call VCM_fnc_KnowAbout; + class KnowAbout {}; + + // unit call VCM_fnc_ClstEmy; + class ClstEmy {}; + + // unit call VCM_fnc_EnemyArray; + class EnemyArray {}; + + // [] call VCM_fnc_IRCHECK; + class IRCHECK {}; + + // [list, object, order, script] call VCM_fnc_ClstObj; + class ClstObj {}; + + // [object, searchRadius, precision, sortingOrder] call VCM_fnc_Heights; + class Heights {}; + + // [group, searchDistance] call VCM_fnc_EmptyStatic; + class EmptyStatic {}; + }; + + // Suppression related functions + class Suppression + { + file = "Vcom\Functions\VCM_Functions\suppression"; + }; }; From 34f8dc620ee57ab5ff7b2634a7b5cb3d8d14010e Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 14 Feb 2019 20:59:37 +0100 Subject: [PATCH 06/30] Changed fn_EnemyArray VCM_fnc_EnemyArray now has additional parameters, namely: - Range, only find units within defined range - Sort, Sorts the array depending on range, from closest to furthest --- .../VCM_Functions/scanning/fn_EnemyArray.sqf | 77 ++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf index 11bcec3..6c56395 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf @@ -1,23 +1,82 @@ /* - Author: Genesis + Author: Freddo Description: Return array containing all enemies of unit. Parameter(s): - 0: OBJECT - Units enemy to this unit will be added to return array. + OBJECT - Units enemy to this unit will be added to return array + + OR + + 0: OBJECT - Units enemy to this unit will be added to return array + 1: NUMBER - Range of search + 2: BOOLEAN - OPTIONAL Whether to sort the array by range, closest to furthest Returns: ARRAY */ +private _array = []; -private _unitSide = side (group _this); -private _targetSide = ""; -private _array1 = []; +if (_this isEqualType []) then { - _targetSide = side _x; - if ([_unitSide, _targetSide] call BIS_fnc_sideIsEnemy) then {_array1 pushback _x;}; + params ["_unit", "_range", "_toSort"]; + + if (isNil "_toSort") then {_toSort = false}; + + if (_toSort isEqualTo false) then + { + // Return unsorted array of all enemies within defined range + private _unitSide = side (group _unit); + { + + if ([_unitSide, (side _x)] call BIS_fnc_sideIsEnemy && {(_unit distance2D _x) < _range}) then + { + _array pushback _x; + }; + + } forEach allUnits; + + } + else + { + // TODO: Optimise + + // Return sorted array of all enemies within defined range + private _unitSide = side (group _unit); + private _range2d = 0; + private _unsortArr = []; + // Find eligible units + { + + if ([_unitSide, (side _x)] call BIS_fnc_sideIsEnemy) then + { + _range2d = (_unit distance2D _x); + if (_range2d < _range) then + { + // In order to be able to be sorted, it is stored in a two dimensional array + _unsortArr pushback [_range2d, _x]; + }; + }; + } forEach allUnits; + // Sort the thing + _sortArr = ([_unsortArr, [], {_x select 0}] call BIS_fnc_sortBy); + {_array pushBack (_x select 1)} forEach _sortArr; + }; +} +else +{ + // Just return all enemies in the mission + private _unitSide = side (group _this); + { + + if ([_unitSide, (side _x)] call BIS_fnc_sideIsEnemy) then + { + _array pushback _x; + }; + + } forEach allUnits; +}; -} forEach allUnits; -_array1 \ No newline at end of file +_array \ No newline at end of file From 3e46e7741e54a13bc38ea35193e69689a8a33111 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 14 Feb 2019 21:01:19 +0100 Subject: [PATCH 07/30] Added Function: fn_KnownEnemyArray This function takes fn_EnemyArray and adds an additional filter to it, namely it only adds returns units that the unit in question knows about. --- .../scanning/fn_KnownEnemyArray.sqf | 49 +++++++++++++++++++ Vcom/cfgFunctions.hpp | 3 ++ 2 files changed, 52 insertions(+) create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf new file mode 100644 index 0000000..c7f35f7 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf @@ -0,0 +1,49 @@ +/* + Author: Genesis + + Description: + Return array of known enemies. + + Parameter(s): + OBJECT - Units enemy to this unit will be added to return array. + + OR + + 0: OBJECT - Units enemy to this unit will be added to return array. + 1: NUMBER - Range of search + 2: BOOLEAN - OPTIONAL, Whether to sort by range (sorted in ascending order) + + Returns: + ARRAY +*/ + +private _rtrnArr = []; + +if (_this isEqualType []) then +{ + + params ["_unit", "_range", "_toSort"]; + + { + if ((_unit knowsAbout _x) >= 1.5) then + { + _rtrnArr pushBack _x; + }; + } + forEach (_this call VCM_fnc_EnemyArray); + +} +else +{ + + { + if ((_this knowsAbout _x) >= 1.5) then + { + _rtrnArr pushBack _x; + }; + } + forEach (_this call VCM_fnc_EnemyArray); + +}; + +_rtrnArr \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index 97b037f..6845c01 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -222,6 +222,9 @@ class VCOM // unit call VCM_fnc_EnemyArray; class EnemyArray {}; + // unit call VCM_fnc_KnownEnemyArray + class KnownEnemyArray {}; + // [] call VCM_fnc_IRCHECK; class IRCHECK {}; From cc1effe486e07455daec3986c5ce5c678975b862 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 14 Feb 2019 21:27:46 +0100 Subject: [PATCH 08/30] Tweaked headers --- Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf | 2 +- Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf index 6c56395..177697b 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyArray.sqf @@ -1,6 +1,6 @@ /* - Author: Freddo + Author: Genesis, overhauled by Freddo Description: Return array containing all enemies of unit. diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf index c7f35f7..5d49390 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyArray.sqf @@ -1,5 +1,5 @@ /* - Author: Genesis + Author: Freddo Description: Return array of known enemies. From 0034114cff05158594eac2342d4779521e077f66 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Thu, 14 Feb 2019 21:37:37 +0100 Subject: [PATCH 09/30] New Functions: EnemyGroupArray --- .../scanning/fn_EnemyGroupArray.sqf | 29 +++++++++++++++++++ .../scanning/fn_KnownEnemyGroupArray.sqf | 29 +++++++++++++++++++ Vcom/cfgFunctions.hpp | 6 ++++ 3 files changed, 64 insertions(+) create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_EnemyGroupArray.sqf create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_EnemyGroupArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyGroupArray.sqf new file mode 100644 index 0000000..80cc311 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_EnemyGroupArray.sqf @@ -0,0 +1,29 @@ +/* + Author: Freddo + + Description: + Return array of enemy groups. + + Parameter(s): + OBJECT - Groups enemy to this unit will be added to return array. + + OR + + 0: OBJECT - Groups enemy to this unit will be added to return array. + 1: NUMBER - Range of search + 2: BOOLEAN - OPTIONAL, Whether to sort by range (sorted in ascending order) + + Returns: + ARRAY + + Note: + This function only checks if any unit from the group is in range, not entire group or leader. +*/ + +private _arr = _this call VCM_fnc_EnemyArray; +private _rtrn = []; +{ + _arr pushBackUnique (group _x); +} forEach _arr; + +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf new file mode 100644 index 0000000..c0cfdc2 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf @@ -0,0 +1,29 @@ +/* + Author: Freddo + + Description: + Return array of known enemy groups. + + Parameter(s): + OBJECT - Groups enemy to this unit will be added to return array. + + OR + + 0: OBJECT - Groups enemy to this unit will be added to return array. + 1: NUMBER - Range of search + 2: BOOLEAN - OPTIONAL, Whether to sort by range (sorted in ascending order) + + Returns: + ARRAY + + Note: + This function only checks if any known unit from the group is in range, not entire group or leader. +*/ + +private _arr = _this call VCM_fnc_KnownEnemyArray; +private _rtrn = []; +{ + _arr pushBackUnique (group _x); +} forEach _arr; + +_rtrn \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index 6845c01..dd46d1c 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -225,6 +225,12 @@ class VCOM // unit call VCM_fnc_KnownEnemyArray class KnownEnemyArray {}; + // unit call VCM_fnc_EnemyGroupArray + class EnemyGroupArray {}; + + // unit call VCM_fnc_KnownEnemyGroupArray + class KnownEnemyGroupArray {}; + // [] call VCM_fnc_IRCHECK; class IRCHECK {}; From ddbfdb13a6c8143396e8600057f6f81b46df29dc Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Sun, 17 Feb 2019 21:57:51 +0100 Subject: [PATCH 10/30] fn_FriendlyGroupArray Used to find nearby groups. Moved fn_FriendlyArray --- .../{ => scanning}/fn_FriendlyArray.sqf | 0 .../scanning/fn_FriendlyGroupArray.sqf | 48 +++++++++++++++++++ Vcom/cfgFunctions.hpp | 9 ++-- 3 files changed, 54 insertions(+), 3 deletions(-) rename Vcom/Functions/VCM_Functions/{ => scanning}/fn_FriendlyArray.sqf (100%) create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf diff --git a/Vcom/Functions/VCM_Functions/fn_FriendlyArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyArray.sqf similarity index 100% rename from Vcom/Functions/VCM_Functions/fn_FriendlyArray.sqf rename to Vcom/Functions/VCM_Functions/scanning/fn_FriendlyArray.sqf diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf new file mode 100644 index 0000000..e5172ee --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf @@ -0,0 +1,48 @@ +/* + Author: Freddo + + Description: + Return array of all friendly groups. + + Parameter(s): + 0: OBJECT - Groups friendly to this unit will be added to return array. + 1: BOOLEAN - OPTIONAL, Whether to sort by range (sorted in ascending order) + + Returns: + ARRAY + + Note: + This function sorts by range to group leader. +*/ + +params ["_unit", "_toSort"]; + +if (isNil "_toSort") then {_toSort = false}; + +private _friendlyArray = []; +private _side = side _unit; +private _group = group _unit; + +if _toSort then +{ + private _unsortArray = []; + { + if ([side _x, _side] call BIS_fnc_sideIsFriendly && !(_x isEqualTo _group)) then + { + _unsortArray pushBack _x; + }; + } foreach allGroups; + + _friendlyArray = [_unsortArray, [], {(leader _x) distance2D _unit}] call BIS_fnc_sortBy; +} +else +{ + { + if ([side _x, _side] call BIS_fnc_sideIsFriendly && !(_x isEqualTo _group)) then + { + _friendlyArray pushBack _x; + }; + } foreach allGroups; +}; + +_friendlyArray \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index dd46d1c..7dd5021 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -52,9 +52,6 @@ class VCOM // [string] call VCM_fnc_Classname; class Classname {}; - // unit call VCM_fnc_FriendlyArray; - class FriendlyArray {}; - // [unit, weapon, muzzle, mode, ammo, magazine, bullet, gunner] call VCM_fnc_HearingAids; class HearingAids {}; @@ -231,6 +228,12 @@ class VCOM // unit call VCM_fnc_KnownEnemyGroupArray class KnownEnemyGroupArray {}; + // unit call VCM_fnc_FriendlyArray; + class FriendlyArray {}; + + // [unit, boolean] call VCM_fnc_FriendlyGroupArray + class FriendlyGroupArray {}; + // [] call VCM_fnc_IRCHECK; class IRCHECK {}; From c432b859486068c149c33878af894850277eb645 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Sun, 17 Feb 2019 22:15:30 +0100 Subject: [PATCH 11/30] fn_HasRadio & fn_GroupHasRadio Generic functions to check if units has radio capability. May be further expanded in the future. --- .../scanning/fn_GroupHasRadio.sqf | 23 +++++++++++++++++++ .../VCM_Functions/scanning/fn_HasRadio.sqf | 21 +++++++++++++++++ Vcom/cfgFunctions.hpp | 6 +++++ 3 files changed, 50 insertions(+) create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf new file mode 100644 index 0000000..c71dab7 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf @@ -0,0 +1,23 @@ +/* + Author: Genesis + + Description: + Checks if group has a radio + + Parameter(s): + GROUP - Group to check for radios + + Returns: + BOOLEAN +*/ + +private _group = group _this; +private _units = units _this; +private _rtrn = false; + +if !((_units findIf {_x call VCM_fnc_HasRadio}) isEqualTo -1) then +{ + _rtrn = true; +}; + +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf new file mode 100644 index 0000000..6864d9a --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf @@ -0,0 +1,21 @@ +/* + Author: Freddo + + Description: + Returns an array containing all of units friendlies. + + Parameter(s): + OBJECT - Object to check if it has a radio assigned to it. + + Returns: + BOOLEAN + + Note: + Need to add TFAR and ACRE vehicle rack compatibility +*/ + +private _unit = _this; + +_rtrn = ("itemRadio" in (assignedItems _unit)); + +_rtrn \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index 7dd5021..fc35bff 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -240,6 +240,12 @@ class VCOM // [list, object, order, script] call VCM_fnc_ClstObj; class ClstObj {}; + // unit call VCM_fnc_HasRadio; + class HasRadio {}; + + // group call VCM_fnc_GroupHasRadio + class GroupHasRadio {}; + // [object, searchRadius, precision, sortingOrder] call VCM_fnc_Heights; class Heights {}; From 5744233fcf073463f48f8f72f93886d46c277526 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Feb 2019 12:16:26 +0100 Subject: [PATCH 12/30] fn_FriendlyGroupArray additional parameter Can define search range. --- .../VCM_Functions/scanning/fn_FriendlyGroupArray.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf index e5172ee..5d88b9b 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf @@ -7,6 +7,7 @@ Parameter(s): 0: OBJECT - Groups friendly to this unit will be added to return array. 1: BOOLEAN - OPTIONAL, Whether to sort by range (sorted in ascending order) + 2: NUMBER - OPTIONAL, Search range Returns: ARRAY @@ -15,9 +16,10 @@ This function sorts by range to group leader. */ -params ["_unit", "_toSort"]; +params ["_unit", "_toSort", "_range"]; if (isNil "_toSort") then {_toSort = false}; +if (isNil "_range") then {_range = -1}; private _friendlyArray = []; private _side = side _unit; @@ -38,7 +40,7 @@ if _toSort then else { { - if ([side _x, _side] call BIS_fnc_sideIsFriendly && !(_x isEqualTo _group)) then + if ([side _x, _side] call BIS_fnc_sideIsFriendly && {!(_x isEqualTo _group)} && {0 <= _range && {_x distance2D _unit < _range}}) then { _friendlyArray pushBack _x; }; From 9f76b6f496250b701180c58a4313532cebd7099d Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Feb 2019 16:57:30 +0100 Subject: [PATCH 13/30] Revamped Reinforcement system --- Vcom/FSMS/fn_SQUADBEH.fsm | 39 ++++------- .../actions/fn_RqstReinforce.sqf | 69 +++++++++++++++++++ .../Functions/VCM_Functions/fn_GroupValue.sqf | 63 +++++++++++++++++ .../scanning/fn_CanReinforce.sqf | 43 ++++++++++++ .../scanning/fn_FriendlyGroupArray.sqf | 2 +- .../scanning/fn_GroupHasRadio.sqf | 6 +- .../VCM_Functions/scanning/fn_HasRadio.sqf | 2 +- .../scanning/fn_KnownEnemyGroupArray.sqf | 2 +- Vcom/cfgFunctions.hpp | 15 +++- 9 files changed, 208 insertions(+), 33 deletions(-) create mode 100644 Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf create mode 100644 Vcom/Functions/VCM_Functions/fn_GroupValue.sqf create mode 100644 Vcom/Functions/VCM_Functions/scanning/fn_CanReinforce.sqf diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index a42b28e..8899b7e 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -33,7 +33,7 @@ item28[] = {"Flank_Orders",4,218,1050.000000,225.000000,1150.000000,275.000000,1 item29[] = {"",7,210,296.000000,21.000000,304.000000,29.000000,0.000000,""}; item30[] = {"Light_Garrison",4,218,1000.000000,200.000000,1100.000000,250.000000,88.000000,"Light Garrison"}; item31[] = {"Five_Minute_Chec",4,218,-300.000000,300.000000,-200.000000,350.000000,950.000000,"Five Minute Checks"}; -item32[] = {"Five_Minute_Chec",2,250,-300.000000,150.000000,-200.000000,200.000000,0.000000,"Five Minute Checks"}; +item32[] = {"Reinforcement_Ch",2,4346,-300.000000,150.000000,-200.000000,200.000000,0.000000,"Reinforcement" \n "Check"}; item33[] = {"CheckIfStatic",4,218,949.004028,175.000031,1050.000122,225.996094,92.000000,"CheckIfStatic"}; item34[] = {"TwoMinuteChecks",4,218,-400.000000,300.000000,-300.000000,350.000000,940.000000,"TwoMinuteChecks"}; item35[] = {"Two_Minute_Check",2,250,-400.000000,150.000000,-300.000000,200.000000,0.000000,"Two Minute Checks"}; @@ -44,7 +44,7 @@ item39[] = {"True",8,218,750.000000,75.000000,850.000000,125.000000,0.000000,"Tr item40[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; item41[] = {"Exit_FSM_2",1,250,700.000000,600.000000,775.000000,650.000000,0.000000,"Exit FSM"}; item42[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; -item43[] = {"Clear_Building",4,4314,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; +item43[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; item44[] = {"Combat_END",4,218,684.709351,384.913361,784.709351,434.913361,90.000000,"Combat END"}; link0[] = {0,1}; link1[] = {0,3}; @@ -113,8 +113,8 @@ link63[] = {40,41}; link64[] = {42,27}; link65[] = {43,27}; link66[] = {44,27}; -globals[] = {0.000000,0,0,0,0,640,480,2,623,6316128,1,378.398834,1562.328491,774.864380,-69.844208,1239,884,1}; -window[] = {2,-1,-1,-1,-1,1006,52,797,52,3,1257}; +globals[] = {0.000000,0,0,0,0,640,480,2,623,6316128,1,-341.180847,1163.171631,1047.220947,-26.102501,1254,884,1}; +window[] = {2,-1,-1,-1,-1,1009,91,836,55,3,1272}; *//*%FSM*/ class FSM { @@ -158,7 +158,7 @@ class FSM condition=/*%FSM*/""/*%FSM*/; action=/*%FSM*/"private _BackbkC = -60;" \n "private _BackbkC2 = -60;" \n - "private _BackbkC3 = -300;" \n + "private _BackbkC3 = -300 + VCM_WARNDELAY;" \n "private _BackbkC4 = -120;" \n "private _BackbkC5 = -120;" \n "private _BackbkC6 = -120;" \n @@ -289,7 +289,7 @@ class FSM { itemno = 31; priority = 950.000000; - to="Five_Minute_Chec"; + to="Reinforcement_Ch"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_BackbkC3 + 300) < time"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; @@ -501,18 +501,7 @@ class FSM "{" \n " _situation = ""READY"";" \n "};" \n - "" \n - "" \n - "//See if we can take any vehicles." \n - "if (VCM_StealVeh) then" \n - "{" \n - "{" \n - " if (_x iskindof ""LandVehicle"" && {crew _x isEqualTo []} && {_x distance _Leader < VCM_AIDISTANCEVEHPATH} && {locked _x != 2}) then" \n - " {" \n - " _Group addvehicle _x;" \n - " };" \n - "} foreach vehicles;" \n - "};"/*%FSM*/; + ""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links { @@ -538,7 +527,8 @@ class FSM action=/*%FSM*/"//[_Leader,50] call VCM_fnc_FindCover;" \n "_Cover2Cover = time;" \n "_Beh = ""COMBAT"";" \n - "if (VCM_FullSpeed) then {_Group setSpeedMode ""FULL"";};"/*%FSM*/; + "if (VCM_FullSpeed) then {_Group setSpeedMode ""FULL"";};" \n + "_BackbkC3 = (time + 300 - VCM_WARNDELAY);"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ @@ -669,7 +659,7 @@ class FSM to="Return"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_WaypointGen + 900 < time && " \n - "{_situation isEqualTo ""READY""} &&" \n + "{_situation isEqualTo ""READY"" || _situation isEqualTo ""REINFORCE""} &&" \n "{VCM_ADVANCEDMOVEMENT} &&" \n "{" \n " isNil {(waypoints _Group) select 1} ||" \n @@ -938,12 +928,13 @@ class FSM }; }; /*%FSM*/ - /*%FSM*/ - class Five_Minute_Chec + /*%FSM*/ + class Reinforcement_Ch { - name = "Five_Minute_Chec"; + name = "Reinforcement_Ch"; itemno = 32; - init = /*%FSM*/"_BackbkC3 = time;"/*%FSM*/; + init = /*%FSM*/"if !(_Group getVariable [""VCM_TOUGHSQUAD"", false]) then {_Group call VCM_fnc_RqstReinforce};" \n + "_BackbkC3 = time;"/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links { diff --git a/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf b/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf new file mode 100644 index 0000000..b8889ff --- /dev/null +++ b/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf @@ -0,0 +1,69 @@ +/* + Author: Freddo + + Description: + Makes unit request support. + + Parameter(s): + GROUP - Group that is requesting support. + + Returns: + BOOLEAN +*/ + +private _group = _this; +private _leader = leader _group; +private _rtrn = false; + +if (!(_group call VCM_fnc_GroupHasRadio) || _group getVariable ["VCM_TOUGHSQUAD", false]) exitWith {_rtrn}; + +// Calculate enemy forces value +private _knownEnemyG = ([_leader, 500, false] call VCM_fnc_KnownEnemyGroupArray); +private _enemyValue = 0; +{ + _enemyValue = _enemyValue + (_x call VCM_fnc_GroupValue); +}forEach _knownEnemyG; + +// Add a bit of +- inaccuracy +_enemyValue = (_enemyValue * (0.75 + random 0.5)); + +// Calculate friendly forces value in vincinity +private _knownFriendlyG = ([_leader, false, 500] call VCM_fnc_FriendlyGroupArray); +private _friendlyValue = 0; +{ + _friendlyValue = _friendlyValue + (_x call VCM_fnc_GroupValue); +}forEach _knownFriendlyG; + +// Friendly forces are superior to enemies +if ((_friendlyValue * 1.25) > _enemyValue) exitWith {_rtrn}; + +if VCM_DEBUG then {systemChat format ["VCOM: %1 calling for support", _group]}; + +// Find eligible groups +private _targetValue = (_enemyValue - (_friendlyValue * 1.25)); +private _eligibleSquads = []; +private _eligibleSquadsValue = 0; +{ + if (_eligibleSquadsValue > _targetValue) exitWith {}; + if (_x call VCM_fnc_CanReinforce) then + { + _eligibleSquadsValue = (_eligibleSquadsValue + (_x call VCM_fnc_GroupValue)); + _eligibleSquads pushBack _x; + }; +} forEach ([_leader, true, VCM_WARNDIST] call VCM_fnc_FriendlyGroupArray); + +if (count _eligibleSquads == 0) exitWith {_rtrn}; + +//Create waypoints +{ + if !(_x call VCM_fnc_CheckSituation isEqualTo "REINFORCE") then { + private _leader == leader _x; + if VCM_DEBUG then {systemChat format ["VCOM: %1 moving to reinforce %2", _x, _group]}; + private _wp = (_x addWaypoint [position _leader, 100]); + _wp setWaypointSpeed "FULL"; + if (behaviour _leader isEqualTo "SAFE") then {_x setBehaviour "AWARE"}; + [_x, "REINFORCE"] call VCM_fnc_SetSituation; + }; +}forEach _eligibleSquads; +_rtrn = true; +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/fn_GroupValue.sqf b/Vcom/Functions/VCM_Functions/fn_GroupValue.sqf new file mode 100644 index 0000000..7b8acb0 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/fn_GroupValue.sqf @@ -0,0 +1,63 @@ +/* + Author: Freddo + + Description: + Returns groups value calculated from different factors. + + Parameter(s): + GROUP - Group to calculate value of. + + Returns: + NUMBER + + Note: + 0 per unarmed vehicle + 1 per soldier + 2 per AT soldier + 4 per armed "car" + 8 per "tank" + 12 per "aircraft" +*/ + +private _group = _this; +private _units = units _group; +private _vehicles = []; +private _rtrnValue = 0; + +{ + _vehicles pushBackUnique assignedVehicle _x; + if (secondaryWeapon _x isEqualTo "") then + { + _rtrnValue = _rtrnValue + 1; + } + else + { + _rtrnValue = _rtrnValue + 2; + }; +} forEach _units; + + +// Someone clean this up +{ + if (_x isKindOf "car") then + { + if (canFire _x) then + { + _rtrnValue = _rtrnValue + 4; + }; + } else { + if (_x isKindOf "tank") then + { + _rtrnValue = _rtrnValue + 8; + } + else + { + if (_x isKindOf "air") then + { + _rtrnValue = _rtrnValue + 12; + }; + }; + }; +} forEach _vehicles; + +_rtrnValue \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_CanReinforce.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_CanReinforce.sqf new file mode 100644 index 0000000..db192e0 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/scanning/fn_CanReinforce.sqf @@ -0,0 +1,43 @@ +/* + Author: Freddo + + Description: + Checks if a group is eligible to reinforce other units. + + Parameter(s): + GROUP - Group to check. + + Returns: + BOOLEAN +*/ + +private _group = _this; +private _units = units _group; +private _rtrn = true; + +if +( + (_group call VCM_fnc_GroupHasRadio) || + behaviour leader _group == "CARELESS" || + _group getVariable ["VCM_NORESCUE", false] +) exitWith {_rtrn = false; _rtrn}; + +switch (_group call VCM_fnc_CheckSituation) do +{ + case "READY": {}; + case "REINFORCE": {}; + default {_rtrn = false}; +}; + +if _rtrn then +{ + { + if + ( + !(canMove _x) || + {_x in VCM_ARTYLST} || + {vehicle _x isKindOf "StaticWeapon"} + ) exitWith {_rtrn = false; _rtrn}; + } forEach _units; +}; +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf index 5d88b9b..d2acc75 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_FriendlyGroupArray.sqf @@ -40,7 +40,7 @@ if _toSort then else { { - if ([side _x, _side] call BIS_fnc_sideIsFriendly && {!(_x isEqualTo _group)} && {0 <= _range && {_x distance2D _unit < _range}}) then + if ([side _x, _side] call BIS_fnc_sideIsFriendly && {!(_x isEqualTo _group)} && {0 <= _range && {leader _x distance2D _unit < _range}}) then { _friendlyArray pushBack _x; }; diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf index c71dab7..77e761c 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_GroupHasRadio.sqf @@ -11,11 +11,11 @@ BOOLEAN */ -private _group = group _this; -private _units = units _this; +private _group = _this; +private _units = units _group; private _rtrn = false; -if !((_units findIf {_x call VCM_fnc_HasRadio}) isEqualTo -1) then +if !((_units findIf {_x call VCM_fnc_HasRadio}) == -1) then { _rtrn = true; }; diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf index 6864d9a..f900c93 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_HasRadio.sqf @@ -16,6 +16,6 @@ private _unit = _this; -_rtrn = ("itemRadio" in (assignedItems _unit)); +_rtrn = ("ItemRadio" in (assignedItems _unit)); _rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf index c0cfdc2..9aa8800 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_KnownEnemyGroupArray.sqf @@ -23,7 +23,7 @@ private _arr = _this call VCM_fnc_KnownEnemyArray; private _rtrn = []; { - _arr pushBackUnique (group _x); + _rtrn pushBackUnique (group _x); } forEach _arr; _rtrn \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index fc35bff..a24cafb 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -75,6 +75,9 @@ class VCOM // unit call VCM_fnc_IsDriver; class IsDriver {}; + + // group call VCM_fnc_GroupValue + class GroupValue {}; }; // Artillery related functions. Deprecated @@ -123,6 +126,9 @@ class VCOM // group call VCM_fnc_RearmSelf; class RearmSelf {}; + + // group call VCM_fnc_RqstReinforce + class RqstReinforce {}; }; // Driving related functions @@ -213,9 +219,15 @@ class VCOM // [array, unitToReveal, revealAmount, _revealLimit] call VCM_fnc_KnowAbout; class KnowAbout {}; + // group call VCM_fnc_CanReinforce + class CanReinforce {}; + // unit call VCM_fnc_ClstEmy; class ClstEmy {}; + // [list, object, order, script] call VCM_fnc_ClstObj; + class ClstObj {}; + // unit call VCM_fnc_EnemyArray; class EnemyArray {}; @@ -237,9 +249,6 @@ class VCOM // [] call VCM_fnc_IRCHECK; class IRCHECK {}; - // [list, object, order, script] call VCM_fnc_ClstObj; - class ClstObj {}; - // unit call VCM_fnc_HasRadio; class HasRadio {}; From 972db41ac7716f30b8f89444b9c4fa8fe87df569 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Sat, 9 Mar 2019 13:31:16 +0100 Subject: [PATCH 14/30] Only call out formation change when changed AI would shout formations on every cycle despite not actually changing formation. --- .../VCM_Functions/movement/fn_FrmChnge.sqf | 82 ++++++++----------- 1 file changed, 33 insertions(+), 49 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/movement/fn_FrmChnge.sqf b/Vcom/Functions/VCM_Functions/movement/fn_FrmChnge.sqf index 82afe32..da6dec9 100644 --- a/Vcom/Functions/VCM_Functions/movement/fn_FrmChnge.sqf +++ b/Vcom/Functions/VCM_Functions/movement/fn_FrmChnge.sqf @@ -5,34 +5,33 @@ Changes group formation dependent on surroundings and behaviour Parameter(s): - 0: OBJECT - Unit whose group to change formation + OBJECT - Unit whose group to change formation Returns: - BOOL + BOOLEAN */ -private ["_unit", "_nearestCity", "_locationPos", "_nearestVillage", "_locationPos2", "_nearestHill", "_locationPos4", "_nearestLocal", "_locationPos3"]; - //Pull the unit -_unit = _this; +private _unit = _this; //Grab the group of the unit -_group = group _unit; +private _group = group _unit; +private _rtrn = false; //Vehicular groups in "SAFE" behaviour will move in convoys if (!isNull objectParent _unit && {behaviour _unit == "SAFE"}) exitWith { - _group setFormation "FILE"; + if (formation _group != "FILE") then {_group setFormation "FILE"}; //Set the units variable so they dont try changing formations too frequently. - _VCOM_CHANGEDFORMATION = true; - _VCOM_CHANGEDFORMATION + _rtrn = true; + _rtrn }; //Grab the nearest "City" from the unit -_nearestCity = nearestLocation [getPosASL _unit, "nameCity"]; +private _nearestCity = nearestLocation [getPosASL _unit, "nameCity"]; //Lets grab the location position -_locationPos = locationPosition _nearestCity; +private _locationPos = locationPosition _nearestCity; //If the unit is less than 500 meters from the location exit with the following code if ((_locationPos distance _unit) < 500) exitWith @@ -41,82 +40,67 @@ if ((_locationPos distance _unit) < 500) exitWith //Check if the unit is in a vehicle or not if (!isNull objectParent _unit) then { - _group setFormation "COLUMN"; + if (formation _group != "COLUMN") then {_group setFormation "COLUMN"}; } else { - _group setFormation "STAG COLUMN"; + if (formation _group != "STAG COLUMN") then {_group setFormation "STAG COLUMN"}; }; //Set the units variable so they dont try changing formations too frequently. - _VCOM_CHANGEDFORMATION = true; - _VCOM_CHANGEDFORMATION + _rtrn = true; + _rtrn }; //The rest of the commands follow the same logic. Commenting where necessary. -_nearestVillage = nearestLocation [getPosASL _unit, "NameVillage"]; -_locationPos2 = locationPosition _nearestVillage; +private _nearestVillage = nearestLocation [getPosASL _unit, "NameVillage"]; +private _locationPos2 = locationPosition _nearestVillage; if ((_locationPos2 distance _unit) < 500) exitWith { if ((vehicle _unit) != _unit) then { - _group setFormation "COLUMN"; + if (formation _group != "COLUMN") then {_group setFormation "COLUMN"}; } else { - _group setFormation "STAG COLUMN"; + if (formation _group != "STAG COLUMN") then {_group setFormation "STAG COLUMN"}; }; - _VCOM_CHANGEDFORMATION = true; - _VCOM_CHANGEDFORMATION + _rtrn = true; + _rtrn }; -_nearestHill = nearestLocation [getPosASL _unit, "Hill"]; -_locationPos4 = locationPosition _nearestHill; +private _nearestHill = nearestLocation [getPosASL _unit, "Hill"]; +private _locationPos4 = locationPosition _nearestHill; if ((_locationPos4 distance _unit) < 500) exitWith { - if ((vehicle _unit) != _unit) then - { - _group setFormation "LINE"; - } - else - { - _group setFormation "LINE"; - }; - - _VCOM_CHANGEDFORMATION = true; - _VCOM_CHANGEDFORMATION + if (formation _group != "LINE") then {_group setFormation "LINE"}; + _rtrn = true; + _rtrn }; -_nearestLocal = nearestLocation [getPosASL _unit, "NameLocal"]; -_locationPos3 = locationPosition _nearestLocal; +private _nearestLocal = nearestLocation [getPosASL _unit, "NameLocal"]; +private _locationPos3 = locationPosition _nearestLocal; if ((_locationPos3 distance _unit) < 300) exitWith { - if ((vehicle _unit) != _unit) then - { - _group setFormation "COLUMN"; - } - else - { - _group setFormation "COLUMN"; - }; + if (formation _group != "COLUMN") then {_group setFormation "COLUMN"}; - _VCOM_CHANGEDFORMATION = true; - _VCOM_CHANGEDFORMATION + _rtrn = true; + _rtrn }; //Execute this code only when all the above were NOT true. Return to wedge formation -_group setFormation "WEDGE"; +if (formation _group != "WEDGE") then {_group setFormation "WEDGE"}; -_VCOM_CHANGEDFORMATION = true; +_rtrn = true; -_VCOM_CHANGEDFORMATION +_rtrn From 89eb8d94ce57a77138fbb2339066e955071863f4 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Mon, 11 Mar 2019 21:18:08 +0100 Subject: [PATCH 15/30] New CQC & movement system This change includes quite a few notable changes. If AI engage in combat within 150m of each other, they will from there on have two choices on how to proceed. If they outnumber the enemy, they will push the advantage, and if they are outnumbered they will attempt to fall back. Furthermore, vanilla Suppression is back and Autocombat is disabled. Autocombat will be enabled while in CQC, though outside of it it will be disabled in order to keep the AI moving quickly. In the close future, there will be a new Suppression system that builds upon the Vanilla suppression system to make midrange and further combat more interesting. To best utilize these changes, I recommend turning down AI "commanding" and "courage" down to 0, in order to make them more susceptible to suppressive fire. --- Vcom/FSMS/fn_SQUADBEH.fsm | 235 +++++++++--------- Vcom/Functions/VCM_Functions/fn_SquadExc.sqf | 6 +- .../VCM_Functions/movement/fn_CQCMovement.sqf | 69 +++++ .../VCM_Functions/movement/fn_FlankMove.sqf | 3 +- .../situation/fn_CheckSituation.sqf | 2 +- .../VCM_Functions/situation/fn_SetCQC.sqf | 48 ++++ Vcom/Functions/VcomAI_DefaultSettings.sqf | 2 +- Vcom/VcomInit.sqf | 9 +- Vcom/cfgFunctions.hpp | 6 + userconfig/VCOM_AI/AISettingsV4.hpp | 2 +- 10 files changed, 256 insertions(+), 126 deletions(-) create mode 100644 Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf create mode 100644 Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index 8899b7e..2f78db6 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -6,8 +6,8 @@ item1[] = {"Cond",4,218,-100.000000,700.000000,0.000000,750.000000,50.000000,"Co item2[] = {"Exit_FSM",1,250,-250.000000,700.000000,-175.000000,750.000000,0.000000,"Exit FSM"}; item3[] = {"Continue",8,218,50.000000,575.000000,150.000000,625.000000,0.000000,"Continue"}; item4[] = {"Start_Point",2,250,50.000000,400.000000,150.000000,450.000000,0.000000,"Start Point"}; -item5[] = {"Exit_Cond",4,218,-100.000000,475.000000,0.000000,525.000000,700.000000,"Exit Cond"}; -item6[] = {"Exit_FSM_1",1,250,-250.000000,475.000000,-175.000000,525.000000,0.000000,"Exit FSM"}; +item5[] = {"Exit_Cond",4,218,147.598297,530.021851,247.598297,580.021851,700.000000,"Exit Cond"}; +item6[] = {"Exit_FSM_1",1,250,610.862549,661.845093,685.862671,711.845093,0.000000,"Exit FSM"}; item7[] = {"Simulation_Pause",4,218,250.000000,475.000000,350.000000,525.000000,990.000000,"Simulation Pause"}; item8[] = {"Simulation_Pause",2,250,325.000000,525.000000,425.000000,575.000000,0.000000,"Simulation Pause"}; item9[] = {"Simulation_Enabl",4,218,200.000000,500.000000,300.000000,550.000000,980.000000,"Simulation Enable"}; @@ -23,9 +23,9 @@ item18[] = {"Continue2StartPo",8,218,0.000000,300.000000,100.000000,350.000000,0 item19[] = {"Continue2StartPo",4,218,100.000000,300.000000,200.000000,350.000000,0.000000,"Continue2StartPoint2"}; item20[] = {"Leader_Cycle_Beg",3,250,475.000000,275.000000,575.000000,325.000000,0.000000,"Leader Cycle Beginning"}; item21[] = {"Continue2Return",8,218,350.000000,275.000000,450.000000,325.000000,0.000000,"Continue2Return"}; -item22[] = {"Combat",4,218,675.000000,225.000000,775.000000,275.000000,100.000000,"Combat"}; +item22[] = {"Combat",4,218,683.094910,328.458984,773.094910,378.458984,100.000000,"Combat"}; item23[] = {"Combat_Brain",2,250,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; -item24[] = {"Combat_BEGIN",4,218,675.000000,325.000000,775.000000,375.000000,110.000000,"Combat BEGIN"}; +item24[] = {"Combat_BEGIN",4,218,677.957336,278.228424,777.957336,328.228424,110.000000,"Combat BEGIN"}; item25[] = {"Return",8,218,475.000000,75.000000,575.000000,125.000000,0.000000,"Return"}; item26[] = {"Arty_Check",4,218,1100.000000,250.000000,1200.000000,300.000000,84.000000,"Arty Check"}; item27[] = {"",7,210,1258.500000,21.000000,1266.500000,29.000000,0.000000,""}; @@ -33,7 +33,7 @@ item28[] = {"Flank_Orders",4,218,1050.000000,225.000000,1150.000000,275.000000,1 item29[] = {"",7,210,296.000000,21.000000,304.000000,29.000000,0.000000,""}; item30[] = {"Light_Garrison",4,218,1000.000000,200.000000,1100.000000,250.000000,88.000000,"Light Garrison"}; item31[] = {"Five_Minute_Chec",4,218,-300.000000,300.000000,-200.000000,350.000000,950.000000,"Five Minute Checks"}; -item32[] = {"Reinforcement_Ch",2,4346,-300.000000,150.000000,-200.000000,200.000000,0.000000,"Reinforcement" \n "Check"}; +item32[] = {"Reinforcement_Ch",2,250,-300.000000,150.000000,-200.000000,200.000000,0.000000,"Reinforcement" \n "Check"}; item33[] = {"CheckIfStatic",4,218,949.004028,175.000031,1050.000122,225.996094,92.000000,"CheckIfStatic"}; item34[] = {"TwoMinuteChecks",4,218,-400.000000,300.000000,-300.000000,350.000000,940.000000,"TwoMinuteChecks"}; item35[] = {"Two_Minute_Check",2,250,-400.000000,150.000000,-300.000000,200.000000,0.000000,"Two Minute Checks"}; @@ -42,10 +42,11 @@ item37[] = {"MinePlant",4,218,850.000000,125.000000,950.000000,175.000000,86.000 item38[] = {"ArmStatics",4,218,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; item39[] = {"True",8,218,750.000000,75.000000,850.000000,125.000000,0.000000,"True"}; item40[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; -item41[] = {"Exit_FSM_2",1,250,700.000000,600.000000,775.000000,650.000000,0.000000,"Exit FSM"}; -item42[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; -item43[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; -item44[] = {"Combat_END",4,218,684.709351,384.913361,784.709351,434.913361,90.000000,"Combat END"}; +item41[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; +item42[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; +item43[] = {"Combat_END",4,4314,677.941040,379.111908,777.941040,429.111908,120.000000,"Combat END"}; +item44[] = {"",7,210,193.223969,683.948181,201.223969,691.948181,0.000000,""}; +item45[] = {"____FAKE____",9,0,0.000000,0.000000,0.000000,0.000000,0.000000,"____FAKE____"}; link0[] = {0,1}; link1[] = {0,3}; link2[] = {1,2}; @@ -57,7 +58,7 @@ link7[] = {4,12}; link8[] = {4,13}; link9[] = {4,31}; link10[] = {4,34}; -link11[] = {5,6}; +link11[] = {5,44}; link12[] = {7,8}; link13[] = {8,9}; link14[] = {8,10}; @@ -78,7 +79,7 @@ link28[] = {20,22}; link29[] = {20,24}; link30[] = {20,25}; link31[] = {20,40}; -link32[] = {20,44}; +link32[] = {20,43}; link33[] = {21,16}; link34[] = {22,23}; link35[] = {23,25}; @@ -92,29 +93,30 @@ link42[] = {23,38}; link43[] = {23,39}; link44[] = {23,40}; link45[] = {23,42}; -link46[] = {23,43}; -link47[] = {24,23}; -link48[] = {25,16}; -link49[] = {26,27}; -link50[] = {27,29}; -link51[] = {28,27}; -link52[] = {29,16}; -link53[] = {30,27}; -link54[] = {31,32}; -link55[] = {32,18}; -link56[] = {33,27}; -link57[] = {34,35}; -link58[] = {35,18}; -link59[] = {36,27}; -link60[] = {37,27}; -link61[] = {38,27}; -link62[] = {39,27}; -link63[] = {40,41}; +link46[] = {24,23}; +link47[] = {25,16}; +link48[] = {26,27}; +link49[] = {27,29}; +link50[] = {28,27}; +link51[] = {29,16}; +link52[] = {30,27}; +link53[] = {31,32}; +link54[] = {32,18}; +link55[] = {33,27}; +link56[] = {34,35}; +link57[] = {35,18}; +link58[] = {36,27}; +link59[] = {37,27}; +link60[] = {38,27}; +link61[] = {39,27}; +link62[] = {40,6}; +link63[] = {41,27}; link64[] = {42,27}; link65[] = {43,27}; -link66[] = {44,27}; -globals[] = {0.000000,0,0,0,0,640,480,2,623,6316128,1,-341.180847,1163.171631,1047.220947,-26.102501,1254,884,1}; -window[] = {2,-1,-1,-1,-1,1009,91,836,55,3,1272}; +link66[] = {44,6}; +link67[] = {45,41}; +globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,397.512909,965.388550,735.301025,-75.390381,580,828,1}; +window[] = {2,-1,-1,-32180,-32000,983,-1125,-380,29,3,598}; *//*%FSM*/ class FSM { @@ -126,9 +128,9 @@ class FSM { name = "Begin_State"; itemno = 0; - init = /*%FSM*/"private _Group = _this;" \n + init = /*%FSM*/"private _group = _this;" \n "private _leader = leader _group;" \n - "" \n + "private _curUnits = (units _group);" \n "" \n "" \n ""/*%FSM*/; @@ -142,7 +144,7 @@ class FSM priority = 50.000000; to="Exit_FSM"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"isPlayer _leader || " \n + condition=/*%FSM*/"((units _group) findIf {isPlayer _x} != -1) || //Do not execute code on player groups" \n "{_Group getvariable [""Vcm_Disable"",false]} || " \n "{!(side _group in VCM_SIDEENABLED)}"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; @@ -174,20 +176,23 @@ class FSM "private _SatchelList = [];" \n "private _MineList = [];" \n "private _StartingBehavior = behaviour _leader;" \n - "private _CurUnits = (units _Group);" \n "private _ehList = [];" \n "" \n - "_Group setVariable [""VCM_SQUADFSM"", _thisFSM, VCM_DEBUG]; // Script handle, global if debug is on" \n + "_group setVariable [""VCM_SQUADFSM"", _thisFSM, VCM_DEBUG]; // Script handle, global if debug is on" \n "" \n - "_Group call VCM_fnc_ArtyManage;" \n + "_group call VCM_fnc_ArtyManage;" \n "private _isskilldisabled = _Group getVariable ""VCM_Skilldisable"";" \n "if (VCM_SKILLCHANGE && isnil ""_isskilldisabled"") then {_Group call VCM_AIDIFSET};" \n "" \n + "_group allowFleeing 0; // Disable fleeing" \n + "_group enableAttack false; // Disable units individually moving to engage" \n "" \n "{" \n " if (!(isPlayer _x)) then" \n " {" \n - " _x disableAI ""SUPPRESSION"";" \n + " _x disableAI ""AUTOCOMBAT"";" \n + " _x setSkill [""COURAGE"", 0]; //Make AI more susceptible to suppression" \n + " _x setSkill [""COMMANDING"", 0]; //Make AI take longer to share information" \n " // Eventhandlers are added to the array _ehList in the format [unit, type, index] for later removal" \n " _ehList pushBack [_x, ""Killed"", _x addEventHandler [""Killed"",{_this spawn VCM_fnc_ClstWarn;}]];" \n " _ehList pushBack [_x, ""Hit"", _x addEventHandler [""Hit"",{_this call VCM_fnc_AIHIT;}]];" \n @@ -258,7 +263,8 @@ class FSM priority = 990.000000; to="Simulation_Pause"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"!(simulationEnabled _leader)"/*%FSM*/; + condition=/*%FSM*/"!(simulationEnabled _leader) ||" \n + "(behaviour _leader == ""CARELESS"")"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -313,7 +319,7 @@ class FSM priority = 700.000000; to="Exit_FSM_1"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"isPlayer _leader || " \n + condition=/*%FSM*/"((units _group) findIf {isPlayer _x} != -1) || " \n "{_Group getvariable [""Vcm_Disable"",false]} || " \n "{(((units _Group) findIf {alive _x}) isEqualTo -1)} || " \n "{!(side _group in VCM_SIDEENABLED)}"/*%FSM*/; @@ -378,7 +384,8 @@ class FSM priority = 980.000000; to="Start_Point"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"simulationEnabled (leader _group)"/*%FSM*/; + condition=/*%FSM*/"simulationEnabled (leader _group) ||" \n + "(behaviour _leader == ""CARELESS"")"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -510,12 +517,39 @@ class FSM { itemno = 40; priority = 700.000000; - to="Exit_FSM_2"; + to="Exit_FSM_1"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_Group getvariable [""Vcm_Disable"",false]) || (((units _Group) findIf {alive _x}) isEqualTo -1)"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ + /*%FSM*/ + class Combat_END + { + itemno = 43; + priority = 120.000000; + to="Return"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_Beh isEqualTo ""COMBAT"" &&" \n + "{" \n + " _situation isEqualTo ""GARRISON"" ||" \n + " {isNull (_leader findNearestEnemy position _leader)}" \n + "}"/*%FSM*/; + action=/*%FSM*/"// return behaviour and speed to normal" \n + "_Beh = ""SAFE"";" \n + "_leader setBehaviour _StartingBehavior;" \n + "(group _leader) setSpeedMode ""NORMAL"";" \n + "" \n + "// delete waypoints" \n + "_leader spawn" \n + "{" \n + " while {(count (waypoints (group _this))) > 0} do" \n + " { deleteWaypoint ((waypoints (group _this)) select 0); };" \n + "};" \n + "" \n + "if (VCM_Debug) then {systemchat ""VCOM: COMBAT END"";};"/*%FSM*/; + }; + /*%FSM*/ /*%FSM*/ class Combat_BEGIN { @@ -523,11 +557,11 @@ class FSM priority = 110.000000; to="Combat_Brain"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_Beh isEqualTo ""COMBAT"")} && {!(_situation isEqualTo ""GARRISON"")}"/*%FSM*/; + condition=/*%FSM*/"!(_Beh isEqualTo ""COMBAT"") && " \n + "{!isNull (_leader findNearestEnemy position _leader)}"/*%FSM*/; action=/*%FSM*/"//[_Leader,50] call VCM_fnc_FindCover;" \n "_Cover2Cover = time;" \n "_Beh = ""COMBAT"";" \n - "if (VCM_FullSpeed) then {_Group setSpeedMode ""FULL"";};" \n "_BackbkC3 = (time + 300 - VCM_WARNDELAY);"/*%FSM*/; }; /*%FSM*/ @@ -538,34 +572,10 @@ class FSM priority = 100.000000; to="Combat_Brain"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_situation isEqualTo ""GARRISON"")}"/*%FSM*/; + condition=/*%FSM*/"_Beh isEqualTo ""COMBAT"""/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ - /*%FSM*/ - class Combat_END - { - itemno = 44; - priority = 90.000000; - to="Return"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"((behaviour _leader) isEqualTo ""COMBAT"") && {!(_situation isEqualTo ""GARRISON"")} && {_leader distance (_leader call VCM_fnc_ClstEmy) > 400}" \n - ""/*%FSM*/; - action=/*%FSM*/"// return behaviour and speed to normal" \n - "_Beh = ""SAFE"";" \n - "_leader setBehaviour _StartingBehavior;" \n - "(group _leader) setSpeedMode ""NORMAL"";" \n - "" \n - "// delete waypoints" \n - "_leader spawn" \n - "{" \n - " while {(count (waypoints (group _this))) > 0} do" \n - " { deleteWaypoint ((waypoints (group _this)) select 0); };" \n - "};" \n - "" \n - "if (VCM_Debug) then {systemchat ""VCOM: COMBAT END"";};"/*%FSM*/; - }; - /*%FSM*/ /*%FSM*/ class Hold_WP { @@ -616,10 +626,16 @@ class FSM init = /*%FSM*/"private _t = time;" \n "private _Wait = 3;" \n "" \n - "private _NearestEnemy = _leader findNearestEnemy _leader;" \n - "if (isNull _NearestEnemy) then" \n + "private _nearestEnemy = _leader findNearestEnemy _leader;" \n + "if (isNull _nearestEnemy) then" \n + "{" \n + " _nearestEnemy = _leader call VCM_fnc_ClstEmy; " \n + "};" \n + "" \n + "if (_nearestEnemy distance _leader <= 150 && _situation != ""CQC"" && _situation != ""BREAKING"") then " \n "{" \n - " _NearestEnemy = _leader call VCM_fnc_ClstEmy; " \n + " _situation = ""CQC"";" \n + " [_group, _nearestEnemy] call VCM_fnc_SetCQC;" \n "};" \n "" \n "private _ArtyT = 0;" \n @@ -645,7 +661,7 @@ class FSM { itemno = 40; priority = 700.000000; - to="Exit_FSM_2"; + to="Exit_FSM_1"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_Group getvariable [""Vcm_Disable"",false]) || (((units _Group) findIf {alive _x}) isEqualTo -1)"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; @@ -672,21 +688,6 @@ class FSM "if (VCM_Debug) then {systemchat ""VCOM: WAYPOINT GENERATION"";};"/*%FSM*/; }; /*%FSM*/ - /*%FSM*/ - class MOVE_UP - { - itemno = 42; - priority = 104.000000; - to="Return"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"_Cover2Cover + 60 < time && " \n - "{!(_situation isEqualTo ""LGARRISON"")}"/*%FSM*/; - action=/*%FSM*/"_Cover2Cover = time;" \n - "[_Leader,100] call VCM_fnc_ForceMove;" \n - "" \n - ""/*%FSM*/; - }; - /*%FSM*/ /*%FSM*/ class CheckIfStatic { @@ -711,10 +712,10 @@ class FSM "private _BackPack = _x select 1;" \n "private _HASUAV = _x select 2;" \n "" \n - "private _NearestEnemy = _leader findNearestEnemy _leader;" \n - "if (isNull _NearestEnemy) then" \n + "private _nearestEnemy = _leader findNearestEnemy _leader;" \n + "if (isNull _nearestEnemy) then" \n "{" \n - " _NearestEnemy = _leader call VCM_fnc_ClstEmy; " \n + " _nearestEnemy = _leader call VCM_fnc_ClstEmy; " \n "};" \n "" \n "//If the unit is in a building, or can see the enemy, we don't want them deploying mortars." \n @@ -734,9 +735,9 @@ class FSM " private _StaticCreated = _AssembledG createvehicle [0,0,0];" \n " _StaticCreated setposATL (getposATL _Unit);" \n "" \n - " [_Unit,_StaticCreated,_NearestEnemy] spawn " \n + " [_Unit,_StaticCreated,_nearestEnemy] spawn " \n " {" \n - " params [""_Unit"",""_StaticCreated"",""_NearestEnemy""];" \n + " params [""_Unit"",""_StaticCreated"",""_nearestEnemy""];" \n "" \n " [_Unit,""AinvPknlMstpSnonWnonDnon_Putdown_AmovPknlMstpSnonWnonDnon""] remoteExec [""Vcm_PMN"",0];" \n " sleep 3.5;" \n @@ -745,7 +746,7 @@ class FSM " _Unit moveInGunner _StaticCreated;" \n " removeBackpackGlobal _Unit;" \n "" \n - " private _dirTo = _StaticCreated getDir _NearestEnemy;" \n + " private _dirTo = _StaticCreated getDir _nearestEnemy;" \n " _StaticCreated setDir _dirTo;" \n " (Vehicle _Unit) setDir _dirTo;" \n " };" \n @@ -768,7 +769,7 @@ class FSM to="Return"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_BackbkC7 + 30 < time) && " \n - "{((_NearestEnemy distance2D _leader) < 800)} && " \n + "{((_nearestEnemy distance2D _leader) < 800)} && " \n "{[_Group] call VCM_fnc_EmptyStatic};"/*%FSM*/; action=/*%FSM*/"_Group call VCM_fnc_ArmStatics;_BackbkC7 = time;" \n "" \n @@ -871,7 +872,7 @@ class FSM condition=/*%FSM*/"VCM_ARTYENABLE && " \n "{(_ArtyT + VCM_ARTYDELAY) < time} && " \n "{side _Group in VCM_ARTYSIDES} && " \n - "{!(_NearestEnemy isEqualTo [0,0,0])} && " \n + "{!(_nearestEnemy isEqualTo [0,0,0])} && " \n "{count (units (group _NearestEnemy)) > 2}"/*%FSM*/; action=/*%FSM*/"[_Group,(group _NearestEnemy)] call VCM_fnc_ArtyCall;" \n "switch ((side _Group)) do {" \n @@ -886,18 +887,15 @@ class FSM /*%FSM*/ class Clear_Building { - itemno = 43; + itemno = 42; priority = 50.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_BackbkC8 + 15 < time && " \n "{_ClearCnc < 51} && " \n - "{" \n - " _situation isEqualTo ""FLANKING"" ||" \n - " {_situation isEqualTo ""READY""}" \n - "} && " \n - "{leader _Group distance2D _NearestEnemy < 100}"/*%FSM*/; - action=/*%FSM*/"[_Group,_NearestEnemy] call VCM_fnc_ClearBuilding;" \n + "{_situation isEqualTo ""CQC""} && " \n + "{leader _Group distance2D _nearestEnemy < 100}"/*%FSM*/; + action=/*%FSM*/"[_Group,_nearestEnemy] call VCM_fnc_ClearBuilding;" \n "private _t = time;" \n "private _Wait = 10;" \n "_BackbkC8 = time;"/*%FSM*/; @@ -975,18 +973,30 @@ class FSM }; }; /*%FSM*/ - /*%FSM*/ - class Exit_FSM_2 + /*%FSM*/ + class ____FAKE____ { - name = "Exit_FSM_2"; - itemno = 41; - init = /*%FSM*/"private _N = VcmAI_ActiveList findIf {_x isEqualTo _Group};" \n - "VcmAI_ActiveList deleteAt _N;" \n - "" \n - "if (VCM_Debug) then {diag_log (format [""%1: EXITED VCOM SCRIPTS"",_Group])};"/*%FSM*/; + name = "____FAKE____"; + itemno = 45; + init = /*%FSM*/""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links { + /*%FSM*/ + class MOVE_UP + { + itemno = 41; + priority = 104.000000; + to="Return"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_Cover2Cover + 60 < time && " \n + "{!(_situation isEqualTo ""LGARRISON"")}"/*%FSM*/; + action=/*%FSM*/"_Cover2Cover = time;" \n + "[_Leader,100] call VCM_fnc_ForceMove;" \n + "" \n + ""/*%FSM*/; + }; + /*%FSM*/ }; }; /*%FSM*/ @@ -996,7 +1006,6 @@ class FSM { "Exit_FSM", "Exit_FSM_1", - "Exit_FSM_2", }; }; /*%FSM*/ \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/fn_SquadExc.sqf b/Vcom/Functions/VCM_Functions/fn_SquadExc.sqf index 6472d4d..c1d044b 100644 --- a/Vcom/Functions/VCM_Functions/fn_SquadExc.sqf +++ b/Vcom/Functions/VCM_Functions/fn_SquadExc.sqf @@ -7,11 +7,11 @@ These FSM's will run until the group is cleaned. They will be designed to halt when the group is empty or all units are dead. Parameter(s): - 0: GROUP + GROUP Returns: NOTHING */ - -_this spawn VCM_fnc_SQUADBEH; +private _fsmHandle = _this getVariable "VCM_SQUADFSM"; +if (isNil "_fsmHandle") then {_this spawn VCM_fnc_SQUADBEH}; VcmAI_ActiveList pushback _this; \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf b/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf new file mode 100644 index 0000000..d971d31 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf @@ -0,0 +1,69 @@ +/* + Author: Freddo + + Description: + Creates CQC waypoints depending on the situation. + + Parameter(s): + 0: GROUP - Group to generate waypoints for + 1: OBJECT - Closest enemy + + Returns: + NOTHING +*/ +params ["_group", "_closestEnemy"]; +private _leader = leader _group; +if (isNil "_closestEnemy") then +{ + _closestEnemy = _leader findNearestEnemy _leader; +}; + +if (_leader distance _closestEnemy < 150) then +{ + for "_i" from ((count waypoints _group) - 1) to 1 do {deleteWaypoint [_group, _i]}; + + // Copied from VCM_fnc_RqstReinforce + // Checks if friendlies outnumber the enemy + private _knownEnemyG = ([_leader, 200, false] call VCM_fnc_KnownEnemyGroupArray); + private _enemyValue = 0; + { + _enemyValue = _enemyValue + (_x call VCM_fnc_GroupValue); + }forEach _knownEnemyG; + + // Add a bit of +- inaccuracy + _enemyValue = (_enemyValue * (0.75 + random 0.5)); + + // Calculate friendly forces value in vincinity + private _knownFriendlyG = ([_leader, false, 200] call VCM_fnc_FriendlyGroupArray); + private _friendlyValue = 0; + { + _friendlyValue = _friendlyValue + (_x call VCM_fnc_GroupValue); + }forEach _knownFriendlyG; + + if ((_friendlyValue * 1.25) > _enemyValue) then + { + // Push the advantage + private _wp = _group addWaypoint [position _closestEnemy, 25]; + _wp setWaypointType "SAD"; + _wp setWaypointSpeed "FULL"; + _wp setWaypointStatements ["this", "[group this] call VCM_fnc_CQCMovement"]; + _group setCurrentWaypoint _wp; + _group enableAttack true; + } + else + { + // Fall back + private _direction = _closestEnemy getDir _leader; + private _wp = _group addWaypoint [position _leader getPos [_direction, 200], 25]; + _wp setWaypointSpeed "FULL"; + _wp setWaypointStatements ["this", "[group this call VCM_fnc_CQCMovement]"]; + _group setCurrentWaypoint _wp; + _group enableAttack false; + private _units = units _group; + { + // Regroup + doStop _x; + _x doFollow _leader; + } forEach _units; + }; +}; \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/movement/fn_FlankMove.sqf b/Vcom/Functions/VCM_Functions/movement/fn_FlankMove.sqf index 83623a7..d70026e 100644 --- a/Vcom/Functions/VCM_Functions/movement/fn_FlankMove.sqf +++ b/Vcom/Functions/VCM_Functions/movement/fn_FlankMove.sqf @@ -7,12 +7,13 @@ Parameter(s): 0: OBJECT - Group leader who will generate waypoints + 1: OPTIONAL: STRING - Movetype, avilable options: "Assault", "High", "Low", "Retreat", "Flank", "FlankL" Returns: NOTHING */ -params ["_leader"]; +params ["_leader", "_moveType"]; private _grp = group _leader; if (_grp getVariable ["VCM_NOFLANK",false]) exitWith {}; diff --git a/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf b/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf index 086c948..0411861 100644 --- a/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf +++ b/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf @@ -5,7 +5,7 @@ Returns current situation/task of the unit Parameter(s): - 0: GROUP - Group to check the situation of + GROUP - Group to check the situation of Returns: STRING diff --git a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf new file mode 100644 index 0000000..d00f2bc --- /dev/null +++ b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf @@ -0,0 +1,48 @@ +/* + Author: Freddo + + Description: + Sets current situation as Close Quarters Combat, and spawns scripts to eventually exit it + + Parameter(s): + 0: GROUP - Group to set the situation of + 1: OBJECT - Nearest enemy + + Returns: + NOTHING +*/ +params ["_group", "_nearestEnemy"]; +private _units = units _group; +{_x enableAI "AUTOCOMBAT"} forEach _units; + +[_group, _nearestEnemy] call VCM_fnc_CQCMovement; + +_group spawn //Handle to eventually exit script +{ + params ["_group", "_handle"]; + private _group = _this; + private _units = units _group; + while {true} do + { + sleep (15 + random 10); + private _situation = _group call VCM_fnc_CheckSituation; + if (isNil "_situation") exitWith {}; //Group/FSM has been deleted + private _leader = leader _group; + if (_units findIf {alive _x} == -1 || _situation isEqualTo "BREAKING") exitWith + { + _group enableAttack false; + {_x doFollow _leader} forEach _units; + }; + private _nearestEnemy = _leader findNearestEnemy _leader; + if (!isNull _nearestEnemy && {_nearestEnemy distance _leader > 200}) exitWith + { + [_group, "READY"] call VCM_fnc_SetSituation; + _group enableAttack false; + { + _x doFollow (leader _group); + _x disableAI "AUTOCOMBAT"; + } forEach _units; + _group setSpeedMode "NORMAL"; + }; + } +}; \ No newline at end of file diff --git a/Vcom/Functions/VcomAI_DefaultSettings.sqf b/Vcom/Functions/VcomAI_DefaultSettings.sqf index eb9b689..96b62b6 100644 --- a/Vcom/Functions/VcomAI_DefaultSettings.sqf +++ b/Vcom/Functions/VcomAI_DefaultSettings.sqf @@ -145,7 +145,7 @@ VCM_AIDIFSET = if (typeOf _unit isEqualTo (_x select 0)) exitWith { _ClassnameSet = true; - _unit setSkill ["aimingAccuracy",((_x select 1) select 0)];_unit setSkill ["aimingShake",((_x select 1) select 1)];_unit setSkill ["spotDistance",((_x select 1) select 2)];_unit setSkill ["spotTime",((_x select 1) select 3)];_unit setSkill ["courage",((_x select 1) select 4)];_unit setSkill ["commanding",((_x select 1) select 5)]; _unit setSkill ["aimingSpeed",((_x select 1) select 6)];_unit setSkill ["general",((_x select 1) select 7)];_unit setSkill ["endurance",((_x select 1) select 8)];_unit setSkill ["reloadSpeed",((_x select 1) select 9)]; + _unit setSkill ["aimingAccuracy",((_x select 1) select 0)];_unit setSkill ["aimingShake",((_x select 1) select 1)];_unit setSkill ["spotDistance",((_x select 1) select 2)];_unit setSkill ["spotTime",((_x select 1) select 3)];/*_unit setSkill ["courage",((_x select 1) select 4)];_unit setSkill ["commanding",((_x select 1) select 5)];*/ _unit setSkill ["aimingSpeed",((_x select 1) select 6)];_unit setSkill ["general",((_x select 1) select 7)];_unit setSkill ["endurance",((_x select 1) select 8)];_unit setSkill ["reloadSpeed",((_x select 1) select 9)]; }; } foreach VCM_SKILL_CLASSNAMES; }; diff --git a/Vcom/VcomInit.sqf b/Vcom/VcomInit.sqf index 770d921..d30267c 100644 --- a/Vcom/VcomInit.sqf +++ b/Vcom/VcomInit.sqf @@ -40,15 +40,12 @@ VCOM_MINEARRAY = []; if (Vcm_ActivateAI) then { { - if (local _x && {simulationEnabled (leader _x)} && {!(isplayer (leader _x))} && {(leader _x) isKindOf "Man"}) then + if (local _x && {simulationEnabled (leader _x)} && {(units _x) findIf {isPlayer _x} == -1} && {(leader _x) isKindOf "Man"}) then { private _Grp = _x; - if !(_Grp in VcmAI_ActiveList) then //{!(VCM_SIDEENABLED findIf {_x isEqualTo (side _Grp)} isEqualTo -1)} + if !(((units _Grp) findIf {alive _x}) isEqualTo -1) then { - if !(((units _Grp) findIf {alive _x}) isEqualTo -1) then - { - _x call VCM_fnc_SquadExc; - }; + _x call VCM_fnc_SquadExc; }; }; } foreach allGroups; diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index a24cafb..0ee702f 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -183,6 +183,9 @@ class VCOM { file = "Vcom\Functions\VCM_Functions\movement"; + // [group, closestEnemy] call VCM_fnc_CQCMovement; + class CQCMovement {}; + // [groupLeader, moveDistance] call VCM_fnc_ForceMove; class ForceMove {}; @@ -204,6 +207,9 @@ class VCOM // group call CheckSituation; class CheckSituation {}; + // group call SetCQC; + class SetCQC {}; + // group call SetSituation; class SetSituation {}; }; diff --git a/userconfig/VCOM_AI/AISettingsV4.hpp b/userconfig/VCOM_AI/AISettingsV4.hpp index 5d7eee2..381d5c5 100644 --- a/userconfig/VCOM_AI/AISettingsV4.hpp +++ b/userconfig/VCOM_AI/AISettingsV4.hpp @@ -147,7 +147,7 @@ VCM_AIDIFSET = if (typeOf _unit isEqualTo (_x select 0)) exitWith { _ClassnameSet = true; - _unit setSkill ["aimingAccuracy",((_x select 1) select 0)];_unit setSkill ["aimingShake",((_x select 1) select 1)];_unit setSkill ["spotDistance",((_x select 1) select 2)];_unit setSkill ["spotTime",((_x select 1) select 3)];_unit setSkill ["courage",((_x select 1) select 4)];_unit setSkill ["commanding",((_x select 1) select 5)]; _unit setSkill ["aimingSpeed",((_x select 1) select 6)];_unit setSkill ["general",((_x select 1) select 7)];_unit setSkill ["endurance",((_x select 1) select 8)];_unit setSkill ["reloadSpeed",((_x select 1) select 9)]; + _unit setSkill ["aimingAccuracy",((_x select 1) select 0)];_unit setSkill ["aimingShake",((_x select 1) select 1)];_unit setSkill ["spotDistance",((_x select 1) select 2)];_unit setSkill ["spotTime",((_x select 1) select 3)];/*_unit setSkill ["courage",((_x select 1) select 4)];_unit setSkill ["commanding",((_x select 1) select 5)];*/ _unit setSkill ["aimingSpeed",((_x select 1) select 6)];_unit setSkill ["general",((_x select 1) select 7)];_unit setSkill ["endurance",((_x select 1) select 8)];_unit setSkill ["reloadSpeed",((_x select 1) select 9)]; }; } foreach VCM_SKILL_CLASSNAMES; }; From 3a0f638f5fc790673012804333861bd5bc97117d Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 12 Mar 2019 16:18:10 +0100 Subject: [PATCH 16/30] CheckSituation returns nothing sometimes Added isNil check, that will make it return "ERROR" instead of nothing. --- Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf | 2 +- Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf b/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf index 0411861..f2be9aa 100644 --- a/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf +++ b/Vcom/Functions/VCM_Functions/situation/fn_CheckSituation.sqf @@ -19,5 +19,5 @@ if !(isNil "_fsm") then { _rtrn = _fsm getFSMVariable "_situation"; }; - +if (isNil "_rtrn") then {_rtrn = "ERROR"}; //This generally occurs when the FSM has been suddenly stopped _rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf index d00f2bc..4051d0a 100644 --- a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf +++ b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf @@ -26,7 +26,6 @@ _group spawn //Handle to eventually exit script { sleep (15 + random 10); private _situation = _group call VCM_fnc_CheckSituation; - if (isNil "_situation") exitWith {}; //Group/FSM has been deleted private _leader = leader _group; if (_units findIf {alive _x} == -1 || _situation isEqualTo "BREAKING") exitWith { From fc324ab1857c7af509d42c2ad544f82137c975cd Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Sat, 16 Mar 2019 21:49:27 +0100 Subject: [PATCH 17/30] New suppression system Added a new suppression system to make AI able to move better while under fire. Old system still kicks in while near enemies. Fixed several things with initialisation that were spawning double threads and more. --- Vcom/FSMS/fn_SQUADBEH.fsm | 226 +++++----- Vcom/FSMS/fn_UNITSUPPRESSION.fsm | 418 ++++++++++++++++++ .../VCM_Functions/movement/fn_CQCMovement.sqf | 3 + .../VCM_Functions/scanning/fn_ClstObj.sqf | 4 +- .../situation/fn_SetSituation.sqf | 2 +- .../{actions => suppression}/fn_AIHIT.sqf | 13 +- .../suppression/fn_AddSuppression.sqf | 21 + .../suppression/fn_AddSuppressionNow.sqf | 27 ++ .../suppression/fn_FSMGetSuppression.sqf | 22 + .../suppression/fn_GetSuppression.sqf | 21 + .../suppression/fn_GroupGetSuppression.sqf | 28 ++ .../suppression/fn_SuppressionDebug.sqf | 32 ++ Vcom/Functions/VcomAI_DefaultSettings.sqf | 1 + Vcom/VcomInit.sqf | 51 ++- Vcom/cfgFunctions.hpp | 32 +- 15 files changed, 758 insertions(+), 143 deletions(-) create mode 100644 Vcom/FSMS/fn_UNITSUPPRESSION.fsm rename Vcom/Functions/VCM_Functions/{actions => suppression}/fn_AIHIT.sqf (95%) create mode 100644 Vcom/Functions/VCM_Functions/suppression/fn_AddSuppression.sqf create mode 100644 Vcom/Functions/VCM_Functions/suppression/fn_AddSuppressionNow.sqf create mode 100644 Vcom/Functions/VCM_Functions/suppression/fn_FSMGetSuppression.sqf create mode 100644 Vcom/Functions/VCM_Functions/suppression/fn_GetSuppression.sqf create mode 100644 Vcom/Functions/VCM_Functions/suppression/fn_GroupGetSuppression.sqf create mode 100644 Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index 2f78db6..de9d4a7 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -15,38 +15,36 @@ item10[] = {"Wait",4,218,325.000000,600.000000,425.000000,650.000000,0.000000,"W item11[] = {"Frequent_Checks",4,218,-100.000000,300.000000,0.000000,350.000000,970.000000,"Frequent Checks"}; item12[] = {"RearmCheck",4,218,-200.000000,300.000000,-100.000000,350.000000,960.000000,"RearmCheck"}; item13[] = {"Continue2LeaderC",8,218,350.000000,375.000000,450.000000,425.000000,0.000000,"Continue2LeaderCycle"}; -item14[] = {"Hold_WP",4,218,400.000000,200.000000,500.000000,250.000000,48.000000,"Hold WP"}; +item14[] = {"Hold_WP",4,218,337.648285,274.228271,437.648285,324.228271,48.000000,"Hold WP"}; item15[] = {"RearmCheck",2,250,-200.000000,150.000000,-100.000000,200.000000,0.000000,"RearmCheck"}; item16[] = {"Return",2,250,250.000000,200.000000,350.000000,250.000000,0.000000,"Return"}; item17[] = {"Full_Check",2,250,-100.000000,150.000000,0.000000,200.000000,0.000000,"Full Check"}; item18[] = {"Continue2StartPo",8,218,0.000000,300.000000,100.000000,350.000000,0.000000,"Continue2StartPoint"}; item19[] = {"Continue2StartPo",4,218,100.000000,300.000000,200.000000,350.000000,0.000000,"Continue2StartPoint2"}; -item20[] = {"Leader_Cycle_Beg",3,250,475.000000,275.000000,575.000000,325.000000,0.000000,"Leader Cycle Beginning"}; -item21[] = {"Continue2Return",8,218,350.000000,275.000000,450.000000,325.000000,0.000000,"Continue2Return"}; -item22[] = {"Combat",4,218,683.094910,328.458984,773.094910,378.458984,100.000000,"Combat"}; -item23[] = {"Combat_Brain",2,250,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; -item24[] = {"Combat_BEGIN",4,218,677.957336,278.228424,777.957336,328.228424,110.000000,"Combat BEGIN"}; -item25[] = {"Return",8,218,475.000000,75.000000,575.000000,125.000000,0.000000,"Return"}; -item26[] = {"Arty_Check",4,218,1100.000000,250.000000,1200.000000,300.000000,84.000000,"Arty Check"}; -item27[] = {"",7,210,1258.500000,21.000000,1266.500000,29.000000,0.000000,""}; -item28[] = {"Flank_Orders",4,218,1050.000000,225.000000,1150.000000,275.000000,105.000000,"Flank Orders"}; -item29[] = {"",7,210,296.000000,21.000000,304.000000,29.000000,0.000000,""}; -item30[] = {"Light_Garrison",4,218,1000.000000,200.000000,1100.000000,250.000000,88.000000,"Light Garrison"}; -item31[] = {"Five_Minute_Chec",4,218,-300.000000,300.000000,-200.000000,350.000000,950.000000,"Five Minute Checks"}; -item32[] = {"Reinforcement_Ch",2,250,-300.000000,150.000000,-200.000000,200.000000,0.000000,"Reinforcement" \n "Check"}; -item33[] = {"CheckIfStatic",4,218,949.004028,175.000031,1050.000122,225.996094,92.000000,"CheckIfStatic"}; -item34[] = {"TwoMinuteChecks",4,218,-400.000000,300.000000,-300.000000,350.000000,940.000000,"TwoMinuteChecks"}; -item35[] = {"Two_Minute_Check",2,250,-400.000000,150.000000,-300.000000,200.000000,0.000000,"Two Minute Checks"}; -item36[] = {"SatchelPlant",4,218,900.000000,150.000000,1000.000000,200.000000,85.000000,"SatchelPlant"}; -item37[] = {"MinePlant",4,218,850.000000,125.000000,950.000000,175.000000,86.000000,"MinePlant"}; -item38[] = {"ArmStatics",4,218,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; -item39[] = {"True",8,218,750.000000,75.000000,850.000000,125.000000,0.000000,"True"}; -item40[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; -item41[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; -item42[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; -item43[] = {"Combat_END",4,4314,677.941040,379.111908,777.941040,429.111908,120.000000,"Combat END"}; -item44[] = {"",7,210,193.223969,683.948181,201.223969,691.948181,0.000000,""}; -item45[] = {"____FAKE____",9,0,0.000000,0.000000,0.000000,0.000000,0.000000,"____FAKE____"}; +item20[] = {"Leader_Cycle_Beg",3,4346,508.062805,372.976349,608.062805,422.976349,0.000000,"Leader" \n "Cycle" \n "Beginning"}; +item21[] = {"Combat",4,218,671.022705,372.075439,761.022705,422.075439,100.000000,"Combat"}; +item22[] = {"Combat_Brain",2,250,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; +item23[] = {"Combat_BEGIN",4,218,665.427063,321.335602,765.427063,371.335632,110.000000,"Combat BEGIN"}; +item24[] = {"Return",8,218,573.508484,193.429855,673.508484,243.429855,0.000000,"Return"}; +item25[] = {"Arty_Check",4,218,1100.000000,250.000000,1200.000000,300.000000,84.000000,"Arty Check"}; +item26[] = {"",7,210,1258.500000,21.000000,1266.500000,29.000000,0.000000,""}; +item27[] = {"Flank_Orders",4,218,1050.000000,225.000000,1150.000000,275.000000,105.000000,"Flank Orders"}; +item28[] = {"",7,210,296.000000,21.000000,304.000000,29.000000,0.000000,""}; +item29[] = {"Light_Garrison",4,218,1000.000000,200.000000,1100.000000,250.000000,88.000000,"Light Garrison"}; +item30[] = {"Five_Minute_Chec",4,218,-300.000000,300.000000,-200.000000,350.000000,950.000000,"Five Minute Checks"}; +item31[] = {"Reinforcement_Ch",2,250,-300.000000,150.000000,-200.000000,200.000000,0.000000,"Reinforcement" \n "Check"}; +item32[] = {"CheckIfStatic",4,218,949.004028,175.000031,1050.000122,225.996094,92.000000,"CheckIfStatic"}; +item33[] = {"TwoMinuteChecks",4,218,-400.000000,300.000000,-300.000000,350.000000,940.000000,"TwoMinuteChecks"}; +item34[] = {"Two_Minute_Check",2,250,-400.000000,150.000000,-300.000000,200.000000,0.000000,"Two Minute Checks"}; +item35[] = {"SatchelPlant",4,218,900.000000,150.000000,1000.000000,200.000000,85.000000,"SatchelPlant"}; +item36[] = {"MinePlant",4,218,850.000000,125.000000,950.000000,175.000000,86.000000,"MinePlant"}; +item37[] = {"ArmStatics",4,218,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; +item38[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; +item39[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; +item40[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; +item41[] = {"Combat_END",4,218,665.358398,270.160522,765.358276,320.160461,120.000000,"Combat END"}; +item42[] = {"",7,210,193.223969,683.948181,201.223969,691.948181,0.000000,""}; +item43[] = {"____FAKE____",9,0,0.000000,0.000000,0.000000,0.000000,0.000000,"____FAKE____"}; link0[] = {0,1}; link1[] = {0,3}; link2[] = {1,2}; @@ -56,9 +54,9 @@ link5[] = {4,7}; link6[] = {4,11}; link7[] = {4,12}; link8[] = {4,13}; -link9[] = {4,31}; -link10[] = {4,34}; -link11[] = {5,44}; +link9[] = {4,30}; +link10[] = {4,33}; +link11[] = {5,42}; link12[] = {7,8}; link13[] = {8,9}; link14[] = {8,10}; @@ -75,48 +73,44 @@ link24[] = {18,4}; link25[] = {19,4}; link26[] = {20,14}; link27[] = {20,21}; -link28[] = {20,22}; +link28[] = {20,23}; link29[] = {20,24}; -link30[] = {20,25}; -link31[] = {20,40}; -link32[] = {20,43}; -link33[] = {21,16}; -link34[] = {22,23}; -link35[] = {23,25}; -link36[] = {23,26}; -link37[] = {23,28}; -link38[] = {23,30}; -link39[] = {23,33}; -link40[] = {23,36}; -link41[] = {23,37}; -link42[] = {23,38}; -link43[] = {23,39}; -link44[] = {23,40}; -link45[] = {23,42}; -link46[] = {24,23}; -link47[] = {25,16}; -link48[] = {26,27}; -link49[] = {27,29}; -link50[] = {28,27}; -link51[] = {29,16}; -link52[] = {30,27}; -link53[] = {31,32}; -link54[] = {32,18}; -link55[] = {33,27}; -link56[] = {34,35}; -link57[] = {35,18}; -link58[] = {36,27}; -link59[] = {37,27}; -link60[] = {38,27}; -link61[] = {39,27}; -link62[] = {40,6}; -link63[] = {41,27}; -link64[] = {42,27}; -link65[] = {43,27}; -link66[] = {44,6}; -link67[] = {45,41}; -globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,397.512909,965.388550,735.301025,-75.390381,580,828,1}; -window[] = {2,-1,-1,-32180,-32000,983,-1125,-380,29,3,598}; +link30[] = {20,38}; +link31[] = {20,41}; +link32[] = {21,22}; +link33[] = {22,24}; +link34[] = {22,25}; +link35[] = {22,27}; +link36[] = {22,29}; +link37[] = {22,32}; +link38[] = {22,35}; +link39[] = {22,36}; +link40[] = {22,37}; +link41[] = {22,38}; +link42[] = {22,40}; +link43[] = {23,22}; +link44[] = {24,16}; +link45[] = {25,26}; +link46[] = {26,28}; +link47[] = {27,26}; +link48[] = {28,16}; +link49[] = {29,26}; +link50[] = {30,31}; +link51[] = {31,18}; +link52[] = {32,26}; +link53[] = {33,34}; +link54[] = {34,18}; +link55[] = {35,26}; +link56[] = {36,26}; +link57[] = {37,26}; +link58[] = {38,6}; +link59[] = {39,26}; +link60[] = {40,26}; +link61[] = {41,16}; +link62[] = {42,6}; +link63[] = {43,39}; +globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,-40.222034,1276.762329,743.056030,-272.837708,1146,884,1}; +window[] = {2,-1,-1,-32000,-32000,994,235,980,40,3,1164}; *//*%FSM*/ class FSM { @@ -132,7 +126,6 @@ class FSM "private _leader = leader _group;" \n "private _curUnits = (units _group);" \n "" \n - "" \n ""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links @@ -177,8 +170,10 @@ class FSM "private _MineList = [];" \n "private _StartingBehavior = behaviour _leader;" \n "private _ehList = [];" \n + "private _suppression = 0;" \n "" \n "_group setVariable [""VCM_SQUADFSM"", _thisFSM, VCM_DEBUG]; // Script handle, global if debug is on" \n + "VcmAI_ActiveList pushBackUnique _this;" \n "" \n "_group call VCM_fnc_ArtyManage;" \n "private _isskilldisabled = _Group getVariable ""VCM_Skilldisable"";" \n @@ -293,7 +288,7 @@ class FSM /*%FSM*/ class Five_Minute_Chec { - itemno = 31; + itemno = 30; priority = 950.000000; to="Reinforcement_Ch"; precondition = /*%FSM*/""/*%FSM*/; @@ -304,7 +299,7 @@ class FSM /*%FSM*/ class TwoMinuteChecks { - itemno = 34; + itemno = 33; priority = 940.000000; to="Two_Minute_Check"; precondition = /*%FSM*/""/*%FSM*/; @@ -322,7 +317,8 @@ class FSM condition=/*%FSM*/"((units _group) findIf {isPlayer _x} != -1) || " \n "{_Group getvariable [""Vcm_Disable"",false]} || " \n "{(((units _Group) findIf {alive _x}) isEqualTo -1)} || " \n - "{!(side _group in VCM_SIDEENABLED)}"/*%FSM*/; + "{!(side _group in VCM_SIDEENABLED)} ||" \n + "{!(VCM_ActivateAI)}"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -508,14 +504,24 @@ class FSM "{" \n " _situation = ""READY"";" \n "};" \n - ""/*%FSM*/; + "" \n + "if (_situation == ""CQC"" && {isNull _nearestEnemy || {_leader distance2D _nearestEnemy > 175}}) then " \n + "{" \n + " _situation == ""READY"";" \n + " _group enableAttack false;" \n + " _CurUnits disableAI ""AUTOCOMBAT"";" \n + " if (_CurUnits findIf {behaviour _x == ""COMBAT""} != -1) then " \n + " {" \n + " {_x setBehaviour ""AWARE""} forEach _CurUnits;" \n + " };" \n + "};"/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links { /*%FSM*/ class Exit_Cond { - itemno = 40; + itemno = 38; priority = 700.000000; to="Exit_FSM_1"; precondition = /*%FSM*/""/*%FSM*/; @@ -526,7 +532,7 @@ class FSM /*%FSM*/ class Combat_END { - itemno = 43; + itemno = 41; priority = 120.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -553,7 +559,7 @@ class FSM /*%FSM*/ class Combat_BEGIN { - itemno = 24; + itemno = 23; priority = 110.000000; to="Combat_Brain"; precondition = /*%FSM*/""/*%FSM*/; @@ -568,7 +574,7 @@ class FSM /*%FSM*/ class Combat { - itemno = 22; + itemno = 21; priority = 100.000000; to="Combat_Brain"; precondition = /*%FSM*/""/*%FSM*/; @@ -596,22 +602,11 @@ class FSM /*%FSM*/ class Return { - itemno = 25; - priority = 0.000000; - to="Return"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/""/*%FSM*/; - action=/*%FSM*/""/*%FSM*/; - }; - /*%FSM*/ - /*%FSM*/ - class Continue2Return - { - itemno = 21; + itemno = 24; priority = 0.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"true"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -622,7 +617,7 @@ class FSM class Combat_Brain { name = "Combat_Brain"; - itemno = 23; + itemno = 22; init = /*%FSM*/"private _t = time;" \n "private _Wait = 3;" \n "" \n @@ -632,6 +627,8 @@ class FSM " _nearestEnemy = _leader call VCM_fnc_ClstEmy; " \n "};" \n "" \n + "_suppression = _group call VCM_fnc_GroupGetSuppression;" \n + "" \n "if (_nearestEnemy distance _leader <= 150 && _situation != ""CQC"" && _situation != ""BREAKING"") then " \n "{" \n " _situation = ""CQC"";" \n @@ -659,7 +656,7 @@ class FSM /*%FSM*/ class Exit_Cond { - itemno = 40; + itemno = 38; priority = 700.000000; to="Exit_FSM_1"; precondition = /*%FSM*/""/*%FSM*/; @@ -670,7 +667,7 @@ class FSM /*%FSM*/ class Flank_Orders { - itemno = 28; + itemno = 27; priority = 105.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -691,7 +688,7 @@ class FSM /*%FSM*/ class CheckIfStatic { - itemno = 33; + itemno = 32; priority = 92.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -764,7 +761,7 @@ class FSM /*%FSM*/ class ArmStatics { - itemno = 38; + itemno = 37; priority = 91.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -779,7 +776,7 @@ class FSM /*%FSM*/ class Light_Garrison { - itemno = 30; + itemno = 29; priority = 88.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -813,7 +810,7 @@ class FSM /*%FSM*/ class MinePlant { - itemno = 37; + itemno = 36; priority = 86.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -844,7 +841,7 @@ class FSM /*%FSM*/ class SatchelPlant { - itemno = 36; + itemno = 35; priority = 85.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -865,7 +862,7 @@ class FSM /*%FSM*/ class Arty_Check { - itemno = 26; + itemno = 25; priority = 84.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -887,7 +884,7 @@ class FSM /*%FSM*/ class Clear_Building { - itemno = 42; + itemno = 40; priority = 50.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; @@ -901,25 +898,14 @@ class FSM "_BackbkC8 = time;"/*%FSM*/; }; /*%FSM*/ - /*%FSM*/ - class True - { - itemno = 39; - priority = 0.000000; - to="Return"; - precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"true"/*%FSM*/; - action=/*%FSM*/"if (VCM_Debug) then {systemchat ""VCOM: CONTINUE"";};"/*%FSM*/; - }; - /*%FSM*/ /*%FSM*/ class Return { - itemno = 25; + itemno = 24; priority = 0.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"true"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -930,7 +916,7 @@ class FSM class Reinforcement_Ch { name = "Reinforcement_Ch"; - itemno = 32; + itemno = 31; init = /*%FSM*/"if !(_Group getVariable [""VCM_TOUGHSQUAD"", false]) then {_Group call VCM_fnc_RqstReinforce};" \n "_BackbkC3 = time;"/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; @@ -954,7 +940,7 @@ class FSM class Two_Minute_Check { name = "Two_Minute_Check"; - itemno = 35; + itemno = 34; init = /*%FSM*/"_BackbkCC4 = time;"/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links @@ -977,7 +963,7 @@ class FSM class ____FAKE____ { name = "____FAKE____"; - itemno = 45; + itemno = 43; init = /*%FSM*/""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links @@ -985,7 +971,7 @@ class FSM /*%FSM*/ class MOVE_UP { - itemno = 41; + itemno = 39; priority = 104.000000; to="Return"; precondition = /*%FSM*/""/*%FSM*/; diff --git a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm new file mode 100644 index 0000000..d3927ef --- /dev/null +++ b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm @@ -0,0 +1,418 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"START",0,250,75.331299,-78.655457,165.331299,-28.655457,0.000000,"START"}; +item1[] = {"EXIT_CHECKS",4,218,75.378906,-169.575836,165.378906,-119.575844,90.000000,"EXIT" \n "CHECKS"}; +item2[] = {"TRUE",8,218,-37.326294,-78.338959,52.673706,-28.338959,0.000000,"TRUE"}; +item3[] = {"EXIT",1,250,181.850510,-172.492142,271.850525,-122.492157,0.000000,"EXIT"}; +item4[] = {"CHECK_SUPPRESSIO",2,250,-37.794777,-170.197464,52.205238,-120.197456,0.000000,"CHECK" \n "SUPPRESSION"}; +item5[] = {"_",-1,250,-107.927109,-146.077637,0.000000,-146.077637,0.000000,""}; +item6[] = {"UP",8,218,-219.143295,-290.917419,-129.143295,-240.917435,10.000000,"UP"}; +item7[] = {"MIDDLE",4,218,-128.628998,-290.745880,-38.628998,-240.745880,20.000000,"MIDDLE"}; +item8[] = {"DOWN",4,218,53.077332,-290.569855,143.077332,-240.569855,30.000000,"DOWN"}; +item9[] = {"CQC",4,4314,-308.165314,-290.831512,-218.165314,-240.831512,80.000000,"CQC"}; +item10[] = {"PINNED",4,218,143.853180,-290.668243,233.853180,-240.668243,40.000000,"PINNED"}; +item11[] = {"TIMER",2,250,-37.913712,-394.222229,52.086319,-344.222229,0.000000,"TIMER"}; +item12[] = {"EXIT_TIMER",4,218,-37.505798,-290.169312,52.494202,-240.169312,1.000000,"EXIT" \n "TIMER"}; +item13[] = {"DO_NOTHING",8,218,-34.893127,-485.660553,55.106873,-435.660553,0.000000,"DO" \n "NOTHING"}; +item14[] = {"VCOM_SUPPRESSION",-1,250,-249.497925,-207.929138,-99.160645,83.022034,0.000000,"VCOM SUPPRESSION" \n "" \n "//TODO - INSERT INFO"}; +version=1; +class LayoutItems +{ + class Item5 + { + class ItemInfo + { + FontFace="Arial"; + FontHeight=10; + lStyle=1; + }; + }; + class Item14 + { + class ItemInfo + { + FontFace="Arial"; + FontHeight=10; + lStyle=1; + Align=0; + }; + }; +}; +link0[] = {0,1}; +link1[] = {0,2}; +link2[] = {1,3}; +link3[] = {2,4}; +link4[] = {4,1}; +link5[] = {4,6}; +link6[] = {4,7}; +link7[] = {4,8}; +link8[] = {4,9}; +link9[] = {4,10}; +link10[] = {6,11}; +link11[] = {7,11}; +link12[] = {8,11}; +link13[] = {9,11}; +link14[] = {10,11}; +link15[] = {11,12}; +link16[] = {11,13}; +link17[] = {12,4}; +link18[] = {13,11}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-479.895294,240.639130,537.254700,-607.855713,521,828,1}; +window[] = {2,-1,-1,-1,-1,895,-1150,-476,178,3,539}; +*//*%FSM*/ +class FSM +{ + fsmName = "fn_UNITSUPPRESSION"; + class States + { + /*%FSM*/ + class START + { + name = "START"; + itemno = 0; + init = /*%FSM*/"private _unit = _this;" \n + "private _group = group _unit;" \n + "private _startingPos = unitPos _unit;" \n + "private _suppression = getSuppression _unit;" \n + "private _dead = isNil ""_suppression"";"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class EXIT_CHECKS + { + itemno = 1; + priority = 90.000000; + to="EXIT"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_dead || // Unit is dead (getSuppression is null)" \n + "{!isNull objectParent _unit} || // Unit is inside a vehicle" \n + "{isPlayer _unit} || // Is a player" \n + "{!local _unit} || // Not local" \n + "{!((side _group) in VCM_SIDEENABLED)} || // Not in an enabled side" \n + "{_group getVariable [""Vcm_Disable"", false]} // Group has VCOM disabled"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class TRUE + { + itemno = 2; + priority = 0.000000; + to="CHECK_SUPPRESSIO"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"true"/*%FSM*/; + action=/*%FSM*/"private _slowSuppression = _suppression;" \n + "private _t = time;" \n + "private _velocity = [0,0,0];" \n + "private _weaponType = """";" \n + "private _unitPos = """";" \n + "private _weaponLow = false;" \n + "private _animationState = """";" \n + "private _groupSuppression = 0;" \n + "private _exitNow = false;" \n + "private _situation = """";" \n + "private _isGarrisoned = false;" \n + "" \n + "if VCM_DEBUG then {_unit spawn VCM_fnc_SuppressionDebug};" \n + "" \n + "_unit setVariable [""VCMSUPPRESSION"", _thisFSM, VCM_DEBUG];"/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class EXIT + { + name = "EXIT"; + itemno = 3; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class CHECK_SUPPRESSIO + { + name = "CHECK_SUPPRESSIO"; + itemno = 4; + init = /*%FSM*/"_group = group _unit;" \n + "_suppression = getSuppression _unit;" \n + "_velocity = velocity _unit;" \n + "_stance = stance _unit;" \n + "_groupSuppression = _group call VCM_fnc_FSMGetSuppression;" \n + "_situation = (_group call VCM_fnc_CheckSituation);" \n + "_isGarrison = (_situation == ""GARRISONED"" || _situation == ""LGARRISON"");" \n + "_dead = isNil ""_suppression"";" \n + "" \n + "" \n + "switch (currentWeapon _unit) do" \n + "{" \n + " case """": {""nothing""};" \n + " case (primaryWeapon _unit): {_weaponType = ""primary""};" \n + " case (handgunWeapon _unit): {_weaponType = ""handgun""};" \n + " case (secondaryWeapon _unit): {_weaponType = ""secondary""};" \n + "};" \n + "_weaponLowered = weaponLowered _unit;" \n + "" \n + "if !(_dead) then" \n + "{" \n + " // Apply group average suppression" \n + " if (!isNil ""_suppression"" && {_groupSuppression - 0.2 > _suppression}) then" \n + " {" \n + " _unit setSuppression _groupSuppression;" \n + " _suppression = _groupSuppression;" \n + " };" \n + " " \n + " // Update slowSuppression" \n + " if (_suppression > _slowSuppression) then " \n + " {" \n + " _slowSuppression = _suppression" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class EXIT_CHECKS + { + itemno = 1; + priority = 90.000000; + to="EXIT"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_dead || // Unit is dead (getSuppression is null)" \n + "{!isNull objectParent _unit} || // Unit is inside a vehicle" \n + "{isPlayer _unit} || // Is a player" \n + "{!local _unit} || // Not local" \n + "{!((side _group) in VCM_SIDEENABLED)} || // Not in an enabled side" \n + "{_group getVariable [""Vcm_Disable"", false]} // Group has VCOM disabled"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class CQC + { + itemno = 9; + priority = 80.000000; + to="TIMER"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(_group call VCM_fnc_CheckSituation) == ""CQC"" || behaviour _unit == ""STEALTH"""/*%FSM*/; + action=/*%FSM*/"_unit setUnitPosWeak ""AUTO"";" \n + "" \n + "_t = time;"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class PINNED + { + itemno = 10; + priority = 40.000000; + to="TIMER"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_slowSuppression > 0.9" \n + ""/*%FSM*/; + action=/*%FSM*/"if ((_stance == ""STAND"" || _stance == ""CROUCH"") && !(_isGarrison)) then " \n + "{" \n + " if (_stance == ""STAND"") then " \n + " {" \n + " //Standing" \n + " switch _weaponType do" \n + " {" \n + " case ""primary"": {_unit playMoveNow ""AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon""};" \n + " case ""handgun"": {_unit playMoveNow ""AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon""};" \n + " };" \n + " " \n + " }" \n + " else" \n + " {" \n + " // Crouched" \n + " switch _weaponType do" \n + " {" \n + " case ""primary"": {_unit playMoveNow ""AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon""};" \n + " case ""handgun"": {_unit playMoveNow ""AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon""};" \n + " };" \n + " };" \n + " _unit setUnitPos ""DOWN"";" \n + "}" \n + "else" \n + "{" \n + " _unit setUnitPos ""DOWN"";" \n + "};" \n + "/*" \n + "_animationState = animationState _unit;" \n + "if !(_animationState == ""AadjPpneMstpSrasWrflDdown"" || _animationState == ""AadjPpneMstpSrasWpstDdown"") then" \n + "{" \n + " // Go as low as possible" \n + " switch _weaponType do" \n + " {" \n + " case ""primary"": {_unit playMoveNow ""AadjPpneMstpSrasWrflDdown""};" \n + " case ""sidearm"": {_unit playMoveNow ""AadjPpneMstpSrasWpstDdown""};" \n + " };" \n + " " \n + " //return to normal animation" \n + " _unit spawn " \n + " {" \n + " sleep 5 + random 10;" \n + " private _animationState = animationState _this;" \n + " if (_animationState == ""AadjPpneMstpSrasWrflDdown"") then" \n + " {" \n + " _this playMoveNow ""AmovPpneMevaSlowWrflDf"";" \n + " };" \n + " if (_animationState == ""AadjPpneMstpSrasWpstDdown"") then" \n + " {" \n + " _this playMoveNow ""AmovPpneMrunSlowWpstDf"";" \n + " }" \n + " };" \n + "};" \n + "*/" \n + "" \n + "_t = time;"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class DOWN + { + itemno = 8; + priority = 30.000000; + to="TIMER"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_slowSuppression > 0.5"/*%FSM*/; + action=/*%FSM*/"if ((_stance == ""STAND"" || _stance == ""CROUCH"") && !(_isGarrison)) then " \n + "{" \n + " if (_stance == ""STAND"") then " \n + " {" \n + " //Standing" \n + " switch _weapontype do" \n + " {" \n + " case ""primary"": " \n + " {" \n + " if (random 10 > 3) then" \n + " {" \n + " // Dive forward" \n + " _unit playMoveNow ""AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon"";" \n + " }" \n + " else" \n + " {" \n + " // Fall to the side" \n + " _unit playMoveNow selectRandom [""AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright"", ""AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft""];" \n + " _unit spawn {sleep 3 + random 3; _this playMoveNow ""AmovPpneMevaSlowWrflDf""};" \n + " };" \n + " };" \n + " case ""handgun"": {_unit playMoveNow ""AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon""};" \n + " };" \n + " " \n + " }" \n + " else" \n + " {" \n + " // Crouched" \n + " switch _weapontype do" \n + " {" \n + " case ""primary"": {_unit playMoveNow ""AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon""};" \n + " case ""handgun"": {_unit playMoveNow ""AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon""};" \n + " };" \n + " };" \n + " _unit setUnitPos ""DOWN"";" \n + "}" \n + "else" \n + "{" \n + " _unit setUnitPos ""DOWN""" \n + "};" \n + "" \n + "_t = time;"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class MIDDLE + { + itemno = 7; + priority = 20.000000; + to="TIMER"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_slowSuppression > 0.1"/*%FSM*/; + action=/*%FSM*/"if (_stance == ""STAND"" && !(_isGarrison)) then " \n + "{" \n + " switch _weapontype do" \n + " {" \n + " case ""primary"": " \n + " {" \n + " _unit playMoveNow selectRandom [""AmovPercMevaSrasWrflDfr_AmovPknlMstpSrasWrflDnon"", ""AmovPercMevaSrasWrflDf_AmovPknlMstpSrasWrflDnon"", ""AmovPercMevaSrasWrflDfl_AmovPknlMstpSrasWrflDnon""]" \n + " };" \n + " };" \n + " _unit setUnitPos ""Middle"";" \n + "}" \n + "else" \n + "{" \n + " _unit setUnitPos ""Middle""" \n + "};" \n + "" \n + "_t = time;"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class UP + { + itemno = 6; + priority = 10.000000; + to="TIMER"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"true"/*%FSM*/; + action=/*%FSM*/"if (random 10 > 7 && {!(_isGarrison)} && {_stance == ""PRONE""} && {_weaponType == ""primary""}) then " \n + "{" \n + " _unit playMoveNow ""AmovPpneMstpSrasWrflDnon_AmovPercMsprSlowWrflDf"";" \n + "};" \n + "" \n + "_unit setUnitPos ""UP"";" \n + "" \n + "_t = time;"/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class TIMER + { + name = "TIMER"; + itemno = 11; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class EXIT_TIMER + { + itemno = 12; + priority = 1.000000; + to="CHECK_SUPPRESSIO"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(_t < time - 2 || _exitNow) &&" \n + "{lifestate _unit != ""INCAPACITATED""}"/*%FSM*/; + action=/*%FSM*/"_slowSuppression = _slowSuppression - 0.05;"/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class DO_NOTHING + { + itemno = 13; + priority = 0.000000; + to="TIMER"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"true"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="START"; + finalStates[] = + { + "EXIT", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf b/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf index d971d31..0a998fa 100644 --- a/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf +++ b/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf @@ -18,6 +18,9 @@ if (isNil "_closestEnemy") then _closestEnemy = _leader findNearestEnemy _leader; }; +// Zeus placed waypoints +if (!isNil {(waypoints _Group) select 1} && {!(((waypoints _Group) select 1) in VCM_IGNOREWAYPOINTS)}) exitWith {}; + if (_leader distance _closestEnemy < 150) then { for "_i" from ((count waypoints _group) - 1) to 1 do {deleteWaypoint [_group, _i]}; diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf index 301d54a..1ccd9e9 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf @@ -21,7 +21,7 @@ if (isNil "_order") then {_order = true}; if (isNil "_script") then {_script = "Nil";}; private _position = [0,0,0]; -if (isNil "_object" || {isNil "_list"}) exitWith {_closestObject = [0,0,0];_closestObject}; +if (isNil "_object" || {isNil "_list"}) exitWith {_closestObject = objNull;_closestObject}; switch (TypeName _object) do { @@ -54,5 +54,5 @@ _distanceArray sort _order; private _closestObject = ((_distanceArray select 0) select 1); -if (isNil "_closestObject") then {_closestObject = [0,0,0];}; +if (isNil "_closestObject") then {_closestObject = objNull;}; _closestObject \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf b/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf index 7ebcbc9..a6f880d 100644 --- a/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf +++ b/Vcom/Functions/VCM_Functions/situation/fn_SetSituation.sqf @@ -15,7 +15,7 @@ params ["_grp", "_newSituation"]; private _fsm = _grp getVariable "VCM_SQUADFSM"; -if !(isNull _fsm) then +if !(isNil "_fsm") then { _fsm setFSMVariable ["_situation", _newSituation]; }; \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/actions/fn_AIHIT.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf similarity index 95% rename from Vcom/Functions/VCM_Functions/actions/fn_AIHIT.sqf rename to Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf index d0b37a1..2c7e0ac 100644 --- a/Vcom/Functions/VCM_Functions/actions/fn_AIHIT.sqf +++ b/Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf @@ -23,19 +23,21 @@ Meant to be called from a "HIT" eventhandler */ params ["_unit", "_source", "_damage", "_instigator"]; + +/* if ( !(isNull objectParent _unit) || {(missionNamespace getvariable ["ace_medical_enableUnconsciousnessAI", 0]) != 0} //Check if ACE3 makes AI go unconscious ) exitWith {}; - -//Lay down -if (unitPos _unit isEqualTo "AUTO") then +*/ +if (_damage > 0.1 && !(lifestate _unit isEqualTo "INCAPACITATED")) then { - _unit setUnitPos "DOWN"; - _unit spawn {sleep 30; _this setUnitPos "AUTO";}; + [_unit, 0.5] call VCM_fnc_AddSuppressionNow; }; +// Deprecated +/* if (VCM_RAGDOLL && {_damage > 0.1} && {!(lifestate _unit isEqualTo "INCAPACITATED")} && {VCM_RAGDOLLCHC > (random 100)}) then { @@ -107,3 +109,4 @@ if (VCM_RAGDOLL && {_damage > 0.1} && {!(lifestate _unit isEqualTo "INCAPACITATE }; }; }; +*/ \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_AddSuppression.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_AddSuppression.sqf new file mode 100644 index 0000000..2ea6467 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/suppression/fn_AddSuppression.sqf @@ -0,0 +1,21 @@ +/* + Author: Freddo + + Description: + Sets a units current suppression + + Parameter(s): + 0: OBJECT - Unit to set + 1: NUMBER - Suppression to add, can be negative + + Returns: + NUMBER - New suppression level +*/ + +params ["_unit", "_toAdd"]; + +private _newSuppression = ((getSuppression _unit + _toAdd) min 1); + +_unit setSuppression _newSuppression; + +_newSuppression \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_AddSuppressionNow.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_AddSuppressionNow.sqf new file mode 100644 index 0000000..212b26f --- /dev/null +++ b/Vcom/Functions/VCM_Functions/suppression/fn_AddSuppressionNow.sqf @@ -0,0 +1,27 @@ +/* + Author: Freddo + + Description: + Sets a units current suppression, and also forces it to perform suppression routines immediately. + + Parameter(s): + 0: OBJECT - Unit to set + 1: NUMBER - Suppression to add, can be negative + + Returns: + NUMBER - New suppression level +*/ + +params ["_unit", "_toAdd"]; + +private _newSuppression = ((getSuppression _unit + _toAdd) min 1); + +_unit setSuppression _newSuppression; +private _fsm = _unit getVariable "VCOMSUPPRESSION"; + +if !(isNil "_fsm") then +{ + _fsm setFSMVariable ["_exitNow", true]; // Skips usual 1 second timer and instead runs immediately +}; + +_newSuppression \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_FSMGetSuppression.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_FSMGetSuppression.sqf new file mode 100644 index 0000000..429fcdd --- /dev/null +++ b/Vcom/Functions/VCM_Functions/suppression/fn_FSMGetSuppression.sqf @@ -0,0 +1,22 @@ +/* + Author: Freddo + + Description: + Gets the current group suppression from FSM + + Parameter(s): + GROUP - Group to check + + Returns: + NUMBER - Groups current suppression level +*/ + +private _group = _this; +private _rtrn = 0; + +private _fsm = (_group getVariable "VCM_SQUADFSM"); +if (!isNil "_fsm" && {typeName _fsm != "SCRIPT"}) then +{ + _rtrn = _fsm getFSMVariable ["_suppression", 0]; +}; +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_GetSuppression.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_GetSuppression.sqf new file mode 100644 index 0000000..2963557 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/suppression/fn_GetSuppression.sqf @@ -0,0 +1,21 @@ +/* + Author: Freddo + + Description: + Gets units slowSuppression value. + + Parameter(s): + OBJECT - Unit to set + + Returns: + NUMBER - Slow Suppression value +*/ + +private _unit = _this; +private _fsm = _unit getVariable "VCMSUPPRESSION"; +private _rtrn = -1; +if (isNil "_fsm" || {completedFSM _fsm}) exitWith {_rtrn}; + +_rtrn = _fsm getFSMVariable ["_slowSuppression", -1]; + +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_GroupGetSuppression.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_GroupGetSuppression.sqf new file mode 100644 index 0000000..c5dc242 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/suppression/fn_GroupGetSuppression.sqf @@ -0,0 +1,28 @@ +/* + Author: Freddo + + Description: + Gets the current average suppression of a group + + Parameter(s): + GROUP - Group to check + + Returns: + NUMBER - Average suppression +*/ + +private _group = _this; +private _units = units _group; +private _rtrn = 0; +private _totalSuppression = 0; + +{ + if (!isNull _x && alive _x) then + { + _totalSuppression = (_totalSuppression + getSuppression _x); + }; +} forEach _units; + +_rtrn = _totalSuppression / ({!isNull _x && alive _x} count _units); + +_rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf new file mode 100644 index 0000000..0b64492 --- /dev/null +++ b/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf @@ -0,0 +1,32 @@ +/* + Author: Freddo, inspired by TPWCAS + + Description: + Spawns a hovering ball above the target that changes colour depending on the amount of suppression. + Script needs to be spawned + + Parameter(s): + OBJECT - Unit +*/ + +private _unit = _this; +private _ball = "Sign_Sphere25cm_Geometry_F" createVehicleLocal [random 5, random 5, random 5]; +private _suppression = 0; +_ball attachTo [_unit, [0, 0, 2]]; + +while {alive _unit && isNull objectParent _unit} do +{ + sleep 2.5; + _suppression = _unit call VCM_fnc_GetSuppression; + + switch true do + { + case (_suppression > 0.9): {_ball setObjectTexture [0, "#(argb,8,8,3)color(0,0,1,1)"]}; + case (_suppression > 0.5): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,0,0,1)"]}; + case (_suppression > 0.1): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,1,0,1)"]}; + case (group _unit call VCM_fnc_CheckSituation == "CQC"): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,0,1,1)"]}; + default {_ball setObjectTexture [0, "#(argb,8,8,3)color(0,1,0,1)"]}; + }; +}; + +deleteVehicle _ball; \ No newline at end of file diff --git a/Vcom/Functions/VcomAI_DefaultSettings.sqf b/Vcom/Functions/VcomAI_DefaultSettings.sqf index 96b62b6..0cd73f8 100644 --- a/Vcom/Functions/VcomAI_DefaultSettings.sqf +++ b/Vcom/Functions/VcomAI_DefaultSettings.sqf @@ -11,6 +11,7 @@ */ Vcm_ActivateAI = true; //Set this to false to disable VcomAI. It can be set to true at any time to re-enable Vcom AI +VCM_SUPPRESSACTIVE = true; //Set to false to disable AI suppression system VcmAI_ActiveList = []; //Leave this alone. VCM_AIMagLimit = 2; //Number of mags remaining before AI looks for ammo. VCM_Debug = false; //Enable debug mode. diff --git a/Vcom/VcomInit.sqf b/Vcom/VcomInit.sqf index d30267c..8653710 100644 --- a/Vcom/VcomInit.sqf +++ b/Vcom/VcomInit.sqf @@ -1,3 +1,4 @@ +if (!isNil "VCMINITHANDLE" && {!scriptDone VCMINITHANDLE}) exitWith {}; //Global actions compiles Vcm_PMN = compileFinal "(_this select 0) playMoveNow (_this select 1);"; @@ -24,32 +25,60 @@ VCOM_MINEARRAY = []; [] spawn VCM_fnc_MineMonitor; [] spawn VCM_fnc_HANDLECURATORS; -[] spawn +VCMINITHANDLE = [] spawn { waitUntil {time > 2}; sleep 2; //Begin Artillery function created by Rydygier - https://forums.bohemia.net/forums/topic/159152-fire-for-effect-the-god-of-war-smart-simple-ai-artillery/ - if (VCM_FFEARTILLERY) then {nul = [] spawn (compile preprocessFileLineNumbers "Vcom\RYD_FFE\FFE.sqf");VCM_ARTYENABLE = false;}; + if (VCM_FFEARTILLERY) then {VCM_FFEHANDLE = [] spawn (compile preprocessFileLineNumbers "Vcom\RYD_FFE\FFE.sqf");VCM_ARTYENABLE = false;}; [] spawn VCM_fnc_AIDRIVEBEHAVIOR; //Below is loop to check for new AI spawning in to be added to the list while {true} do { - if (Vcm_ActivateAI) then + waitUntil {Vcm_ActivateAI}; + { + private _fsmHandle = _x getVariable "VCM_SQUADFSM"; + if + ( + (isNil {completedFSM _fsmHandle} || {completedFSM _fsmHandle}) && + {local _x} && + {simulationEnabled (leader _x)} && + {(units _x) findIf {isPlayer _x} == -1} && + {(leader _x) isKindOf "Man"} + ) then { - if (local _x && {simulationEnabled (leader _x)} && {(units _x) findIf {isPlayer _x} == -1} && {(leader _x) isKindOf "Man"}) then + private _grp = _x; + if !(((units _grp) findIf {alive _x}) isEqualTo -1) then { - private _Grp = _x; - if !(((units _Grp) findIf {alive _x}) isEqualTo -1) then - { - _x call VCM_fnc_SquadExc; - }; + _grp spawn VCM_fnc_SQUADBEH; }; - } foreach allGroups; + }; + } foreach allGroups; + + if (VCM_SUPPRESSACTIVE) then + { + { + private _fsmHandle = _x getVariable "VCMSUPPRESSION"; + if + ( + (isNil {completedFSM _fsmHandle} || {completedFSM _fsmHandle}) && + {isNull objectParent _x} && + {local _x} && + {simulationEnabled _x} && + {!isPlayer _x} && + {_x isKindOf "Man"} && + {alive _x} + ) then + { + _x spawn VCM_fnc_UNITSUPPRESSION; + }; + } foreach allUnits; }; - sleep 10; + + sleep 15; }; }; \ No newline at end of file diff --git a/Vcom/cfgFunctions.hpp b/Vcom/cfgFunctions.hpp index 0ee702f..cdf6131 100644 --- a/Vcom/cfgFunctions.hpp +++ b/Vcom/cfgFunctions.hpp @@ -42,6 +42,12 @@ class VCOM { ext = ".fsm"; }; + + // unit spawn VCM_fnc_UNITSUPPRESSION + class UNITSUPPRESSION + { + ext = ".fsm"; + }; }; // Generic functions @@ -103,9 +109,6 @@ class VCOM // [unitToRearm, rearmLocation] spawn VCM_fnc_ActRearm class ActRearm {}; - // [unit, source, damage, instigator] call VCM_fnc_AIHIT; - class AIHIT {}; - // [group] call VCM_fnc_ArmStatics; class ArmStatics {}; @@ -258,7 +261,7 @@ class VCOM // unit call VCM_fnc_HasRadio; class HasRadio {}; - // group call VCM_fnc_GroupHasRadio + // group call VCM_fnc_GroupHasRadio; class GroupHasRadio {}; // [object, searchRadius, precision, sortingOrder] call VCM_fnc_Heights; @@ -272,6 +275,27 @@ class VCOM class Suppression { file = "Vcom\Functions\VCM_Functions\suppression"; + + // [unit, number] call VCM_fnc_AddSuppression; + class AddSuppression {}; + + // [unit, number] call VCM_fnc_AddSuppressionNow; + class AddSuppressionNow {}; + + // [unit, source, damage, instigator] call VCM_fnc_AIHIT; + class AIHIT {}; + + // _group call VCM_fnc_FSMGetSuppression; + class FSMGetSuppression {}; + + // _unit call VCM_fnc_GetSuppression + class GetSuppression {}; + + // _group call VCM_fnc_GroupGetSuppression; + class GroupGetSuppression {}; + + // _unit spawn VCM_fnc_SuppressionDebug; + class SuppressionDebug {}; }; }; From e4cf0d2c511cbc71dfd338843f59db591b692c7c Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Sun, 17 Mar 2019 13:43:46 +0100 Subject: [PATCH 18/30] Fixed VCOM not running on headless/zeus Fixes #90 --- Vcom/VcomInit.sqf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Vcom/VcomInit.sqf b/Vcom/VcomInit.sqf index 8653710..ffb5005 100644 --- a/Vcom/VcomInit.sqf +++ b/Vcom/VcomInit.sqf @@ -7,7 +7,12 @@ Vcm_PAN = compileFinal "(_this select 0) playActionNow (_this select 1);"; VCM_PublicScript = compileFinal "[] call (_this select 0);"; VCM_ServerAsk = compileFinal "if (isServer) then {publicvariable (_this select 0);};"; -if !(isServer) exitWith {}; +if +!( + isServer || + !hasInterface || + allCurators findIf {getAssignedCuratorUnit _x == player} == -1 +) exitWith {}; //Parameters [] call compile preprocessFileLineNumbers "Vcom\Functions\VCOMAI_DefaultSettings.sqf"; //Load default settings From 8e19ab753aa45009806bc62bab67f80e0ceac346 Mon Sep 17 00:00:00 2001 From: genesis92x Date: Tue, 19 Mar 2019 01:27:43 -0600 Subject: [PATCH 19/30] Optimizations Some little optimizations and fixing for HC support. Will be looking into performance tests and HC tests. I like the organization system :+1: Thank's for the hard work! --- Vcom/FSMS/fn_SQUADBEH.fsm | 14 +++++----- Vcom/FSMS/fn_UNITSUPPRESSION.fsm | 28 +++++++++---------- .../VCM_Functions/actions/fn_HealSelf.sqf | 5 +--- .../VCM_Functions/fn_MedicalHandler.sqf | 4 +-- .../VCM_Functions/situation/fn_SetCQC.sqf | 2 +- Vcom/VcomInit.sqf | 9 +++++- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index de9d4a7..a18a922 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -1,4 +1,4 @@ -/*%FSM*/ +/*%FSM*/ /*%FSM*/ /* item0[] = {"Begin_State",0,250,50.000000,700.000000,150.000000,750.000000,0.000000,"Begin State"}; @@ -21,7 +21,7 @@ item16[] = {"Return",2,250,250.000000,200.000000,350.000000,250.000000,0.000000, item17[] = {"Full_Check",2,250,-100.000000,150.000000,0.000000,200.000000,0.000000,"Full Check"}; item18[] = {"Continue2StartPo",8,218,0.000000,300.000000,100.000000,350.000000,0.000000,"Continue2StartPoint"}; item19[] = {"Continue2StartPo",4,218,100.000000,300.000000,200.000000,350.000000,0.000000,"Continue2StartPoint2"}; -item20[] = {"Leader_Cycle_Beg",3,4346,508.062805,372.976349,608.062805,422.976349,0.000000,"Leader" \n "Cycle" \n "Beginning"}; +item20[] = {"Leader_Cycle_Beg",3,250,508.062805,372.976349,608.062805,422.976349,0.000000,"Leader" \n "Cycle" \n "Beginning"}; item21[] = {"Combat",4,218,671.022705,372.075439,761.022705,422.075439,100.000000,"Combat"}; item22[] = {"Combat_Brain",2,250,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; item23[] = {"Combat_BEGIN",4,218,665.427063,321.335602,765.427063,371.335632,110.000000,"Combat BEGIN"}; @@ -38,7 +38,7 @@ item33[] = {"TwoMinuteChecks",4,218,-400.000000,300.000000,-300.000000,350.00000 item34[] = {"Two_Minute_Check",2,250,-400.000000,150.000000,-300.000000,200.000000,0.000000,"Two Minute Checks"}; item35[] = {"SatchelPlant",4,218,900.000000,150.000000,1000.000000,200.000000,85.000000,"SatchelPlant"}; item36[] = {"MinePlant",4,218,850.000000,125.000000,950.000000,175.000000,86.000000,"MinePlant"}; -item37[] = {"ArmStatics",4,218,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; +item37[] = {"ArmStatics",4,4314,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; item38[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; item39[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; item40[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; @@ -109,8 +109,8 @@ link60[] = {40,26}; link61[] = {41,16}; link62[] = {42,6}; link63[] = {43,39}; -globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,-40.222034,1276.762329,743.056030,-272.837708,1146,884,1}; -window[] = {2,-1,-1,-32000,-32000,994,235,980,40,3,1164}; +globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,112.155273,1383.402954,801.801514,-178.812408,1146,884,1}; +window[] = {2,-1,-1,-1,-1,1084,130,875,130,3,1164}; *//*%FSM*/ class FSM { @@ -259,7 +259,7 @@ class FSM to="Simulation_Pause"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"!(simulationEnabled _leader) ||" \n - "(behaviour _leader == ""CARELESS"")"/*%FSM*/; + "(behaviour _leader isEqualTo ""CARELESS"")"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ @@ -381,7 +381,7 @@ class FSM to="Start_Point"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"simulationEnabled (leader _group) ||" \n - "(behaviour _leader == ""CARELESS"")"/*%FSM*/; + "(behaviour _leader isEqualTo ""CARELESS"")"/*%FSM*/; action=/*%FSM*/""/*%FSM*/; }; /*%FSM*/ diff --git a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm index d3927ef..2fa0e03 100644 --- a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm +++ b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm @@ -1,4 +1,4 @@ -/*%FSM*/ +/*%FSM*/ /*%FSM*/ /* item0[] = {"START",0,250,75.331299,-78.655457,165.331299,-28.655457,0.000000,"START"}; @@ -9,13 +9,13 @@ item4[] = {"CHECK_SUPPRESSIO",2,250,-37.794777,-170.197464,52.205238,-120.197456 item5[] = {"_",-1,250,-107.927109,-146.077637,0.000000,-146.077637,0.000000,""}; item6[] = {"UP",8,218,-219.143295,-290.917419,-129.143295,-240.917435,10.000000,"UP"}; item7[] = {"MIDDLE",4,218,-128.628998,-290.745880,-38.628998,-240.745880,20.000000,"MIDDLE"}; -item8[] = {"DOWN",4,218,53.077332,-290.569855,143.077332,-240.569855,30.000000,"DOWN"}; -item9[] = {"CQC",4,4314,-308.165314,-290.831512,-218.165314,-240.831512,80.000000,"CQC"}; +item8[] = {"DOWN",4,4314,53.077332,-290.569855,143.077332,-240.569855,30.000000,"DOWN"}; +item9[] = {"CQC",4,218,-308.165314,-290.831512,-218.165314,-240.831512,80.000000,"CQC"}; item10[] = {"PINNED",4,218,143.853180,-290.668243,233.853180,-240.668243,40.000000,"PINNED"}; item11[] = {"TIMER",2,250,-37.913712,-394.222229,52.086319,-344.222229,0.000000,"TIMER"}; item12[] = {"EXIT_TIMER",4,218,-37.505798,-290.169312,52.494202,-240.169312,1.000000,"EXIT" \n "TIMER"}; item13[] = {"DO_NOTHING",8,218,-34.893127,-485.660553,55.106873,-435.660553,0.000000,"DO" \n "NOTHING"}; -item14[] = {"VCOM_SUPPRESSION",-1,250,-249.497925,-207.929138,-99.160645,83.022034,0.000000,"VCOM SUPPRESSION" \n "" \n "//TODO - INSERT INFO"}; +item14[] = {"VCOM_SUPPRESSION",-1,250,-275.000000,-150.000000,-125.000000,150.000000,0.000000,"VCOM SUPPRESSION" \n "" \n "//TODO - INSERT INFO"}; version=1; class LayoutItems { @@ -58,8 +58,8 @@ link15[] = {11,12}; link16[] = {11,13}; link17[] = {12,4}; link18[] = {13,11}; -globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-479.895294,240.639130,537.254700,-607.855713,521,828,1}; -window[] = {2,-1,-1,-1,-1,895,-1150,-476,178,3,539}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-379.981201,140.035645,285.095734,-597.236328,521,884,1}; +window[] = {2,-1,-1,-1,-1,769,52,726,52,3,539}; *//*%FSM*/ class FSM { @@ -200,7 +200,7 @@ class FSM priority = 80.000000; to="TIMER"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"(_group call VCM_fnc_CheckSituation) == ""CQC"" || behaviour _unit == ""STEALTH"""/*%FSM*/; + condition=/*%FSM*/"(_group call VCM_fnc_CheckSituation) isEqualTo ""CQC"" || behaviour _unit isEqualTo ""STEALTH"""/*%FSM*/; action=/*%FSM*/"_unit setUnitPosWeak ""AUTO"";" \n "" \n "_t = time;"/*%FSM*/; @@ -215,9 +215,9 @@ class FSM precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_slowSuppression > 0.9" \n ""/*%FSM*/; - action=/*%FSM*/"if ((_stance == ""STAND"" || _stance == ""CROUCH"") && !(_isGarrison)) then " \n + action=/*%FSM*/"if ((_stance isEqualTo ""STAND"" || _stance isEqualTo ""CROUCH"") && !(_isGarrison)) then " \n "{" \n - " if (_stance == ""STAND"") then " \n + " if (_stance isEqualTo ""STAND"") then " \n " {" \n " //Standing" \n " switch _weaponType do" \n @@ -281,9 +281,9 @@ class FSM to="TIMER"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_slowSuppression > 0.5"/*%FSM*/; - action=/*%FSM*/"if ((_stance == ""STAND"" || _stance == ""CROUCH"") && !(_isGarrison)) then " \n + action=/*%FSM*/"if ((_stance isEqualTo ""STAND"" || _stance isEqualTo ""CROUCH"") && !(_isGarrison)) then " \n "{" \n - " if (_stance == ""STAND"") then " \n + " if (_stance isEqualTo ""STAND"") then " \n " {" \n " //Standing" \n " switch _weapontype do" \n @@ -333,7 +333,7 @@ class FSM to="TIMER"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"_slowSuppression > 0.1"/*%FSM*/; - action=/*%FSM*/"if (_stance == ""STAND"" && !(_isGarrison)) then " \n + action=/*%FSM*/"if (_stance isEqualTo ""STAND"" && !(_isGarrison)) then " \n "{" \n " switch _weapontype do" \n " {" \n @@ -360,7 +360,7 @@ class FSM to="TIMER"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"true"/*%FSM*/; - action=/*%FSM*/"if (random 10 > 7 && {!(_isGarrison)} && {_stance == ""PRONE""} && {_weaponType == ""primary""}) then " \n + action=/*%FSM*/"if (random 10 > 7 && {!(_isGarrison)} && {_stance isEqualTo ""PRONE""} && {_weaponType isEqualTo ""primary""}) then " \n "{" \n " _unit playMoveNow ""AmovPpneMstpSrasWrflDnon_AmovPercMsprSlowWrflDf"";" \n "};" \n @@ -390,7 +390,7 @@ class FSM to="CHECK_SUPPRESSIO"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_t < time - 2 || _exitNow) &&" \n - "{lifestate _unit != ""INCAPACITATED""}"/*%FSM*/; + "{!(lifestate _unit isEqualTo ""INCAPACITATED"")}"/*%FSM*/; action=/*%FSM*/"_slowSuppression = _slowSuppression - 0.05;"/*%FSM*/; }; /*%FSM*/ diff --git a/Vcom/Functions/VCM_Functions/actions/fn_HealSelf.sqf b/Vcom/Functions/VCM_Functions/actions/fn_HealSelf.sqf index 8148b04..8157d17 100644 --- a/Vcom/Functions/VCM_Functions/actions/fn_HealSelf.sqf +++ b/Vcom/Functions/VCM_Functions/actions/fn_HealSelf.sqf @@ -12,16 +12,13 @@ BOOLEAN - If unit able to treat self: TRUE, else FALSE */ -private "_rtrn"; +private _rtrn = false; if (alive _this && {"FirstAidKit" in items _this} && {{_x > 0.25} count (getAllHitPointsDamage _this select 2) != 0}) then { _this action ["HealSoldierSelf", _this]; if VCM_DEBUG then {systemChat format ["VCOM: %1 healing self", _this]}; _rtrn = true; -} else -{ - _rtrn = false; }; _rtrn \ No newline at end of file diff --git a/Vcom/Functions/VCM_Functions/fn_MedicalHandler.sqf b/Vcom/Functions/VCM_Functions/fn_MedicalHandler.sqf index fd18b2d..ef90f3e 100644 --- a/Vcom/Functions/VCM_Functions/fn_MedicalHandler.sqf +++ b/Vcom/Functions/VCM_Functions/fn_MedicalHandler.sqf @@ -16,7 +16,7 @@ if !(VCM_MEDICALACTIVE) exitWith {}; params ["_group"]; private _units = units _group; private _medics = _group call VCM_fnc_RMedics; -if (isNil "_medics") then {private _medics = []}; +if (isNil "_medics") then {_medics = []}; { if (isNull objectParent _x && {damage _x != 0}) then @@ -27,7 +27,7 @@ if (isNil "_medics") then {private _medics = []}; sleep random 10; if !(_unit call VCM_fnc_HealSelf) then // VCM_fnc_HealSelf returns false if unit unable to heal self { - if (count _medicArr == 0) exitWith {}; + if (count _medicArr isEqualTo 0) exitWith {}; private _medic = selectRandom _medicArr; if !(_medic getVariable ["VCM_MBUSY", false]) then // Check if medic is busy { diff --git a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf index 4051d0a..e67abaf 100644 --- a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf +++ b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf @@ -27,7 +27,7 @@ _group spawn //Handle to eventually exit script sleep (15 + random 10); private _situation = _group call VCM_fnc_CheckSituation; private _leader = leader _group; - if (_units findIf {alive _x} == -1 || _situation isEqualTo "BREAKING") exitWith + if (_units findIf {alive _x} isEqualTo -1 || _situation isEqualTo "BREAKING") exitWith { _group enableAttack false; {_x doFollow _leader} forEach _units; diff --git a/Vcom/VcomInit.sqf b/Vcom/VcomInit.sqf index ffb5005..ce8cd9c 100644 --- a/Vcom/VcomInit.sqf +++ b/Vcom/VcomInit.sqf @@ -7,12 +7,17 @@ Vcm_PAN = compileFinal "(_this select 0) playActionNow (_this select 1);"; VCM_PublicScript = compileFinal "[] call (_this select 0);"; VCM_ServerAsk = compileFinal "if (isServer) then {publicvariable (_this select 0);};"; + +/* +Reasoning for removal: It's best to have Vcom running for ALL clients. Vcom was designed from the ground up to ONLY run on AI LOCAL to the machine running the commands. This enables HC support, hotswapping of AI between CPUS, and better consistency over several hours with multiple disconnects/changes of HC's or AI owners. + if !( isServer || !hasInterface || allCurators findIf {getAssignedCuratorUnit _x == player} == -1 ) exitWith {}; +*/ //Parameters [] call compile preprocessFileLineNumbers "Vcom\Functions\VCOMAI_DefaultSettings.sqf"; //Load default settings @@ -52,7 +57,7 @@ VCMINITHANDLE = [] spawn (isNil {completedFSM _fsmHandle} || {completedFSM _fsmHandle}) && {local _x} && {simulationEnabled (leader _x)} && - {(units _x) findIf {isPlayer _x} == -1} && + {(units _x) findIf {isPlayer _x} isEqualTo -1} && {(leader _x) isKindOf "Man"} ) then { @@ -64,6 +69,8 @@ VCMINITHANDLE = [] spawn }; } foreach allGroups; + + //This system is definitely a cool idea - however running an FSM per AI is going to be heavy. I would like to take a further look into performance impact. if (VCM_SUPPRESSACTIVE) then { { From 30a627e06d60d5eabb63e5dd5741d6f50718fe38 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Mar 2019 17:13:06 +0100 Subject: [PATCH 20/30] CQC movement bugfixes Getpos direction and distance were mixed up, added additional exit conditions, made it not overwrite Zeus placed waypoints --- Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf | 8 +++++--- Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf b/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf index 0a998fa..79d43ac 100644 --- a/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf +++ b/Vcom/Functions/VCM_Functions/movement/fn_CQCMovement.sqf @@ -19,9 +19,10 @@ if (isNil "_closestEnemy") then }; // Zeus placed waypoints -if (!isNil {(waypoints _Group) select 1} && {!(((waypoints _Group) select 1) in VCM_IGNOREWAYPOINTS)}) exitWith {}; +if !((waypoints _group) findIf {_x in VCM_IGNOREWAYPOINTS} isEqualTo -1) exitWith {}; +if (_group getVariable ["VCM_NOFLANK", false]) exitWith {}; -if (_leader distance _closestEnemy < 150) then +if (_leader distance _closestEnemy < 120) then { for "_i" from ((count waypoints _group) - 1) to 1 do {deleteWaypoint [_group, _i]}; @@ -57,7 +58,8 @@ if (_leader distance _closestEnemy < 150) then { // Fall back private _direction = _closestEnemy getDir _leader; - private _wp = _group addWaypoint [position _leader getPos [_direction, 200], 25]; + private _position = position _leader getPos [200, _direction]; + private _wp = _group addWaypoint [_position, 25]; _wp setWaypointSpeed "FULL"; _wp setWaypointStatements ["this", "[group this call VCM_fnc_CQCMovement]"]; _group setCurrentWaypoint _wp; diff --git a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf index 4051d0a..4c9e9aa 100644 --- a/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf +++ b/Vcom/Functions/VCM_Functions/situation/fn_SetCQC.sqf @@ -33,7 +33,7 @@ _group spawn //Handle to eventually exit script {_x doFollow _leader} forEach _units; }; private _nearestEnemy = _leader findNearestEnemy _leader; - if (!isNull _nearestEnemy && {_nearestEnemy distance _leader > 200}) exitWith + if (!isNull _nearestEnemy && {_nearestEnemy distance _leader > 120}) exitWith { [_group, "READY"] call VCM_fnc_SetSituation; _group enableAttack false; From 01cfa34af1155b41a4f27f89cd6c1eebe5fb0f82 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Mar 2019 17:17:58 +0100 Subject: [PATCH 21/30] Removed unneeded parameter _script parameter didn't appear to do anything, may re-add when it does something --- Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf b/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf index 1ccd9e9..a60fe5e 100644 --- a/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf +++ b/Vcom/Functions/VCM_Functions/scanning/fn_ClstObj.sqf @@ -9,16 +9,14 @@ 0: ARRAY - Array to search for closest object 1: OBJECT - Object to search away from 2: (Optional): BOOLEAN - Defines order to sort array. True: Ascending, false, descending - 3: (Optional): ??? Returns: OBJECT */ -params ["_list","_object","_order","_script"]; +params ["_list","_object","_order"]; if (isNil "_order") then {_order = true}; -if (isNil "_script") then {_script = "Nil";}; private _position = [0,0,0]; if (isNil "_object" || {isNil "_list"}) exitWith {_closestObject = objNull;_closestObject}; @@ -32,7 +30,6 @@ switch (TypeName _object) do }; private _distanceArray = []; -if (typeName _list isEqualTo "SCALAR") then {systemChat format ["_script: %1",_script];}; private _newObjectDistance = 0; { if !(isNil "_x") then From ff4fe95f7e1f3ae5ffedaa735a849e93e6c386fa Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Mar 2019 17:18:27 +0100 Subject: [PATCH 22/30] Force units to "AUTO" unitpos in CQC --- Vcom/FSMS/fn_UNITSUPPRESSION.fsm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm index 2fa0e03..cffe165 100644 --- a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm +++ b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm @@ -58,7 +58,7 @@ link15[] = {11,12}; link16[] = {11,13}; link17[] = {12,4}; link18[] = {13,11}; -globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-379.981201,140.035645,285.095734,-597.236328,521,884,1}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-479.895294,240.639130,537.254700,-607.855713,521,884,1}; window[] = {2,-1,-1,-1,-1,769,52,726,52,3,539}; *//*%FSM*/ class FSM @@ -201,7 +201,7 @@ class FSM to="TIMER"; precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_group call VCM_fnc_CheckSituation) isEqualTo ""CQC"" || behaviour _unit isEqualTo ""STEALTH"""/*%FSM*/; - action=/*%FSM*/"_unit setUnitPosWeak ""AUTO"";" \n + action=/*%FSM*/"_unit setUnitPos ""AUTO"";" \n "" \n "_t = time;"/*%FSM*/; }; From 6f9e532daef838cafccdde0db9a641674d59cc37 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Mar 2019 17:19:32 +0100 Subject: [PATCH 23/30] if "is", rather than if "isn't" More future proof and better readability --- Vcom/FSMS/fn_SQUADBEH.fsm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index a18a922..b7145d1 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -23,7 +23,7 @@ item18[] = {"Continue2StartPo",8,218,0.000000,300.000000,100.000000,350.000000,0 item19[] = {"Continue2StartPo",4,218,100.000000,300.000000,200.000000,350.000000,0.000000,"Continue2StartPoint2"}; item20[] = {"Leader_Cycle_Beg",3,250,508.062805,372.976349,608.062805,422.976349,0.000000,"Leader" \n "Cycle" \n "Beginning"}; item21[] = {"Combat",4,218,671.022705,372.075439,761.022705,422.075439,100.000000,"Combat"}; -item22[] = {"Combat_Brain",2,250,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; +item22[] = {"Combat_Brain",2,4346,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; item23[] = {"Combat_BEGIN",4,218,665.427063,321.335602,765.427063,371.335632,110.000000,"Combat BEGIN"}; item24[] = {"Return",8,218,573.508484,193.429855,673.508484,243.429855,0.000000,"Return"}; item25[] = {"Arty_Check",4,218,1100.000000,250.000000,1200.000000,300.000000,84.000000,"Arty Check"}; @@ -109,8 +109,8 @@ link60[] = {40,26}; link61[] = {41,16}; link62[] = {42,6}; link63[] = {43,39}; -globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,112.155273,1383.402954,801.801514,-178.812408,1146,884,1}; -window[] = {2,-1,-1,-1,-1,1084,130,875,130,3,1164}; +globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,504.794159,1408.691162,1043.839111,-121.934799,1146,884,1}; +window[] = {2,-1,-1,-1,-1,1162,208,953,208,3,1164}; *//*%FSM*/ class FSM { @@ -629,7 +629,7 @@ class FSM "" \n "_suppression = _group call VCM_fnc_GroupGetSuppression;" \n "" \n - "if (_nearestEnemy distance _leader <= 150 && _situation != ""CQC"" && _situation != ""BREAKING"") then " \n + "if (_nearestEnemy distance _leader <= 100 && {_situation == ""READY"" || _situation == ""FLANKING"" || _situation == ""REINFORCE""}) then " \n "{" \n " _situation = ""CQC"";" \n " [_group, _nearestEnemy] call VCM_fnc_SetCQC;" \n From fa8b17ed012c627e9af65503bb8fc840008fd983 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Mar 2019 18:01:33 +0100 Subject: [PATCH 24/30] Revamped fn_ClearBuilding Now checks if player is inside of the closest building, not within a certain distance. Also changed method for finding closest position(s). --- .../actions/fn_ClearBuilding.sqf | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/actions/fn_ClearBuilding.sqf b/Vcom/Functions/VCM_Functions/actions/fn_ClearBuilding.sqf index d0d622c..4de308b 100644 --- a/Vcom/Functions/VCM_Functions/actions/fn_ClearBuilding.sqf +++ b/Vcom/Functions/VCM_Functions/actions/fn_ClearBuilding.sqf @@ -15,38 +15,42 @@ params ["_group","_enemy"]; -private _nBuildingLst = nearestObjects [_enemy, ["House", "Building"], 25]; -if (count _nBuildingLst < 1) exitWith {}; +private _building = (nearestObject [_enemy, "House"]); + +private _buildingPositions = [_building] call BIS_fnc_buildingPositions; + +// Not enterable +if (count _buildingPositions < 3) exitWith {}; + +private _bbr = boundingBoxReal _building; // TODO: Replace 'boundingBoxReal' with '0 BoundingBoxReal' on devbranch +private _p1 = _bbr select 0; +private _p2 = _bbr select 1; +// Check if unit is inside of the closest building +if +!( + _enemy inArea + [ + getPos _building, // Center of building + (abs ((_p2 select 0) - (_p1 select 0)) / 2), // Maximum Width / 2 + (abs ((_p2 select 1) - (_p1 select 1)) / 2), // Maximum Length / 2 + getDir _building, // Building facing + true // Is rectangular + ] +) exitWith {}; if VCM_Debug then {systemChat format ["VCOM: %1 clearing out %2", _group, _enemy]}; -private _buildingPositions = []; +private _finalPositions = []; +_finalPositions = (_buildingPositions inAreaArray [getPosATL _enemy, 3, 3, 0, false, 1.5]); +if (_finalPositions isEqualTo []) then { - if (count ([_x] call BIS_fnc_buildingPositions) > 3) then {_buildingPositions pushback _x;}; -} foreach _nBuildingLst; - -if (count _buildingPositions < 1) exitWith {}; -private _finalSel = [_buildingPositions,_enemy,true,"Clear0"] call VCM_fnc_ClstObj; -private _tempA = _finalSel call BIS_fnc_buildingPositions; -private _tempB = _tempA; - -//Filter down the closest positions -private _unitPosition = getposATL _enemy; -private _acceptableRange = _unitPosition select 2; -{ - if ((_x select 2) < (_acceptableRange - 1) || (_x select 2) > (_acceptableRange + 1)) then - { - _tempA deleteAt _forEachIndex; - }; - -} foreach _tempA; - -if (_tempA isEqualTo []) then {_tempA = _tempB;}; - -private _clstP = [_tempA,_enemy,true,"Clear1"] call VCM_fnc_ClstObj; + // Settle for the three closest + private _temp = [_buildingPositions, [], {_x distance _enemy}] call BIS_fnc_sortBy; + for "_i" from 0 to 2 do {_finalPositions pushBack (_temp select _i)}; +}; { doStop _x; - _x doMove _clstP; + _x doMove selectRandom _finalPositions; } foreach (units _group); \ No newline at end of file From 60a926ea527f747259c0b4605abeb0b7aa031364 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Tue, 19 Mar 2019 22:11:39 +0100 Subject: [PATCH 25/30] disableAI syntax error Were applying to an array instead of each entry inside of it. --- Vcom/FSMS/fn_SQUADBEH.fsm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index b7145d1..1242d17 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -1,4 +1,4 @@ -/*%FSM*/ +/*%FSM*/ /*%FSM*/ /* item0[] = {"Begin_State",0,250,50.000000,700.000000,150.000000,750.000000,0.000000,"Begin State"}; @@ -21,9 +21,9 @@ item16[] = {"Return",2,250,250.000000,200.000000,350.000000,250.000000,0.000000, item17[] = {"Full_Check",2,250,-100.000000,150.000000,0.000000,200.000000,0.000000,"Full Check"}; item18[] = {"Continue2StartPo",8,218,0.000000,300.000000,100.000000,350.000000,0.000000,"Continue2StartPoint"}; item19[] = {"Continue2StartPo",4,218,100.000000,300.000000,200.000000,350.000000,0.000000,"Continue2StartPoint2"}; -item20[] = {"Leader_Cycle_Beg",3,250,508.062805,372.976349,608.062805,422.976349,0.000000,"Leader" \n "Cycle" \n "Beginning"}; +item20[] = {"Leader_Cycle_Beg",3,4346,508.062805,372.976349,608.062805,422.976349,0.000000,"Leader" \n "Cycle" \n "Beginning"}; item21[] = {"Combat",4,218,671.022705,372.075439,761.022705,422.075439,100.000000,"Combat"}; -item22[] = {"Combat_Brain",2,4346,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; +item22[] = {"Combat_Brain",2,250,870.650879,303.704590,970.650879,353.704590,0.000000,"Combat Brain"}; item23[] = {"Combat_BEGIN",4,218,665.427063,321.335602,765.427063,371.335632,110.000000,"Combat BEGIN"}; item24[] = {"Return",8,218,573.508484,193.429855,673.508484,243.429855,0.000000,"Return"}; item25[] = {"Arty_Check",4,218,1100.000000,250.000000,1200.000000,300.000000,84.000000,"Arty Check"}; @@ -38,7 +38,7 @@ item33[] = {"TwoMinuteChecks",4,218,-400.000000,300.000000,-300.000000,350.00000 item34[] = {"Two_Minute_Check",2,250,-400.000000,150.000000,-300.000000,200.000000,0.000000,"Two Minute Checks"}; item35[] = {"SatchelPlant",4,218,900.000000,150.000000,1000.000000,200.000000,85.000000,"SatchelPlant"}; item36[] = {"MinePlant",4,218,850.000000,125.000000,950.000000,175.000000,86.000000,"MinePlant"}; -item37[] = {"ArmStatics",4,4314,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; +item37[] = {"ArmStatics",4,218,800.000000,100.000000,900.000000,150.000000,91.000000,"ArmStatics"}; item38[] = {"Exit_Cond",4,218,675.000000,475.000000,775.000000,525.000000,700.000000,"Exit Cond"}; item39[] = {"MOVE_UP",4,218,1150.000000,275.000000,1250.000000,325.000000,104.000000,"MOVE UP"}; item40[] = {"Clear_Building",4,218,1200.000000,300.000000,1300.000000,350.000000,50.000000,"Clear Building"}; @@ -109,8 +109,8 @@ link60[] = {40,26}; link61[] = {41,16}; link62[] = {42,6}; link63[] = {43,39}; -globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,504.794159,1408.691162,1043.839111,-121.934799,1146,884,1}; -window[] = {2,-1,-1,-1,-1,1162,208,953,208,3,1164}; +globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,241.991943,1000.233398,975.413818,-52.121349,1089,884,1}; +window[] = {2,-1,-1,-32000,-32000,1029,86,831,75,3,1107}; *//*%FSM*/ class FSM { @@ -509,7 +509,9 @@ class FSM "{" \n " _situation == ""READY"";" \n " _group enableAttack false;" \n - " _CurUnits disableAI ""AUTOCOMBAT"";" \n + " {" \n + " _x disableAI ""AUTOCOMBAT"";" \n + " } forEach _CurUnits;" \n " if (_CurUnits findIf {behaviour _x == ""COMBAT""} != -1) then " \n " {" \n " {_x setBehaviour ""AWARE""} forEach _CurUnits;" \n From 29ae8f1f574fce955d3a96d49f2f64cf47c3f812 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Wed, 20 Mar 2019 08:52:02 +0100 Subject: [PATCH 26/30] Debug ball coloured purple while in CQC takes priority --- .../Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf index 0b64492..0b37cd6 100644 --- a/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf +++ b/Vcom/Functions/VCM_Functions/suppression/fn_SuppressionDebug.sqf @@ -21,10 +21,10 @@ while {alive _unit && isNull objectParent _unit} do switch true do { + case (group _unit call VCM_fnc_CheckSituation == "CQC"): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,0,1,1)"]}; case (_suppression > 0.9): {_ball setObjectTexture [0, "#(argb,8,8,3)color(0,0,1,1)"]}; case (_suppression > 0.5): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,0,0,1)"]}; case (_suppression > 0.1): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,1,0,1)"]}; - case (group _unit call VCM_fnc_CheckSituation == "CQC"): {_ball setObjectTexture [0, "#(argb,8,8,3)color(1,0,1,1)"]}; default {_ball setObjectTexture [0, "#(argb,8,8,3)color(0,1,0,1)"]}; }; }; From f591b21c4556d57ff6408b166b20d85868976444 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Wed, 20 Mar 2019 09:16:00 +0100 Subject: [PATCH 27/30] Suppression tweaks AI should now properly exit "CQC" type situation. Suppression takes longer to lower. "Group" suppression now properly works. --- Vcom/FSMS/fn_SQUADBEH.fsm | 17 ++++++++--------- Vcom/FSMS/fn_UNITSUPPRESSION.fsm | 18 +++++++++--------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Vcom/FSMS/fn_SQUADBEH.fsm b/Vcom/FSMS/fn_SQUADBEH.fsm index 1242d17..7e8da18 100644 --- a/Vcom/FSMS/fn_SQUADBEH.fsm +++ b/Vcom/FSMS/fn_SQUADBEH.fsm @@ -109,8 +109,8 @@ link60[] = {40,26}; link61[] = {41,16}; link62[] = {42,6}; link63[] = {43,39}; -globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,241.991943,1000.233398,975.413818,-52.121349,1089,884,1}; -window[] = {2,-1,-1,-32000,-32000,1029,86,831,75,3,1107}; +globals[] = {0.000000,0,0,0,0,640,480,2,624,6316128,1,-176.980988,1007.904419,903.668335,-58.167114,610,828,1}; +window[] = {2,-1,-1,-181,-1,1125,-1206,-461,171,3,628}; *//*%FSM*/ class FSM { @@ -491,6 +491,11 @@ class FSM init = /*%FSM*/"private _t = time;" \n "private _Wait = 5;" \n "" \n + "private _nearestEnemy = _leader findNearestEnemy _leader;" \n + "if (isNull _nearestEnemy) then" \n + "{" \n + " _nearestEnemy = _leader call VCM_fnc_ClstEmy; " \n + "};" \n "" \n "private _index = currentWaypoint _Group;" \n "private _WaypointIs = waypointType [_Group,_index];" \n @@ -507,7 +512,7 @@ class FSM "" \n "if (_situation == ""CQC"" && {isNull _nearestEnemy || {_leader distance2D _nearestEnemy > 175}}) then " \n "{" \n - " _situation == ""READY"";" \n + " _situation = ""READY"";" \n " _group enableAttack false;" \n " {" \n " _x disableAI ""AUTOCOMBAT"";" \n @@ -623,12 +628,6 @@ class FSM init = /*%FSM*/"private _t = time;" \n "private _Wait = 3;" \n "" \n - "private _nearestEnemy = _leader findNearestEnemy _leader;" \n - "if (isNull _nearestEnemy) then" \n - "{" \n - " _nearestEnemy = _leader call VCM_fnc_ClstEmy; " \n - "};" \n - "" \n "_suppression = _group call VCM_fnc_GroupGetSuppression;" \n "" \n "if (_nearestEnemy distance _leader <= 100 && {_situation == ""READY"" || _situation == ""FLANKING"" || _situation == ""REINFORCE""}) then " \n diff --git a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm index cffe165..48adf7f 100644 --- a/Vcom/FSMS/fn_UNITSUPPRESSION.fsm +++ b/Vcom/FSMS/fn_UNITSUPPRESSION.fsm @@ -1,4 +1,4 @@ -/*%FSM*/ +/*%FSM*/ /*%FSM*/ /* item0[] = {"START",0,250,75.331299,-78.655457,165.331299,-28.655457,0.000000,"START"}; @@ -9,11 +9,11 @@ item4[] = {"CHECK_SUPPRESSIO",2,250,-37.794777,-170.197464,52.205238,-120.197456 item5[] = {"_",-1,250,-107.927109,-146.077637,0.000000,-146.077637,0.000000,""}; item6[] = {"UP",8,218,-219.143295,-290.917419,-129.143295,-240.917435,10.000000,"UP"}; item7[] = {"MIDDLE",4,218,-128.628998,-290.745880,-38.628998,-240.745880,20.000000,"MIDDLE"}; -item8[] = {"DOWN",4,4314,53.077332,-290.569855,143.077332,-240.569855,30.000000,"DOWN"}; +item8[] = {"DOWN",4,218,53.077332,-290.569855,143.077332,-240.569855,30.000000,"DOWN"}; item9[] = {"CQC",4,218,-308.165314,-290.831512,-218.165314,-240.831512,80.000000,"CQC"}; item10[] = {"PINNED",4,218,143.853180,-290.668243,233.853180,-240.668243,40.000000,"PINNED"}; item11[] = {"TIMER",2,250,-37.913712,-394.222229,52.086319,-344.222229,0.000000,"TIMER"}; -item12[] = {"EXIT_TIMER",4,218,-37.505798,-290.169312,52.494202,-240.169312,1.000000,"EXIT" \n "TIMER"}; +item12[] = {"EXIT_TIMER",4,4314,-37.505798,-290.169312,52.494202,-240.169312,1.000000,"EXIT" \n "TIMER"}; item13[] = {"DO_NOTHING",8,218,-34.893127,-485.660553,55.106873,-435.660553,0.000000,"DO" \n "NOTHING"}; item14[] = {"VCOM_SUPPRESSION",-1,250,-275.000000,-150.000000,-125.000000,150.000000,0.000000,"VCOM SUPPRESSION" \n "" \n "//TODO - INSERT INFO"}; version=1; @@ -58,8 +58,8 @@ link15[] = {11,12}; link16[] = {11,13}; link17[] = {12,4}; link18[] = {13,11}; -globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-479.895294,240.639130,537.254700,-607.855713,521,884,1}; -window[] = {2,-1,-1,-1,-1,769,52,726,52,3,539}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-423.130829,414.361237,107.706512,-538.317017,1146,884,1}; +window[] = {2,-1,-1,-1,-1,769,53,727,52,3,1164}; *//*%FSM*/ class FSM { @@ -162,10 +162,10 @@ class FSM "if !(_dead) then" \n "{" \n " // Apply group average suppression" \n - " if (!isNil ""_suppression"" && {_groupSuppression - 0.2 > _suppression}) then" \n + " if (!isNil ""_suppression"" && {_groupSuppression - 0.3 > _suppression}) then" \n " {" \n - " _unit setSuppression _groupSuppression;" \n - " _suppression = _groupSuppression;" \n + " _unit setSuppression (_groupSuppression - 0.3);" \n + " _suppression = (_groupSuppression - 0.3);" \n " };" \n " " \n " // Update slowSuppression" \n @@ -391,7 +391,7 @@ class FSM precondition = /*%FSM*/""/*%FSM*/; condition=/*%FSM*/"(_t < time - 2 || _exitNow) &&" \n "{!(lifestate _unit isEqualTo ""INCAPACITATED"")}"/*%FSM*/; - action=/*%FSM*/"_slowSuppression = _slowSuppression - 0.05;"/*%FSM*/; + action=/*%FSM*/"_slowSuppression = _slowSuppression - (0.025 + random 0.025);"/*%FSM*/; }; /*%FSM*/ /*%FSM*/ From f9184dc3571377b0cdfc7d78a2ddd12463b118c9 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Wed, 20 Mar 2019 17:43:15 +0100 Subject: [PATCH 28/30] Tweaked AI hearing Added randomisation When gunshots are heard, go from "SAFE" to "AWARE" --- Vcom/Functions/VCM_Functions/fn_HearingAids.sqf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Vcom/Functions/VCM_Functions/fn_HearingAids.sqf b/Vcom/Functions/VCM_Functions/fn_HearingAids.sqf index 549a217..4b2ca55 100644 --- a/Vcom/Functions/VCM_Functions/fn_HearingAids.sqf +++ b/Vcom/Functions/VCM_Functions/fn_HearingAids.sqf @@ -60,7 +60,11 @@ if ((_timeShot + 20) < time) then if (count _snda > 0) then { - [_snda,_unit] remoteExec ["VCM_fnc_KnowAbout",0]; + [_snda,_unit, random 0.15 + 0.1, 0.5] remoteExec ["VCM_fnc_KnowAbout",0]; + { + if (behaviour _x isEqualTo "SAFE") then {_x setBehaviour "AWARE"}; + } foreach _snda; + }; _unit setVariable ["VCM_FTH",time]; From b6a90aedc7288f1292457c86c5fec3bacf2722b3 Mon Sep 17 00:00:00 2001 From: Freddo3000 Date: Wed, 20 Mar 2019 17:44:51 +0100 Subject: [PATCH 29/30] Reenabled some hit animations Reactions while prone were a bit lacking, so I reenabled rolling left/right --- .../VCM_Functions/suppression/fn_AIHIT.sqf | 44 +++---------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf b/Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf index 2c7e0ac..dd22b15 100644 --- a/Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf +++ b/Vcom/Functions/VCM_Functions/suppression/fn_AIHIT.sqf @@ -36,19 +36,11 @@ if (_damage > 0.1 && !(lifestate _unit isEqualTo "INCAPACITATED")) then [_unit, 0.5] call VCM_fnc_AddSuppressionNow; }; -// Deprecated -/* -if (VCM_RAGDOLL && {_damage > 0.1} && {!(lifestate _unit isEqualTo "INCAPACITATED")} && {VCM_RAGDOLLCHC > (random 100)}) then +if (!(lifestate _unit isEqualTo "INCAPACITATED") && {5 < (random 10)}) then { - if !(stance _unit isEqualTo "PRONE") then + if (stance _unit isEqualTo "PRONE") then { - //Ragdoll unit - _unit setUnconscious true; - _unit spawn {sleep 2;_this setUnconscious false;}; - } else { - //Apply animations instead of ragdoll when prone - //Find current weapon type private _currentWeapon = currentWeapon _unit; private _currentWeaponType = 0; @@ -62,19 +54,9 @@ if (VCM_RAGDOLL && {_damage > 0.1} && {!(lifestate _unit isEqualTo "INCAPACITATE //Rifle animations case 1: { - switch (floor random 3) do { - case 1: {_unit playMoveNow "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDl";}; //Roll left - case 2: {_unit playMoveNow "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDr";}; //Roll right - default - { - _unit playMoveNow "amovppnemstpsraswrfldnon_aadjppnemstpsraswrflddown"; //Go as low as possible - _unit spawn - { - sleep 4 + random 2; - //Return to normal - if (alive _this && {animationState _this isEqualTo "aadjppnemstpsraswrflddown"}) then {_this playMoveNow "aadjppnemstpsraswrflddown_amovppnemstpsraswrfldnon"}; - }; - }; + switch (floor random 2) do { + case 0: {_unit playMoveNow "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDl";}; //Roll left + case 1: {_unit playMoveNow "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDr";}; //Roll right }; }; @@ -82,18 +64,8 @@ if (VCM_RAGDOLL && {_damage > 0.1} && {!(lifestate _unit isEqualTo "INCAPACITATE case 2: { switch (floor random 3) do { - case 1: {_unit playMoveNow "amovppnemstpsraswpstdnon_amovppnemevaslowwpstdl";}; //Roll left - case 2: {_unit playMoveNow "amovppnemstpsraswpstdnon_amovppnemevaslowwpstdr";}; //Roll right - default - { - _unit playMoveNow "amovppnemstpsraswpstdnon_aadjppnemstpsraswpstddown"; //Go as low as possible - _unit spawn - { - sleep 4 + random 2; - //Return to normal - if (alive _this && {animationState _this isEqualTo "aadjppnemstpsraswpstddown"}) then {_this playMoveNow "aadjppnemstpsraswpstddown_amovppnemstpsraswpstdnon"}; - }; - }; + case 0: {_unit playMoveNow "amovppnemstpsraswpstdnon_amovppnemevaslowwpstdl";}; //Roll left + case 1: {_unit playMoveNow "amovppnemstpsraswpstdnon_amovppnemevaslowwpstdr";}; //Roll right }; }; @@ -103,10 +75,8 @@ if (VCM_RAGDOLL && {_damage > 0.1} && {!(lifestate _unit isEqualTo "INCAPACITATE switch (floor random 2) do { case 0: {_unit playMoveNow "amovppnemstpsoptwbindnon_amovppnemevasoptwbindl";}; //Roll left case 1: {_unit playMoveNow "amovppnemstpsoptwbindnon_amovppnemevasoptwbindr";}; //Roll right - default {}; }; }; }; }; }; -*/ \ No newline at end of file From 250eb842c89348f2ac45149733820f6b2ea3079e Mon Sep 17 00:00:00 2001 From: genesis92x Date: Mon, 25 Mar 2019 23:01:57 -0600 Subject: [PATCH 30/30] Update fn_RqstReinforce.sqf --- Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf b/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf index b8889ff..5b8037f 100644 --- a/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf +++ b/Vcom/Functions/VCM_Functions/actions/fn_RqstReinforce.sqf @@ -52,12 +52,12 @@ private _eligibleSquadsValue = 0; }; } forEach ([_leader, true, VCM_WARNDIST] call VCM_fnc_FriendlyGroupArray); -if (count _eligibleSquads == 0) exitWith {_rtrn}; +if (count _eligibleSquads isEqualTo 0) exitWith {_rtrn}; //Create waypoints { if !(_x call VCM_fnc_CheckSituation isEqualTo "REINFORCE") then { - private _leader == leader _x; + private _leader = leader _x; if VCM_DEBUG then {systemChat format ["VCOM: %1 moving to reinforce %2", _x, _group]}; private _wp = (_x addWaypoint [position _leader, 100]); _wp setWaypointSpeed "FULL";