-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
2faccd2
3486c18
649e0ca
59b185e
d98bcda
376c288
73174e6
f57b917
20cd57d
de610a6
1cdccc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\afmf\addons\waypoint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CfgWaypoints { | ||
class ADDON { | ||
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); | ||
}; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,8 @@ | ||||||||||||||||||||
## 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 | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should keep one empty line before and after any list in Markdown. Plus some spelling fixes. I'm not sure what that does mean, so if my suggestion doesn't apply, please fix that.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
### Authors | ||||||||||||||||||||
|
||||||||||||||||||||
- Command DDOS |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PREP(moveVehicleWp); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "script_component.hpp" |
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; | ||
CommandDDOS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ADDON = true; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "script_component.hpp" | ||
#include "XEH_PREP.hpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ZEN_WaypointTypes { | ||
class GVAR(VehicleMove) { | ||
displayName = CSTRING(Vehicle_Move_Name); | ||
type = "SCRIPTED"; | ||
script = QPATHTOF(functions\fnc_moveVehicleWP.sqf); | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,135 @@ | ||||||||||
#include "script_component.hpp" | ||||||||||
/* | ||||||||||
* Author: Command DDOS | ||||||||||
* | ||||||||||
* | ||||||||||
* Arguments: | ||||||||||
* 0: group | ||||||||||
* 1: pos | ||||||||||
* | ||||||||||
* Return Value: | ||||||||||
* none | ||||||||||
* | ||||||||||
*/ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment does not follow the template, excess line between author and arguments. |
||||||||||
|
||||||||||
params ["_group", "_pos"]; | ||||||||||
|
||||||||||
if !(local _group) exitwith {false}; | ||||||||||
|
||||||||||
//vehicle list | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary comment, it's obvious what
Suggested change
|
||||||||||
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]; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should save and restore values of these variables after the waypoint is completed. |
||||||||||
|
||||||||||
_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}; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if next waypoint is the same? Will there be 2 competing scripts? I don't see a valid reason for checking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but waypoint gonna end only when WUAE is complete, so new wuae gonna be created for next waypoint There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relevant FT ticket: https://feedback.bistudio.com/T183544 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, can be resolved then. |
||||||||||
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]; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review your whole code for such cases, there's plenty of them. Please stick to camelCase/the same casing as on Biki.
Suggested change
|
||||||||||
_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; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep a space after
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see veteran spared his time writing such comments and will have you fix all the issues that will be automatically reported by updated HEMTT. 🤣 |
||||||||||
|
||||||||||
},[_LeaderVehicle,_group] | ||||||||||
] call CBA_fnc_waitUntilAndExecute; | ||||||||||
}; | ||||||||||
|
||||||||||
waitUntil {sleep 0.4; !(_LeaderVehicle getvariable [QGVAR(ActiveVehicleMove),false])}; | ||||||||||
3Mydlo3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
// end | ||||||||||
true | ||||||||||
3Mydlo3 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "\z\afmf\addons\waypoint\script_component.hpp" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,15 @@ | ||||||
#define COMPONENT waypoint | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I think plural would be more in-place for component concerning (possibly) multiple waypoints.
Suggested change
Keep in mind renaming folder. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, do not forget to change pboprefix and folder names too. |
||||||
#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" | ||||||
|
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="Waypoint"> | ||
<Key ID="STR_AFMF_Waypoint_Vehicle_Move_Name"> | ||
<English>Direct Vehicle Move</English> | ||
<Polish>Bezpośredni ruch pojazdu</Polish> | ||
</Key> | ||
<Key ID="STR_AFMF_Waypoint_Vehicle_Move_Description"> | ||
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vehicle Move
orMove Vehicle
, stringtable naming is inconsistent with class. Also usecamelpascal case for this (VehicleMove or MoveVehicle)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually
VehicleMove
orMoveVehicle
would bePascalCase
, notcamelCase
.