From 2faccd2e4a0cdd2c11005b4a452beea68df7b774 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Wed, 14 Aug 2024 23:29:01 +0200 Subject: [PATCH 01/10] Ininitial --- addons/waypoint/$PBOPREFIX$ | 1 + addons/waypoint/CfgWaypoints.cfg | 13 ++ addons/waypoint/README.md | 8 ++ addons/waypoint/XEH_PREP.hpp | 2 + addons/waypoint/XEH_postInit.sqf | 1 + addons/waypoint/XEH_preInit.sqf | 7 + addons/waypoint/XEH_preStart.sqf | 2 + addons/waypoint/ZEN_CfgWaypointTypes.hpp | 7 + addons/waypoint/config.cpp | 19 +++ .../waypoint/functions/fnc_moveVehicleWp.sqf | 135 ++++++++++++++++++ .../waypoint/functions/script_component.hpp | 1 + addons/waypoint/script_component.hpp | 15 ++ addons/waypoint/stringtable.xml | 13 ++ 13 files changed, 224 insertions(+) create mode 100644 addons/waypoint/$PBOPREFIX$ create mode 100644 addons/waypoint/CfgWaypoints.cfg create mode 100644 addons/waypoint/README.md create mode 100644 addons/waypoint/XEH_PREP.hpp create mode 100644 addons/waypoint/XEH_postInit.sqf create mode 100644 addons/waypoint/XEH_preInit.sqf create mode 100644 addons/waypoint/XEH_preStart.sqf create mode 100644 addons/waypoint/ZEN_CfgWaypointTypes.hpp create mode 100644 addons/waypoint/config.cpp create mode 100644 addons/waypoint/functions/fnc_moveVehicleWp.sqf create mode 100644 addons/waypoint/functions/script_component.hpp create mode 100644 addons/waypoint/script_component.hpp create mode 100644 addons/waypoint/stringtable.xml diff --git a/addons/waypoint/$PBOPREFIX$ b/addons/waypoint/$PBOPREFIX$ new file mode 100644 index 0000000..bf3a558 --- /dev/null +++ b/addons/waypoint/$PBOPREFIX$ @@ -0,0 +1 @@ +z\afmf\addons\waypoint \ No newline at end of file diff --git a/addons/waypoint/CfgWaypoints.cfg b/addons/waypoint/CfgWaypoints.cfg new file mode 100644 index 0000000..accdc2c --- /dev/null +++ b/addons/waypoint/CfgWaypoints.cfg @@ -0,0 +1,13 @@ +class CfgWaypoints { + class AF_Waypoints { + displayName = "ArmaForces"; + class Move_vehicle { + displayName = CSTRING(Vehicle_Move_Name); + file = QPATHTOF(functions\fnc_moveVehicleWp.sqf); + icon = "\a3\3DEN\Data\CfgWaypoints\Move_ca.paa"; + tooltip = CSTRING(Vehicle_Move_Description); + }; + + + }; +}; diff --git a/addons/waypoint/README.md b/addons/waypoint/README.md new file mode 100644 index 0000000..1885812 --- /dev/null +++ b/addons/waypoint/README.md @@ -0,0 +1,8 @@ +## Arsenal + +Waypoints: +- Vehicle Move - Order vehicle to move in strain line to target ignoring AI orders and situation. waypoint create pool of vehicles where group units are driver and create new group per vehicle + +### Authors + +- Command DDOS diff --git a/addons/waypoint/XEH_PREP.hpp b/addons/waypoint/XEH_PREP.hpp new file mode 100644 index 0000000..357e9a5 --- /dev/null +++ b/addons/waypoint/XEH_PREP.hpp @@ -0,0 +1,2 @@ +PREP(fnc_moveVehicleWp); + diff --git a/addons/waypoint/XEH_postInit.sqf b/addons/waypoint/XEH_postInit.sqf new file mode 100644 index 0000000..421c54b --- /dev/null +++ b/addons/waypoint/XEH_postInit.sqf @@ -0,0 +1 @@ +#include "script_component.hpp" diff --git a/addons/waypoint/XEH_preInit.sqf b/addons/waypoint/XEH_preInit.sqf new file mode 100644 index 0000000..81be88f --- /dev/null +++ b/addons/waypoint/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; +ADDON = true; diff --git a/addons/waypoint/XEH_preStart.sqf b/addons/waypoint/XEH_preStart.sqf new file mode 100644 index 0000000..a51262a --- /dev/null +++ b/addons/waypoint/XEH_preStart.sqf @@ -0,0 +1,2 @@ +#include "script_component.hpp" +#include "XEH_PREP.hpp" diff --git a/addons/waypoint/ZEN_CfgWaypointTypes.hpp b/addons/waypoint/ZEN_CfgWaypointTypes.hpp new file mode 100644 index 0000000..774e5a6 --- /dev/null +++ b/addons/waypoint/ZEN_CfgWaypointTypes.hpp @@ -0,0 +1,7 @@ + class ZEN_WaypointTypes { + class GVAR(VehicleMove) { + displayName = CSTRING(Vehicle_Move_Name); + type = "SCRIPTED"; + script = QPATHTOF(functions\fnc_moveVehicleWP.sqf); + }; +}; diff --git a/addons/waypoint/config.cpp b/addons/waypoint/config.cpp new file mode 100644 index 0000000..5ef25a4 --- /dev/null +++ b/addons/waypoint/config.cpp @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "afmf_main" + }; + author = "ArmaForces"; + authors[] = {"Command DDOS"}; + VERSION_CONFIG; + }; +}; + +#include "CfgWaypoints.cfg" +#include "ZEN_CfgWaypointTypes.hpp" diff --git a/addons/waypoint/functions/fnc_moveVehicleWp.sqf b/addons/waypoint/functions/fnc_moveVehicleWp.sqf new file mode 100644 index 0000000..56aeaf8 --- /dev/null +++ b/addons/waypoint/functions/fnc_moveVehicleWp.sqf @@ -0,0 +1,135 @@ +#include "script_component.hpp" +/* + * Author: Command DDOS + * + * + * Arguments: + * 0: group + * 1: pos + * + * Return Value: + * none + * +*/ + +params ["_group", "_pos"]; + +if !(local _group) exitwith {false}; + +//vehicle list +private _vehicles = []; +{ + _vehicles pushBackUnique (vehicle _x); +} forEach (units _group); + +_vehicles = _vehicles select {assignedDriver _x in (units _group)}; + +if (count _vehicles == 0) exitwith {true}; + + +private _LeaderVehicle = vehicle leader _group; + +// create groups with waypoint for vehicles without leader vehicle +{ + private _vehicle = _X; + private _newgroup = createGroup (side _group); + private _UnitsInVehicle = (units _group select {_x in (Crew _vehicle)}); + _UnitsInVehicle joinSilent _newGroup; + _group leaveVehicle _vehicle; + _newgroup addVehicle _vehicle; + private _nearPos = _pos vectorAdd [random 5,random 5,0]; + private _waypoint = _newGroup addWaypoint [_nearPos,0]; + _waypoint setWaypointType "SCRIPTED"; + _waypoint setWaypointScript QPATHTOF(functions\fnc_moveVehicleWP.sqf); +} foreach (_vehicles - [_LeaderVehicle]); + +if !(driver _LeaderVehicle in (units _group)) exitwith {true}; + +// at this point there should be always 1 vehicle to process with leader inside + private _driver = driver _LeaderVehicle; + + //prevent when driver is not avaible +if !(alive _driver) exitwith {true}; +if (lifestate _driver == "INCAPACITATED") exitwith {true}; + + //calculate positions + private _posVehicleATL = getposATL _LeaderVehicle; + private _vectorDir = _posVehicleATL vectorDiff _pos; + private _vectorDirNormalized = vectorNormalized _vectorDir ; + private _pos1 = _pos vectorAdd (_vectorDirNormalized vectorMultiply 1); + private _pos2 = _pos; + private _pos3 = _pos vectorAdd (_vectorDirNormalized vectorMultiply -1); + //update pos used in WUAE + _LeaderVehicle setvariable [QGVAR(TargetArrayMovePosition),[_pos1,_pos2,_pos3]]; + + //create WUAE only when needed +if !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false]) then { + + _LeaderVehicle setvariable [QGVAR(ActiveVehicleMove),true]; + + //making group/unit easier to command + _driver setVariable ["lambs_danger_disableAI", true]; + (group _driver) setVariable ["lambs_danger_disablegroupAI", true]; + + _driver enableAI "PATH"; + _driver domove _pos2; + _driver disableAI "AUTOTARGET"; + _driver disableAI "AUTOCOMBAT"; + _driver disableAI "TARGET"; + _driver disableai "COVER"; + _driver disableai "FSM"; + _driver setBehaviour "AWARE"; + + _LeaderVehicle setvariable [QGVAR(DriverWaitTime),(time + 1)]; + _LeaderVehicle setDriveOnPath (_LeaderVehicle getvariable QGVAR(TargetArrayMovePosition)); + + [{ + //condition + params ["_vehicle","_group"]; + if !(waypointScript [_group,currentWaypoint _group] == QPATHTOF(functions\fnc_moveVehicleWP.sqf)) exitwith {true}; + if !(alive (driver _vehicle)) exitwith {true}; + if (lifestate (driver _vehicle) == "INCAPACITATED") exitwith {true}; + if (_vehicle distance2d (_vehicle getvariable (QGVAR(TargetArrayMovePosition)) select 1) < 8 ) exitwith {true}; + //refresh AI from "stuck" or move to updated position + + if (_vehicle getvariable QGVAR(DriverWaitTime) < time) then { + _vehicle setvariable [QGVAR(DriverWaitTime),(time + 2)]; + if (speed _vehicle < 4) then { + (driver _vehicle) disableAI "Path"; + (driver _vehicle) enableAI "Path"; + }; + if !(isFormationLeader (driver _vehicle)) then { + (driver _vehicle) doFollow leader (driver _vehicle); + dostop (driver _vehicle); + }; + (driver _vehicle) domove ( _vehicle getvariable QGVAR(TargetArrayMovePosition) select 1); + _vehicle setDriveOnPath ( _vehicle getvariable QGVAR(TargetArrayMovePosition)); + false; + } + },{ + //code when true + params ["_vehicle"]; + + //fixing driver behaviour where he can ignore all move orders if vehicle don't achive setDriveOnPath destinations before doFollow. + private _point1 = _vehicle getrelpos [2,0]; + private _point2 = _vehicle getrelpos [3,0]; + _vehicle setDriveOnPath [_point1,_point2]; + + [{ + params ["_vehicle"]; + (driver _vehicle) doFollow (leader (driver _vehicle)); + (driver _vehicle) domove (getposATL _vehicle); + (driver _vehicle) enableAI "all"; + (driver _vehicle) setVariable ["lambs_danger_disableAI", false]; + (group (driver _vehicle)) setVariable ["lambs_danger_disablegroupAI", false]; + _vehicle setvariable [QGVAR(ActiveVehicleMove),false]; + },[_vehicle],0.2] call cba_fnc_waitAndExecute; + + },[_LeaderVehicle,_group] + ] call CBA_fnc_waitUntilAndExecute; +}; + +waitUntil {sleep 0.4; !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false])}; + +// end +true diff --git a/addons/waypoint/functions/script_component.hpp b/addons/waypoint/functions/script_component.hpp new file mode 100644 index 0000000..0bc4b39 --- /dev/null +++ b/addons/waypoint/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\afmf\addons\waypoint\script_component.hpp" diff --git a/addons/waypoint/script_component.hpp b/addons/waypoint/script_component.hpp new file mode 100644 index 0000000..3b8b05b --- /dev/null +++ b/addons/waypoint/script_component.hpp @@ -0,0 +1,15 @@ +#define COMPONENT waypoint +#include "\z\afmf\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_WAYPOINT + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_ENABLED_WAYPOINT + #define DEBUG_SETTINGS DEBUG_SETTINGS_DEBUG_ENABLED_WAYPOINT +#endif + +#include "\z\afmf\addons\main\script_macros.hpp" + diff --git a/addons/waypoint/stringtable.xml b/addons/waypoint/stringtable.xml new file mode 100644 index 0000000..c8221f8 --- /dev/null +++ b/addons/waypoint/stringtable.xml @@ -0,0 +1,13 @@ + + + + + Direct Vehicle Move + Bezpośredni ruch pojazdu + + + Direct Vehicle Move. Waypoint create new groups for all drivers in original group and assign new waypoint for them. Waypoint is complete after reaching destination or after losing life by driver + Bezpośredni ruch pojazdu. Waypoint tworzy nowe grupy na każdego kierowce który znajduję się w grupie i przypisuje im również waypoint. Zalicza się po dotarciu lub straceniu życia przez kierowce + + + From 3486c188a9d27f3891152d52ebac32a8c3a50db1 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Thu, 15 Aug 2024 00:43:36 +0200 Subject: [PATCH 02/10] Update addons/waypoint/XEH_PREP.hpp Co-authored-by: 3Mydlo3 --- addons/waypoint/XEH_PREP.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/waypoint/XEH_PREP.hpp b/addons/waypoint/XEH_PREP.hpp index 357e9a5..6738ebb 100644 --- a/addons/waypoint/XEH_PREP.hpp +++ b/addons/waypoint/XEH_PREP.hpp @@ -1,2 +1,2 @@ -PREP(fnc_moveVehicleWp); +PREP(moveVehicleWp); From 649e0cad7d58df80c5a228705668defe9b6876a5 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:18:25 +0200 Subject: [PATCH 03/10] delete tab in code --- addons/waypoint/functions/fnc_moveVehicleWp.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/waypoint/functions/fnc_moveVehicleWp.sqf b/addons/waypoint/functions/fnc_moveVehicleWp.sqf index 56aeaf8..a1a0e38 100644 --- a/addons/waypoint/functions/fnc_moveVehicleWp.sqf +++ b/addons/waypoint/functions/fnc_moveVehicleWp.sqf @@ -19,7 +19,7 @@ if !(local _group) exitwith {false}; //vehicle list private _vehicles = []; { - _vehicles pushBackUnique (vehicle _x); + _vehicles pushBackUnique (vehicle _x); } forEach (units _group); _vehicles = _vehicles select {assignedDriver _x in (units _group)}; @@ -132,4 +132,4 @@ if !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false]) then { waitUntil {sleep 0.4; !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false])}; // end -true +true \ No newline at end of file From 59b185eb5a18ffcdb2bfcb91b3699796e1e12b30 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Fri, 16 Aug 2024 02:35:15 +0200 Subject: [PATCH 04/10] clearing empty lines and fix name in readme --- addons/waypoint/CfgWaypoints.cfg | 2 -- addons/waypoint/README.md | 2 +- addons/waypoint/XEH_PREP.hpp | 1 - addons/waypoint/XEH_postInit.sqf | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/waypoint/CfgWaypoints.cfg b/addons/waypoint/CfgWaypoints.cfg index accdc2c..a85ffca 100644 --- a/addons/waypoint/CfgWaypoints.cfg +++ b/addons/waypoint/CfgWaypoints.cfg @@ -7,7 +7,5 @@ class CfgWaypoints { icon = "\a3\3DEN\Data\CfgWaypoints\Move_ca.paa"; tooltip = CSTRING(Vehicle_Move_Description); }; - - }; }; diff --git a/addons/waypoint/README.md b/addons/waypoint/README.md index 1885812..37ad6d1 100644 --- a/addons/waypoint/README.md +++ b/addons/waypoint/README.md @@ -1,4 +1,4 @@ -## Arsenal +## Waypoint Waypoints: - Vehicle Move - Order vehicle to move in strain line to target ignoring AI orders and situation. waypoint create pool of vehicles where group units are driver and create new group per vehicle diff --git a/addons/waypoint/XEH_PREP.hpp b/addons/waypoint/XEH_PREP.hpp index 6738ebb..c34a60d 100644 --- a/addons/waypoint/XEH_PREP.hpp +++ b/addons/waypoint/XEH_PREP.hpp @@ -1,2 +1 @@ PREP(moveVehicleWp); - diff --git a/addons/waypoint/XEH_postInit.sqf b/addons/waypoint/XEH_postInit.sqf index 421c54b..84f2529 100644 --- a/addons/waypoint/XEH_postInit.sqf +++ b/addons/waypoint/XEH_postInit.sqf @@ -1 +1 @@ -#include "script_component.hpp" +#include "script_component.hpp" \ No newline at end of file From d98bcdac63067ce7139d8f445700df350c07c281 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Fri, 13 Sep 2024 02:20:35 +0200 Subject: [PATCH 05/10] Apply suggestions from code review fast fixes from review Co-authored-by: Filip Maciejewski --- addons/waypoint/CfgWaypoints.cfg | 2 +- addons/waypoint/XEH_postInit.sqf | 2 +- addons/waypoint/XEH_preInit.sqf | 1 + addons/waypoint/functions/fnc_moveVehicleWp.sqf | 10 +++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/waypoint/CfgWaypoints.cfg b/addons/waypoint/CfgWaypoints.cfg index a85ffca..b0002f7 100644 --- a/addons/waypoint/CfgWaypoints.cfg +++ b/addons/waypoint/CfgWaypoints.cfg @@ -1,5 +1,5 @@ class CfgWaypoints { - class AF_Waypoints { + class ADDON { displayName = "ArmaForces"; class Move_vehicle { displayName = CSTRING(Vehicle_Move_Name); diff --git a/addons/waypoint/XEH_postInit.sqf b/addons/waypoint/XEH_postInit.sqf index 84f2529..421c54b 100644 --- a/addons/waypoint/XEH_postInit.sqf +++ b/addons/waypoint/XEH_postInit.sqf @@ -1 +1 @@ -#include "script_component.hpp" \ No newline at end of file +#include "script_component.hpp" diff --git a/addons/waypoint/XEH_preInit.sqf b/addons/waypoint/XEH_preInit.sqf index 81be88f..ecb5d0c 100644 --- a/addons/waypoint/XEH_preInit.sqf +++ b/addons/waypoint/XEH_preInit.sqf @@ -4,4 +4,5 @@ ADDON = false; PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; + ADDON = true; diff --git a/addons/waypoint/functions/fnc_moveVehicleWp.sqf b/addons/waypoint/functions/fnc_moveVehicleWp.sqf index a1a0e38..e183ae4 100644 --- a/addons/waypoint/functions/fnc_moveVehicleWp.sqf +++ b/addons/waypoint/functions/fnc_moveVehicleWp.sqf @@ -27,7 +27,7 @@ _vehicles = _vehicles select {assignedDriver _x in (units _group)}; if (count _vehicles == 0) exitwith {true}; -private _LeaderVehicle = vehicle leader _group; +private _leaderVehicle = vehicle leader _group; // create groups with waypoint for vehicles without leader vehicle { @@ -76,8 +76,8 @@ if !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false]) then { _driver disableAI "AUTOTARGET"; _driver disableAI "AUTOCOMBAT"; _driver disableAI "TARGET"; - _driver disableai "COVER"; - _driver disableai "FSM"; + _driver disableAI "COVER"; + _driver disableAI "FSM"; _driver setBehaviour "AWARE"; _LeaderVehicle setvariable [QGVAR(DriverWaitTime),(time + 1)]; @@ -95,8 +95,8 @@ if !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false]) then { if (_vehicle getvariable QGVAR(DriverWaitTime) < time) then { _vehicle setvariable [QGVAR(DriverWaitTime),(time + 2)]; if (speed _vehicle < 4) then { - (driver _vehicle) disableAI "Path"; - (driver _vehicle) enableAI "Path"; + (driver _vehicle) disableAI "PATH"; + (driver _vehicle) enableAI "PATH"; }; if !(isFormationLeader (driver _vehicle)) then { (driver _vehicle) doFollow leader (driver _vehicle); From 73174e6ba4be9f168c1bf946e55c36dd58ca42fb Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:10:50 +0200 Subject: [PATCH 06/10] waypoint logic simplified, added forgotten files, fixed configs. --- addons/waypoint/$PBOPREFIX$ | 1 - addons/waypoint/README.md | 8 -- addons/waypoint/XEH_PREP.hpp | 1 - addons/waypoint/ZEN_CfgWaypointTypes.hpp | 7 - .../waypoint/functions/fnc_moveVehicleWp.sqf | 135 ------------------ .../waypoint/functions/script_component.hpp | 1 - addons/waypoints/$PBOPREFIX$ | 1 + addons/waypoints/CfgEventHandlers.hpp | 15 ++ .../{waypoint => waypoints}/CfgWaypoints.cfg | 6 +- addons/waypoints/README.md | 9 ++ addons/waypoints/XEH_PREP.hpp | 2 + .../{waypoint => waypoints}/XEH_postInit.sqf | 0 .../{waypoint => waypoints}/XEH_preInit.sqf | 0 .../{waypoint => waypoints}/XEH_preStart.sqf | 0 addons/waypoints/ZEN_CfgWaypointTypes.hpp | 7 + addons/{waypoint => waypoints}/config.cpp | 1 + .../functions/fnc_seperateGroupVehicles.sqf | 33 +++++ .../functions/fnc_waypointMoveVehicle.sqf | 65 +++++++++ .../waypoints/functions/script_component.hpp | 1 + .../script_component.hpp | 9 +- .../{waypoint => waypoints}/stringtable.xml | 6 +- 21 files changed, 144 insertions(+), 164 deletions(-) delete mode 100644 addons/waypoint/$PBOPREFIX$ delete mode 100644 addons/waypoint/README.md delete mode 100644 addons/waypoint/XEH_PREP.hpp delete mode 100644 addons/waypoint/ZEN_CfgWaypointTypes.hpp delete mode 100644 addons/waypoint/functions/fnc_moveVehicleWp.sqf delete mode 100644 addons/waypoint/functions/script_component.hpp create mode 100644 addons/waypoints/$PBOPREFIX$ create mode 100644 addons/waypoints/CfgEventHandlers.hpp rename addons/{waypoint => waypoints}/CfgWaypoints.cfg (61%) create mode 100644 addons/waypoints/README.md create mode 100644 addons/waypoints/XEH_PREP.hpp rename addons/{waypoint => waypoints}/XEH_postInit.sqf (100%) rename addons/{waypoint => waypoints}/XEH_preInit.sqf (100%) rename addons/{waypoint => waypoints}/XEH_preStart.sqf (100%) create mode 100644 addons/waypoints/ZEN_CfgWaypointTypes.hpp rename addons/{waypoint => waypoints}/config.cpp (92%) create mode 100644 addons/waypoints/functions/fnc_seperateGroupVehicles.sqf create mode 100644 addons/waypoints/functions/fnc_waypointMoveVehicle.sqf create mode 100644 addons/waypoints/functions/script_component.hpp rename addons/{waypoint => waypoints}/script_component.hpp (56%) rename addons/{waypoint => waypoints}/stringtable.xml (82%) diff --git a/addons/waypoint/$PBOPREFIX$ b/addons/waypoint/$PBOPREFIX$ deleted file mode 100644 index bf3a558..0000000 --- a/addons/waypoint/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\afmf\addons\waypoint \ No newline at end of file diff --git a/addons/waypoint/README.md b/addons/waypoint/README.md deleted file mode 100644 index 37ad6d1..0000000 --- a/addons/waypoint/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Waypoint - -Waypoints: -- Vehicle Move - Order vehicle to move in strain line to target ignoring AI orders and situation. waypoint create pool of vehicles where group units are driver and create new group per vehicle - -### Authors - -- Command DDOS diff --git a/addons/waypoint/XEH_PREP.hpp b/addons/waypoint/XEH_PREP.hpp deleted file mode 100644 index c34a60d..0000000 --- a/addons/waypoint/XEH_PREP.hpp +++ /dev/null @@ -1 +0,0 @@ -PREP(moveVehicleWp); diff --git a/addons/waypoint/ZEN_CfgWaypointTypes.hpp b/addons/waypoint/ZEN_CfgWaypointTypes.hpp deleted file mode 100644 index 774e5a6..0000000 --- a/addons/waypoint/ZEN_CfgWaypointTypes.hpp +++ /dev/null @@ -1,7 +0,0 @@ - class ZEN_WaypointTypes { - class GVAR(VehicleMove) { - displayName = CSTRING(Vehicle_Move_Name); - type = "SCRIPTED"; - script = QPATHTOF(functions\fnc_moveVehicleWP.sqf); - }; -}; diff --git a/addons/waypoint/functions/fnc_moveVehicleWp.sqf b/addons/waypoint/functions/fnc_moveVehicleWp.sqf deleted file mode 100644 index e183ae4..0000000 --- a/addons/waypoint/functions/fnc_moveVehicleWp.sqf +++ /dev/null @@ -1,135 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Command DDOS - * - * - * Arguments: - * 0: group - * 1: pos - * - * Return Value: - * none - * -*/ - -params ["_group", "_pos"]; - -if !(local _group) exitwith {false}; - -//vehicle list -private _vehicles = []; -{ - _vehicles pushBackUnique (vehicle _x); -} forEach (units _group); - -_vehicles = _vehicles select {assignedDriver _x in (units _group)}; - -if (count _vehicles == 0) exitwith {true}; - - -private _leaderVehicle = vehicle leader _group; - -// create groups with waypoint for vehicles without leader vehicle -{ - private _vehicle = _X; - private _newgroup = createGroup (side _group); - private _UnitsInVehicle = (units _group select {_x in (Crew _vehicle)}); - _UnitsInVehicle joinSilent _newGroup; - _group leaveVehicle _vehicle; - _newgroup addVehicle _vehicle; - private _nearPos = _pos vectorAdd [random 5,random 5,0]; - private _waypoint = _newGroup addWaypoint [_nearPos,0]; - _waypoint setWaypointType "SCRIPTED"; - _waypoint setWaypointScript QPATHTOF(functions\fnc_moveVehicleWP.sqf); -} foreach (_vehicles - [_LeaderVehicle]); - -if !(driver _LeaderVehicle in (units _group)) exitwith {true}; - -// at this point there should be always 1 vehicle to process with leader inside - private _driver = driver _LeaderVehicle; - - //prevent when driver is not avaible -if !(alive _driver) exitwith {true}; -if (lifestate _driver == "INCAPACITATED") exitwith {true}; - - //calculate positions - private _posVehicleATL = getposATL _LeaderVehicle; - private _vectorDir = _posVehicleATL vectorDiff _pos; - private _vectorDirNormalized = vectorNormalized _vectorDir ; - private _pos1 = _pos vectorAdd (_vectorDirNormalized vectorMultiply 1); - private _pos2 = _pos; - private _pos3 = _pos vectorAdd (_vectorDirNormalized vectorMultiply -1); - //update pos used in WUAE - _LeaderVehicle setvariable [QGVAR(TargetArrayMovePosition),[_pos1,_pos2,_pos3]]; - - //create WUAE only when needed -if !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false]) then { - - _LeaderVehicle setvariable [QGVAR(ActiveVehicleMove),true]; - - //making group/unit easier to command - _driver setVariable ["lambs_danger_disableAI", true]; - (group _driver) setVariable ["lambs_danger_disablegroupAI", true]; - - _driver enableAI "PATH"; - _driver domove _pos2; - _driver disableAI "AUTOTARGET"; - _driver disableAI "AUTOCOMBAT"; - _driver disableAI "TARGET"; - _driver disableAI "COVER"; - _driver disableAI "FSM"; - _driver setBehaviour "AWARE"; - - _LeaderVehicle setvariable [QGVAR(DriverWaitTime),(time + 1)]; - _LeaderVehicle setDriveOnPath (_LeaderVehicle getvariable QGVAR(TargetArrayMovePosition)); - - [{ - //condition - params ["_vehicle","_group"]; - if !(waypointScript [_group,currentWaypoint _group] == QPATHTOF(functions\fnc_moveVehicleWP.sqf)) exitwith {true}; - if !(alive (driver _vehicle)) exitwith {true}; - if (lifestate (driver _vehicle) == "INCAPACITATED") exitwith {true}; - if (_vehicle distance2d (_vehicle getvariable (QGVAR(TargetArrayMovePosition)) select 1) < 8 ) exitwith {true}; - //refresh AI from "stuck" or move to updated position - - if (_vehicle getvariable QGVAR(DriverWaitTime) < time) then { - _vehicle setvariable [QGVAR(DriverWaitTime),(time + 2)]; - if (speed _vehicle < 4) then { - (driver _vehicle) disableAI "PATH"; - (driver _vehicle) enableAI "PATH"; - }; - if !(isFormationLeader (driver _vehicle)) then { - (driver _vehicle) doFollow leader (driver _vehicle); - dostop (driver _vehicle); - }; - (driver _vehicle) domove ( _vehicle getvariable QGVAR(TargetArrayMovePosition) select 1); - _vehicle setDriveOnPath ( _vehicle getvariable QGVAR(TargetArrayMovePosition)); - false; - } - },{ - //code when true - params ["_vehicle"]; - - //fixing driver behaviour where he can ignore all move orders if vehicle don't achive setDriveOnPath destinations before doFollow. - private _point1 = _vehicle getrelpos [2,0]; - private _point2 = _vehicle getrelpos [3,0]; - _vehicle setDriveOnPath [_point1,_point2]; - - [{ - params ["_vehicle"]; - (driver _vehicle) doFollow (leader (driver _vehicle)); - (driver _vehicle) domove (getposATL _vehicle); - (driver _vehicle) enableAI "all"; - (driver _vehicle) setVariable ["lambs_danger_disableAI", false]; - (group (driver _vehicle)) setVariable ["lambs_danger_disablegroupAI", false]; - _vehicle setvariable [QGVAR(ActiveVehicleMove),false]; - },[_vehicle],0.2] call cba_fnc_waitAndExecute; - - },[_LeaderVehicle,_group] - ] call CBA_fnc_waitUntilAndExecute; -}; - -waitUntil {sleep 0.4; !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false])}; - -// end -true \ No newline at end of file diff --git a/addons/waypoint/functions/script_component.hpp b/addons/waypoint/functions/script_component.hpp deleted file mode 100644 index 0bc4b39..0000000 --- a/addons/waypoint/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\afmf\addons\waypoint\script_component.hpp" diff --git a/addons/waypoints/$PBOPREFIX$ b/addons/waypoints/$PBOPREFIX$ new file mode 100644 index 0000000..0ae0480 --- /dev/null +++ b/addons/waypoints/$PBOPREFIX$ @@ -0,0 +1 @@ +z\afmf\addons\waypoints \ No newline at end of file diff --git a/addons/waypoints/CfgEventHandlers.hpp b/addons/waypoints/CfgEventHandlers.hpp new file mode 100644 index 0000000..e90bed4 --- /dev/null +++ b/addons/waypoints/CfgEventHandlers.hpp @@ -0,0 +1,15 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/waypoint/CfgWaypoints.cfg b/addons/waypoints/CfgWaypoints.cfg similarity index 61% rename from addons/waypoint/CfgWaypoints.cfg rename to addons/waypoints/CfgWaypoints.cfg index b0002f7..4241a94 100644 --- a/addons/waypoint/CfgWaypoints.cfg +++ b/addons/waypoints/CfgWaypoints.cfg @@ -1,11 +1,11 @@ class CfgWaypoints { class ADDON { displayName = "ArmaForces"; - class Move_vehicle { - displayName = CSTRING(Vehicle_Move_Name); + class VehicleMove { + displayName = CSTRING(VehicleMoveName); file = QPATHTOF(functions\fnc_moveVehicleWp.sqf); icon = "\a3\3DEN\Data\CfgWaypoints\Move_ca.paa"; - tooltip = CSTRING(Vehicle_Move_Description); + tooltip = CSTRING(VehicleMoveDescription); }; }; }; diff --git a/addons/waypoints/README.md b/addons/waypoints/README.md new file mode 100644 index 0000000..a89e65c --- /dev/null +++ b/addons/waypoints/README.md @@ -0,0 +1,9 @@ +## Waypoint + +Waypoints: + +- Vehicle Move - Orders vehicle to move in straight line to the waypoint position, ignoring AI orders and situation. For more vehicles in a group, the group is divided into each vehicle duplicating the waypoint for better zeus control. + +### Authors + +- Command DDOS diff --git a/addons/waypoints/XEH_PREP.hpp b/addons/waypoints/XEH_PREP.hpp new file mode 100644 index 0000000..7457e73 --- /dev/null +++ b/addons/waypoints/XEH_PREP.hpp @@ -0,0 +1,2 @@ +PREP(waypointMoveVehicle); +PREP(seperateGroupVehicles); diff --git a/addons/waypoint/XEH_postInit.sqf b/addons/waypoints/XEH_postInit.sqf similarity index 100% rename from addons/waypoint/XEH_postInit.sqf rename to addons/waypoints/XEH_postInit.sqf diff --git a/addons/waypoint/XEH_preInit.sqf b/addons/waypoints/XEH_preInit.sqf similarity index 100% rename from addons/waypoint/XEH_preInit.sqf rename to addons/waypoints/XEH_preInit.sqf diff --git a/addons/waypoint/XEH_preStart.sqf b/addons/waypoints/XEH_preStart.sqf similarity index 100% rename from addons/waypoint/XEH_preStart.sqf rename to addons/waypoints/XEH_preStart.sqf diff --git a/addons/waypoints/ZEN_CfgWaypointTypes.hpp b/addons/waypoints/ZEN_CfgWaypointTypes.hpp new file mode 100644 index 0000000..443958f --- /dev/null +++ b/addons/waypoints/ZEN_CfgWaypointTypes.hpp @@ -0,0 +1,7 @@ + class ZEN_WaypointTypes { + class GVAR(VehicleMove) { + displayName = CSTRING(VehicleMoveName); + type = "SCRIPTED"; + script = QPATHTOF(functions\fnc_waypointMoveVehicle.sqf); + }; +}; diff --git a/addons/waypoint/config.cpp b/addons/waypoints/config.cpp similarity index 92% rename from addons/waypoint/config.cpp rename to addons/waypoints/config.cpp index 5ef25a4..6f7e11b 100644 --- a/addons/waypoint/config.cpp +++ b/addons/waypoints/config.cpp @@ -17,3 +17,4 @@ class CfgPatches { #include "CfgWaypoints.cfg" #include "ZEN_CfgWaypointTypes.hpp" +#include "CfgEventHandlers.hpp" diff --git a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf new file mode 100644 index 0000000..9eeb472 --- /dev/null +++ b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf @@ -0,0 +1,33 @@ +#include "script_component.hpp" +/* + * Author: Command DDOS + * Used in waypoint, create new groups with waypoint from original group + * + * Arguments: + * 0: Array Of vehicles + * + * Return Value: + * none + * +*/ + +params ["_vehicles"]; + +{ + private _vehicle = _X; + private _oldGroup = group driver _vehicle; + private _pos = (getWPPos [_oldGroup,currentWaypoint _oldGroup]); + private _waypointType = waypointType [_oldGroup,currentWaypoint _oldGroup]; + private _waypointScript = waypointScript [_oldGroup,currentWaypoint _oldGroup]; + private _newgroup = createGroup (side _group); + private _UnitsInVehicle = (units _group select {_x in (crew _vehicle)}); + _UnitsInVehicle joinSilent _newGroup; + _group leaveVehicle _vehicle; + _newgroup addVehicle _vehicle; + private _nearPos = _pos vectorAdd [random 5,random 5,0]; + private _waypoint = _newGroup addWaypoint [_nearPos,0]; + _waypoint setWaypointType _waypointType; + if !(_waypointScript == "") then { + _waypoint setWaypointScript _waypointScript; + }; +} forEach _vehicles; \ No newline at end of file diff --git a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf new file mode 100644 index 0000000..a7ecb62 --- /dev/null +++ b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf @@ -0,0 +1,65 @@ +#include "script_component.hpp" +/* + * Author: Command DDOS + * + * Arguments: + * 0: group + * 1: pos + * + * Return Value: + * none + * +*/ + +params ["_group", "_pos"]; + +if !(local _group) exitWith {false}; + + +private _vehicles = []; +{ + _vehicles pushBackUnique (vehicle _x); +} forEach (units _group); + +_vehicles = _vehicles select {assignedDriver _x in (units _group)}; +if (count _vehicles == 0) exitWith {true}; +private _vehicle = vehicle leader _group; + +// create groups with waypoint for vehicles without leader vehicle +if !(count (_vehicles - [_vehicle]) == 0) then { + [_vehicles - [_vehicle]] call FUNC(seperateGroupVehicles); +}; + +if !(driver _vehicle in (units _group)) exitWith {true}; + +// this should allow fast fix bugged driver behaviour by changing waypoint position by zeus +If (speed _vehicle < 4) then { + _vehicle engineOn false; +}; +// update pos used in WUAE +_vehicle setVariable [QGVAR(targetMovePosition), _pos]; + +// create WUAE only when needed +if !(_vehicle getVariable [QGVAR(ActiveVehicleMove), false]) then { + _vehicle setVariable [QGVAR(ActiveVehicleMove), true]; +// WUAE +[{ + // condition + params ["_vehicle","_group"]; + if !(waypointScript [_group,currentWaypoint _group] == QPATHTOF(functions\fnc_waypointMoveVehicle.sqf)) exitWith {true}; + if !(alive (driver _vehicle)) exitWith {true}; + if (lifeState (driver _vehicle) == "INCAPACITATED") exitWith {true}; + if (_vehicle distance2D (_vehicle getVariable (QGVAR(targetMovePosition))) < 8) exitWith {true}; + + _vehicle setDriveOnPath [getPosATL _vehicle, _vehicle getVariable QGVAR(targetMovePosition)]; + false; + },{ + // code when true + params ["_vehicle"]; + (group driver _vehicle) move (getPosATL _vehicle); + _vehicle setVariable [QGVAR(ActiveVehicleMove), false]; + },[_vehicle,_group] +] call CBA_fnc_waitUntilAndExecute; +}; + +waitUntil {sleep 0.2; !(_vehicle getVariable [QGVAR(ActiveVehicleMove),false])}; diff --git a/addons/waypoints/functions/script_component.hpp b/addons/waypoints/functions/script_component.hpp new file mode 100644 index 0000000..372f088 --- /dev/null +++ b/addons/waypoints/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\afmf\addons\waypoints\script_component.hpp" diff --git a/addons/waypoint/script_component.hpp b/addons/waypoints/script_component.hpp similarity index 56% rename from addons/waypoint/script_component.hpp rename to addons/waypoints/script_component.hpp index 3b8b05b..4f017a9 100644 --- a/addons/waypoint/script_component.hpp +++ b/addons/waypoints/script_component.hpp @@ -1,15 +1,14 @@ -#define COMPONENT waypoint +#define COMPONENT waypoints #include "\z\afmf\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -#ifdef DEBUG_ENABLED_WAYPOINT +#ifdef DEBUG_ENABLED_WAYPOINTS #define DEBUG_MODE_FULL #endif - #ifdef DEBUG_ENABLED_WAYPOINT - #define DEBUG_SETTINGS DEBUG_SETTINGS_DEBUG_ENABLED_WAYPOINT + #ifdef DEBUG_SETTINGS_WAYPOINTS + #define DEBUG_SETTINGS DEBUG_SETTINGS_WAYPOINTS #endif #include "\z\afmf\addons\main\script_macros.hpp" - diff --git a/addons/waypoint/stringtable.xml b/addons/waypoints/stringtable.xml similarity index 82% rename from addons/waypoint/stringtable.xml rename to addons/waypoints/stringtable.xml index c8221f8..b92c1be 100644 --- a/addons/waypoint/stringtable.xml +++ b/addons/waypoints/stringtable.xml @@ -1,11 +1,11 @@ - - + + Direct Vehicle Move Bezpośredni ruch pojazdu - + Direct Vehicle Move. Waypoint create new groups for all drivers in original group and assign new waypoint for them. Waypoint is complete after reaching destination or after losing life by driver Bezpośredni ruch pojazdu. Waypoint tworzy nowe grupy na każdego kierowce który znajduję się w grupie i przypisuje im również waypoint. Zalicza się po dotarciu lub straceniu życia przez kierowce From f57b917c6847c6b5649339ed7fca738f1fdfdb8a Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:12:38 +0200 Subject: [PATCH 07/10] delete left tab --- addons/waypoints/functions/fnc_waypointMoveVehicle.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf index a7ecb62..f270aea 100644 --- a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf +++ b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf @@ -18,7 +18,7 @@ if !(local _group) exitWith {false}; private _vehicles = []; { - _vehicles pushBackUnique (vehicle _x); + _vehicles pushBackUnique (vehicle _x); } forEach (units _group); _vehicles = _vehicles select {assignedDriver _x in (units _group)}; From 20cd57deb7e33d328c91b3892ff3339af8a9f085 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:15:50 +0200 Subject: [PATCH 08/10] deleting not needed ";" --- addons/waypoints/functions/fnc_seperateGroupVehicles.sqf | 2 +- addons/waypoints/functions/fnc_waypointMoveVehicle.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf index 9eeb472..834cb8d 100644 --- a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf +++ b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf @@ -30,4 +30,4 @@ params ["_vehicles"]; if !(_waypointScript == "") then { _waypoint setWaypointScript _waypointScript; }; -} forEach _vehicles; \ No newline at end of file +} forEach _vehicles \ No newline at end of file diff --git a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf index f270aea..cf3f1e8 100644 --- a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf +++ b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf @@ -62,4 +62,4 @@ if !(_vehicle getVariable [QGVAR(ActiveVehicleMove), false]) then { ] call CBA_fnc_waitUntilAndExecute; }; -waitUntil {sleep 0.2; !(_vehicle getVariable [QGVAR(ActiveVehicleMove),false])}; +waitUntil {sleep 0.2; !(_vehicle getVariable [QGVAR(ActiveVehicleMove),false])} From de610a6a8d950b2c039dec8f0a8fec568431680e Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:08:19 +0200 Subject: [PATCH 09/10] rewrite --- .../functions/fnc_seperateGroupVehicles.sqf | 56 ++++++++++++----- .../functions/fnc_waypointMoveVehicle.sqf | 63 ++++++++----------- 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf index 834cb8d..3058b2e 100644 --- a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf +++ b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf @@ -1,33 +1,57 @@ #include "script_component.hpp" /* * Author: Command DDOS - * Used in waypoint, create new groups with waypoint from original group * * Arguments: - * 0: Array Of vehicles + * 0: group + * 1: clone waypoint from original group + * 2: random pos near cloned waypoint * * Return Value: - * none + * Array of new groups * */ -params ["_vehicles"]; +params [ + ["_group", grpNull, [grpNull]], + ["_cloneWaypoint", true, [true]], + ["_waypointRandomDif", 3, [0]] +]; + +private _vehicles = []; + +{ + _vehicles pushBackUnique (vehicle _x); +} forEach (units _group); + +_vehicles = (_vehicles - [vehicle leader _group]) select {assignedDriver _x in (units _group)}; +if (count _vehicles == 0) exitWith {[]}; + +private _newgroups = []; { private _vehicle = _X; private _oldGroup = group driver _vehicle; - private _pos = (getWPPos [_oldGroup,currentWaypoint _oldGroup]); - private _waypointType = waypointType [_oldGroup,currentWaypoint _oldGroup]; - private _waypointScript = waypointScript [_oldGroup,currentWaypoint _oldGroup]; - private _newgroup = createGroup (side _group); + private _newGroup = createGroup (side _group); private _UnitsInVehicle = (units _group select {_x in (crew _vehicle)}); _UnitsInVehicle joinSilent _newGroup; _group leaveVehicle _vehicle; - _newgroup addVehicle _vehicle; - private _nearPos = _pos vectorAdd [random 5,random 5,0]; - private _waypoint = _newGroup addWaypoint [_nearPos,0]; - _waypoint setWaypointType _waypointType; - if !(_waypointScript == "") then { - _waypoint setWaypointScript _waypointScript; - }; -} forEach _vehicles \ No newline at end of file + _newGroup addVehicle _vehicle; + _newGroup setBehaviour (combatBehaviour _group); + + if (_cloneWaypoint) then { + private _waypointPos = (getWPPos [_oldGroup,currentWaypoint _oldGroup]); + if (_waypointPos isEqualTo [0,0,0]) exitwith {}; + private _waypointType = waypointType [_oldGroup,currentWaypoint _oldGroup]; + private _waypointScript = waypointScript [_oldGroup,currentWaypoint _oldGroup]; + private _nearPos = _waypointPos vectorAdd [random _waypointRandomDif,random _waypointRandomDif,0]; + private _waypoint = _newGroup addWaypoint [_nearPos,0]; + _newGroups = _newGroups + [_newGroup]; + _waypoint setWaypointType _waypointType; + if !(_waypointScript == "") then { + _waypoint setWaypointScript _waypointScript; + }; + }; +} forEach _vehicles; + +_newGroups \ No newline at end of file diff --git a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf index cf3f1e8..c4b7fc4 100644 --- a/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf +++ b/addons/waypoints/functions/fnc_waypointMoveVehicle.sqf @@ -15,51 +15,40 @@ params ["_group", "_pos"]; if !(local _group) exitWith {false}; +[_group] call FUNC(seperateGroupVehicles); -private _vehicles = []; -{ - _vehicles pushBackUnique (vehicle _x); -} forEach (units _group); - -_vehicles = _vehicles select {assignedDriver _x in (units _group)}; -if (count _vehicles == 0) exitWith {true}; private _vehicle = vehicle leader _group; -// create groups with waypoint for vehicles without leader vehicle -if !(count (_vehicles - [_vehicle]) == 0) then { - [_vehicles - [_vehicle]] call FUNC(seperateGroupVehicles); +// creating move waypoint when leader is not in vehicle +if (vehicle leader _group == leader _group) exitWith { + _group addWaypoint [_pos, 0, (currentWaypoint _group) + 1]; + true; }; -if !(driver _vehicle in (units _group)) exitWith {true}; - -// this should allow fast fix bugged driver behaviour by changing waypoint position by zeus -If (speed _vehicle < 4) then { - _vehicle engineOn false; -}; -// update pos used in WUAE +//update pos used in WUAE _vehicle setVariable [QGVAR(targetMovePosition), _pos]; -// create WUAE only when needed +//create WUAE only when needed if !(_vehicle getVariable [QGVAR(ActiveVehicleMove), false]) then { - _vehicle setVariable [QGVAR(ActiveVehicleMove), true]; -// WUAE -[{ - // condition - params ["_vehicle","_group"]; - if !(waypointScript [_group,currentWaypoint _group] == QPATHTOF(functions\fnc_waypointMoveVehicle.sqf)) exitWith {true}; - if !(alive (driver _vehicle)) exitWith {true}; - if (lifeState (driver _vehicle) == "INCAPACITATED") exitWith {true}; - if (_vehicle distance2D (_vehicle getVariable (QGVAR(targetMovePosition))) < 8) exitWith {true}; - - _vehicle setDriveOnPath [getPosATL _vehicle, _vehicle getVariable QGVAR(targetMovePosition)]; - false; - },{ - // code when true - params ["_vehicle"]; - (group driver _vehicle) move (getPosATL _vehicle); - _vehicle setVariable [QGVAR(ActiveVehicleMove), false]; - },[_vehicle,_group] -] call CBA_fnc_waitUntilAndExecute; + _vehicle setVariable [QGVAR(ActiveVehicleMove), true]; + //WUAE + [{ + //condition + params ["_vehicle","_scriptHandle"]; + if (scriptDone _scriptHandle) exitWith {true}; + if !(alive (driver _vehicle)) exitWith {true}; + if (lifeState (driver _vehicle) == "INCAPACITATED") exitWith {true}; + if (_vehicle distance2D (_vehicle getVariable (QGVAR(targetMovePosition))) < 8) exitWith {true}; + + _vehicle setDriveOnPath [getPosATL _vehicle, _vehicle getVariable QGVAR(targetMovePosition)]; + false; + },{ + //code when true + params ["_vehicle"]; + (group driver _vehicle) move (getPosATL _vehicle); + _vehicle setVariable [QGVAR(ActiveVehicleMove), false]; + },[_vehicle,_thisScript] + ] call CBA_fnc_waitUntilAndExecute; }; waitUntil {sleep 0.2; !(_vehicle getVariable [QGVAR(ActiveVehicleMove),false])} From 1cdccc00427ec982602ab28a844f4d3f2d38e4f9 Mon Sep 17 00:00:00 2001 From: CommandDDOS <95705060+CommandDDOS@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:11:14 +0200 Subject: [PATCH 10/10] fix command size name --- addons/waypoints/functions/fnc_seperateGroupVehicles.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf index 3058b2e..1a0c9cf 100644 --- a/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf +++ b/addons/waypoints/functions/fnc_seperateGroupVehicles.sqf @@ -41,7 +41,7 @@ private _newgroups = []; if (_cloneWaypoint) then { private _waypointPos = (getWPPos [_oldGroup,currentWaypoint _oldGroup]); - if (_waypointPos isEqualTo [0,0,0]) exitwith {}; + if (_waypointPos isEqualTo [0,0,0]) exitWith {}; private _waypointType = waypointType [_oldGroup,currentWaypoint _oldGroup]; private _waypointScript = waypointScript [_oldGroup,currentWaypoint _oldGroup]; private _nearPos = _waypointPos vectorAdd [random _waypointRandomDif,random _waypointRandomDif,0];