calculatePath: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
||
Line 1: | Line 1: | ||
{{Command|Comments= | {{Command|Comments= | ||
| arma3 |Game= | | arma3 |Game= | ||
Line 9: | Line 8: | ||
|gr1= Object Manipulation |GROUP1= | |gr1= Object Manipulation |GROUP1= | ||
| Spawns an agent that will execute an AI path calculation and fire the <tt>"PathCalculated"</tt> [[Arma_3:_Event_Handlers#PathCalculated | event handler]]. The vehicle type to simulate could be one of the following presets: | | Spawns an agent that will execute an AI path calculation and fire the <tt>"PathCalculated"</tt> [[Arma_3:_Event_Handlers#PathCalculated | event handler]]. The vehicle type to simulate could be one of the following presets: | ||
Line 24: | Line 22: | ||
|pr= For some unknown reason, the "PathCalculated" Event Handler is fired twice, first with calculated path and second with array consisting of 2 elements, which are identical and are equal to the end point. See '''[[#Examples|Example 3 & 4]]''' for a workaround. |Problems= | |pr= For some unknown reason, the "PathCalculated" Event Handler is fired twice, first with calculated path and second with array consisting of 2 elements, which are identical and are equal to the end point. See '''[[#Examples|Example 3 & 4]]''' for a workaround. |Problems= | ||
| [[calculatePath]] [type, behaviour, from, to] |Syntax= | | [[calculatePath]] [type, behaviour, from, to] |Syntax= | ||
Line 37: | Line 34: | ||
| [[Object]] - The agent to [[addEventHandler|add]] the [[Arma 3: Event Handlers#PathCalculated|<tt>"PathCalculated"</tt> Event Handler]] to. |Return Value= | | [[Object]] - The agent to [[addEventHandler|add]] the [[Arma 3: Event Handlers#PathCalculated|<tt>"PathCalculated"</tt> Event Handler]] to. |Return Value= | ||
|x1= <code>[[calculatePath]] ["car", "safe", [2150.67,5778.19,0], [2184.11,5802.28,0]]</code> |Example 1= | |x1= <code>[[calculatePath]] ["car", "safe", [2150.67,5778.19,0], [2184.11,5802.28,0]]</code> |Example 1= | ||
Line 76: | Line 72: | ||
}]; | }]; | ||
_agent [[setDestination]] [<nowiki/>[[player]] [[getRelPos]] [500, 0], "LEADER PLANNED", [[true]]];</code> |Example 4= | _agent [[setDestination]] [<nowiki/>[[player]] [[getRelPos]] [500, 0], "LEADER PLANNED", [[true]]];</code> |Example 4= | ||
| [[setDriveOnPath]], [[setDestination]] |See Also= | | [[setDriveOnPath]], [[setDestination]] |See Also= |
Revision as of 00:28, 17 January 2021
Description
- Description:
- Spawns an agent that will execute an AI path calculation and fire the "PathCalculated" event handler. The vehicle type to simulate could be one of the following presets:
- "man" (will use "C_man_1")
- "car" (will use "C_Offroad_01_F")
- "tank" (will use "B_MBT_01_cannon_F")
- "wheeled_APC" (will use "B_APC_Tracked_01_rcws_F")
- "boat" (will use "C_Rubberboat")
- "plane" (will use "B_Plane_CAS_01_dynamicLoadout_F")
- "helicopter" (will use "B_Heli_Light_01_F")
- Problems:
- For some unknown reason, the "PathCalculated" Event Handler is fired twice, first with calculated path and second with array consisting of 2 elements, which are identical and are equal to the end point. See Example 3 & 4 for a workaround.
- Groups:
- Object Manipulation
Syntax
- Syntax:
- calculatePath [type, behaviour, from, to]
- Parameters:
- type: String - Vehicle type to simulate (see description)
- behaviour: String - AI behaviour, one of "CARELESS", "SAFE", "AWARE", "COMBAT" or "STEALTH"
- from: Array - Start position in format [x,y,z]
- to: Array - End position in format [x,y,z]
- Return Value:
- Object - The agent to add the "PathCalculated" Event Handler to.
Examples
- Example 1:
calculatePath ["car", "safe", [2150.67,5778.19,0], [2184.11,5802.28,0]]
- Example 2:
- Draws the path from South West to North East of Agia Marina:
(calculatePath ["man","safe",[2832.9,5927.79,0],[3107.46,6036.61,0]]) addEventHandler ["PathCalculated", { { private _marker = createMarker ["marker" + str _forEachIndex, _x]; _marker setMarkerType "mil_dot"; _marker setMarkerText str _forEachIndex; } forEach (_this select 1); }]
- Example 3:
- Alternative usage of calculatePath functionality that is free of double execution bug (and calculatePath command):
private _agent = createAgent [typeOf player, position player, [], 0, "NONE"]; _agent addEventHandler ["PathCalculated", { { private _marker = createMarker ["marker" + str _forEachIndex, _x]; _marker setMarkerType "mil_dot"; _marker setMarkerText str _forEachIndex; } forEach (_this select 1); }]; _agent setDestination [player getRelPos [500, 0], "LEADER PLANNED", true];
- Example 4:
- Same as above but for a vehicle:
private _agent = createAgent [typeOf player, position player, [], 0, "NONE"]; private _car = "B_Quadbike_01_F" createVehicle position player; _agent moveInDriver _car; _agent addEventHandler ["PathCalculated", { { private _marker = createMarker ["marker" + str _forEachIndex, _x]; _marker setMarkerType "mil_dot"; _marker setMarkerText str _forEachIndex; } forEach (_this select 1); }]; _agent setDestination [player getRelPos [500, 0], "LEADER PLANNED", true];
Additional Information
- See also:
- setDriveOnPathsetDestination
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
- Posted on July 6, 2019 - 10:28 (UTC)
- Tankbuster
- When using this command to get the predicted path of vehicles driving and having them stay on roads (not go cross country) is important, the best vehicle to use is "wheeled_APC" and careless behaviour.