Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Direct Vehicle Move waypoint #11

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions addons/waypoints/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\afmf\addons\waypoints
15 changes: 15 additions & 0 deletions addons/waypoints/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -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));
};
};
11 changes: 11 additions & 0 deletions addons/waypoints/CfgWaypoints.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CfgWaypoints {
class ADDON {
displayName = "ArmaForces";
class VehicleMove {
displayName = CSTRING(VehicleMoveName);
file = QPATHTOF(functions\fnc_moveVehicleWp.sqf);
icon = "\a3\3DEN\Data\CfgWaypoints\Move_ca.paa";
tooltip = CSTRING(VehicleMoveDescription);
};
};
};
9 changes: 9 additions & 0 deletions addons/waypoints/README.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions addons/waypoints/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PREP(waypointMoveVehicle);
PREP(seperateGroupVehicles);
1 change: 1 addition & 0 deletions addons/waypoints/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "script_component.hpp"
8 changes: 8 additions & 0 deletions addons/waypoints/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "script_component.hpp"
ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;
2 changes: 2 additions & 0 deletions addons/waypoints/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"
7 changes: 7 additions & 0 deletions addons/waypoints/ZEN_CfgWaypointTypes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ZEN_WaypointTypes {
class GVAR(VehicleMove) {
displayName = CSTRING(VehicleMoveName);
type = "SCRIPTED";
script = QPATHTOF(functions\fnc_waypointMoveVehicle.sqf);
};
};
20 changes: 20 additions & 0 deletions addons/waypoints/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#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"
#include "CfgEventHandlers.hpp"
57 changes: 57 additions & 0 deletions addons/waypoints/functions/fnc_seperateGroupVehicles.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "script_component.hpp"
/*
* Author: Command DDOS
*
* Arguments:
* 0: group
* 1: clone waypoint from original group <BOOLEAN, defaults to true>
* 2: random pos near cloned waypoint <NUMBER, defaults to 3>
*
* Return Value:
* Array of new groups <ARRAY>
*
*/

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 _newGroup = createGroup (side _group);
private _UnitsInVehicle = (units _group select {_x in (crew _vehicle)});
_UnitsInVehicle joinSilent _newGroup;
_group leaveVehicle _vehicle;
_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
54 changes: 54 additions & 0 deletions addons/waypoints/functions/fnc_waypointMoveVehicle.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "script_component.hpp"
/*
* Author: Command DDOS
*
* Arguments:
* 0: group
* 1: pos
*
* Return Value:
* none
*
*/

params ["_group", "_pos"];

if !(local _group) exitWith {false};

[_group] call FUNC(seperateGroupVehicles);

private _vehicle = vehicle leader _group;

// creating move waypoint when leader is not in vehicle
if (vehicle leader _group == leader _group) exitWith {
_group addWaypoint [_pos, 0, (currentWaypoint _group) + 1];
true;
};

//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","_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])}
1 change: 1 addition & 0 deletions addons/waypoints/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "\z\afmf\addons\waypoints\script_component.hpp"
14 changes: 14 additions & 0 deletions addons/waypoints/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#define COMPONENT waypoints
#include "\z\afmf\addons\main\script_mod.hpp"

// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE

#ifdef DEBUG_ENABLED_WAYPOINTS
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_WAYPOINTS
#define DEBUG_SETTINGS DEBUG_SETTINGS_WAYPOINTS
#endif

#include "\z\afmf\addons\main\script_macros.hpp"
13 changes: 13 additions & 0 deletions addons/waypoints/stringtable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="AFMF">
<Package name="Waypoints">
<Key ID="STR_AFMF_Waypoints_VehicleMoveName">
<English>Direct Vehicle Move</English>
<Polish>Bezpośredni ruch pojazdu</Polish>
</Key>
<Key ID="STR_AFMF_Waypoints_VehicleMoveDescription">
<English>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</English>
<Polish>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</Polish>
</Key>
</Package>
</Project>
Loading