Skip to content

Commit

Permalink
Added mission Wrapper/Group/503-NTTR-Route-at-waypoint-to-random-point
Browse files Browse the repository at this point in the history
  • Loading branch information
kaltokri committed Feb 25, 2024
1 parent 7f1b94c commit 0cfa011
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
-- Author: FlightControl
-- Created: 08.08.2017
-- Contributors: kaltokri
-- Modified: 24.02.2024
--
-- # Documentation:
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Group.html
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Zone.html
-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Point.html
--
-- # Description:
-- In this mission a vehicle drive (endless) to random zones when a waypoint has been reached.

-- Create a list of all zones in the mission.
local ZoneList = {
ZONE:New( "ZONE1" ),
ZONE:New( "ZONE2" ),
ZONE:New( "ZONE3" ),
ZONE:New( "ZONE4" ),
ZONE:New( "ZONE5" ),
}

-- Get object of the APC.
VehicleGroup = GROUP:FindByName( "APC" )

--- Function to ReRoute the APC to another zone.
-- @param Wrapper.Group#GROUP RoutedGroup
function ReRoute( VehicleGroup )
local ZoneNumber = math.random( 1, #ZoneList )

-- Write informations to the log.
VehicleGroup:E( "Routing" )
VehicleGroup:E( ZoneNumber )
-- Print informations on the screen
VehicleGroup:MessageToAll( "Routing to Zone" .. tostring( ZoneNumber ),30 )

-- Create Waypoints.
local FromCoord = VehicleGroup:GetCoordinate() -- Core.Point#COORDINATE
local FromWP = FromCoord:WaypointGround()

local ZoneTo = ZoneList[ ZoneNumber ] -- Core.Zone#ZONE
local ToCoord = ZoneTo:GetCoordinate()
local ToWP = ToCoord:WaypointGround( 72, "Vee" ) -- Speed 72 km/h, formation Vee.

-- Create a Task, which will be executed if the waypoint is reached.
-- It will call this function again and because of that the APC will drive endless from one random point to antoher.
local TaskReRoute = VehicleGroup:TaskFunction( "ReRoute" )
VehicleGroup:SetTaskWaypoint( ToWP, TaskReRoute )

VehicleGroup:Route( { FromWP, ToWP }, 1 )
end

ReRoute( VehicleGroup )
Binary file not shown.

0 comments on commit 0cfa011

Please sign in to comment.