mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'FF/Develop' into feature/Cargo/Limits
This commit is contained in:
commit
b438df27a4
@ -139,7 +139,7 @@ function AI_CARGO_APC:New( APC, CargoSet, CombatRadius )
|
|||||||
-- @function [parent=#AI_CARGO_APC] __Pickup
|
-- @function [parent=#AI_CARGO_APC] __Pickup
|
||||||
-- @param #AI_CARGO_APC self
|
-- @param #AI_CARGO_APC self
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate Pickup place. If not given, loading starts at the current location.
|
||||||
-- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do.
|
-- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do.
|
||||||
|
|
||||||
--- Deploy Handler OnBefore for AI_CARGO_APC
|
--- Deploy Handler OnBefore for AI_CARGO_APC
|
||||||
@ -170,8 +170,8 @@ function AI_CARGO_APC:New( APC, CargoSet, CombatRadius )
|
|||||||
--- Deploy Asynchronous Trigger for AI_CARGO_APC
|
--- Deploy Asynchronous Trigger for AI_CARGO_APC
|
||||||
-- @function [parent=#AI_CARGO_APC] __Deploy
|
-- @function [parent=#AI_CARGO_APC] __Deploy
|
||||||
-- @param #AI_CARGO_APC self
|
-- @param #AI_CARGO_APC self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
-- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do.
|
-- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,8 @@ AI_CARGO_AIRPLANE = {
|
|||||||
|
|
||||||
--- Creates a new AI_CARGO_AIRPLANE object.
|
--- Creates a new AI_CARGO_AIRPLANE object.
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param Wrapper.Group#GROUP Airplane Plane used for transportation of cargo.
|
||||||
-- @param Core.Set#SET_CARGO CargoSet
|
-- @param Core.Set#SET_CARGO CargoSet Cargo set to be transported.
|
||||||
-- @return #AI_CARGO_AIRPLANE
|
-- @return #AI_CARGO_AIRPLANE
|
||||||
function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
||||||
|
|
||||||
@ -45,76 +45,109 @@ function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
|||||||
self:AddTransition( "Unboarding", "Unloaded", "Unloaded" )
|
self:AddTransition( "Unboarding", "Unloaded", "Unloaded" )
|
||||||
|
|
||||||
self:AddTransition( "*", "Landed", "*" )
|
self:AddTransition( "*", "Landed", "*" )
|
||||||
|
self:AddTransition( "*", "Home" , "*" )
|
||||||
|
|
||||||
self:AddTransition( "*", "Destroyed", "Destroyed" )
|
self:AddTransition( "*", "Destroyed", "Destroyed" )
|
||||||
|
|
||||||
--- Pickup Handler OnBefore for AI_CARGO_AIRPLANE
|
--- Pickup Handler OnBefore for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] OnBeforePickup
|
-- @function [parent=#AI_CARGO_AIRPLANE] OnBeforePickup
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param #string From
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
-- @param #string Event
|
-- @param #string From From state.
|
||||||
-- @param #string To
|
-- @param #string Event Event.
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param #string To To state.
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase where troops are picked up.
|
||||||
|
-- @param #number Speed in km/h for travelling to pickup base.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- Pickup Handler OnAfter for AI_CARGO_AIRPLANE
|
--- Pickup Handler OnAfter for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] OnAfterPickup
|
-- @function [parent=#AI_CARGO_AIRPLANE] OnAfterPickup
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase where troops are picked up.
|
||||||
|
-- @param #number Speed in km/h for travelling to pickup base.
|
||||||
|
|
||||||
--- Pickup Trigger for AI_CARGO_AIRPLANE
|
--- Pickup Trigger for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] Pickup
|
-- @function [parent=#AI_CARGO_AIRPLANE] Pickup
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase where troops are picked up.
|
||||||
|
-- @param #number Speed in km/h for travelling to pickup base.
|
||||||
|
|
||||||
--- Pickup Asynchronous Trigger for AI_CARGO_AIRPLANE
|
--- Pickup Asynchronous Trigger for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] __Pickup
|
-- @function [parent=#AI_CARGO_AIRPLANE] __Pickup
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param #number Delay
|
-- @param #number Delay Delay in seconds.
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase where troops are picked up.
|
||||||
|
-- @param #number Speed in km/h for travelling to pickup base.
|
||||||
|
|
||||||
--- Deploy Handler OnBefore for AI_CARGO_AIRPLANE
|
--- Deploy Handler OnBefore for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] OnBeforeDeploy
|
-- @function [parent=#AI_CARGO_AIRPLANE] OnBeforeDeploy
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Destination airbase where troops are deployed.
|
||||||
|
-- @param #number Speed Speed in km/h for travelling to deploy base.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- Deploy Handler OnAfter for AI_CARGO_AIRPLANE
|
--- Deploy Handler OnAfter for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] OnAfterDeploy
|
-- @function [parent=#AI_CARGO_AIRPLANE] OnAfterDeploy
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Destination airbase where troops are deployed.
|
||||||
|
-- @param #number Speed Speed in km/h for travelling to deploy base.
|
||||||
|
|
||||||
--- Deploy Trigger for AI_CARGO_AIRPLANE
|
--- Deploy Trigger for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] Deploy
|
-- @function [parent=#AI_CARGO_AIRPLANE] Deploy
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Destination airbase where troops are deployed.
|
||||||
|
-- @param #number Speed Speed in km/h for travelling to deploy base.
|
||||||
|
|
||||||
--- Deploy Asynchronous Trigger for AI_CARGO_AIRPLANE
|
--- Deploy Asynchronous Trigger for AI_CARGO_AIRPLANE
|
||||||
-- @function [parent=#AI_CARGO_AIRPLANE] __Deploy
|
-- @function [parent=#AI_CARGO_AIRPLANE] __Deploy
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param #number Delay Delay in seconds.
|
||||||
-- @param #number Delay
|
-- @param Wrapper.Airbase#AIRBASE Airbase Destination airbase where troops are deployed.
|
||||||
|
-- @param #number Speed Speed in km/h for travelling to deploy base.
|
||||||
|
|
||||||
|
--- On after Loaded event, i.e. triggered when the cargo is inside the carrier.
|
||||||
|
-- @function [parent=#AI_CARGO_AIRPLANE] OnAfterLoaded
|
||||||
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
|
|
||||||
|
-- Set carrier.
|
||||||
self:SetCarrier( Airplane )
|
self:SetCarrier( Airplane )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the Carrier.
|
function AI_CARGO_AIRPLANE:IsTransporting()
|
||||||
|
|
||||||
|
return self.Transporting == true
|
||||||
|
end
|
||||||
|
|
||||||
|
function AI_CARGO_AIRPLANE:IsRelocating()
|
||||||
|
|
||||||
|
return self.Relocating == true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the Carrier (controllable). Also initializes events for carrier and defines the coalition.
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param Wrapper.Group#GROUP Airplane Transport plane.
|
||||||
-- @return #AI_CARGO_AIRPLANE
|
-- @return #AI_CARGO_AIRPLANE self
|
||||||
function AI_CARGO_AIRPLANE:SetCarrier( Airplane )
|
function AI_CARGO_AIRPLANE:SetCarrier( Airplane )
|
||||||
|
|
||||||
local AICargo = self
|
local AICargo = self
|
||||||
@ -155,7 +188,8 @@ function AI_CARGO_AIRPLANE:SetCarrier( Airplane )
|
|||||||
|
|
||||||
|
|
||||||
function Airplane:OnEventEngineShutdown( EventData )
|
function Airplane:OnEventEngineShutdown( EventData )
|
||||||
AICargo:Landed()
|
self:F("Calling")
|
||||||
|
AICargo:Landed( self.Airplane )
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Coalition = self.Airplane:GetCoalition()
|
self.Coalition = self.Airplane:GetCoalition()
|
||||||
@ -168,7 +202,7 @@ end
|
|||||||
|
|
||||||
--- Find a free Carrier within a range.
|
--- Find a free Carrier within a range.
|
||||||
-- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase
|
||||||
-- @param #number Radius
|
-- @param #number Radius
|
||||||
-- @return Wrapper.Group#GROUP NewCarrier
|
-- @return Wrapper.Group#GROUP NewCarrier
|
||||||
function AI_CARGO_AIRPLANE:FindCarrier( Coordinate, Radius )
|
function AI_CARGO_AIRPLANE:FindCarrier( Coordinate, Radius )
|
||||||
@ -190,22 +224,28 @@ function AI_CARGO_AIRPLANE:FindCarrier( Coordinate, Radius )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after "Landed" event. Called on engine shutdown and initiates the pickup mission or unloading event.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
-- @param From
|
-- @param From
|
||||||
-- @param Event
|
-- @param Event
|
||||||
-- @param To
|
-- @param To
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
|
||||||
-- @param #number Speed
|
|
||||||
function AI_CARGO_AIRPLANE:onafterLanded( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterLanded( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
self:F({Airplane, From, Event, To})
|
||||||
|
self:F({IsAlive=Airplane:IsAlive()})
|
||||||
|
self:F({RoutePickup=self.RoutePickup})
|
||||||
|
|
||||||
|
if Airplane and Airplane:IsAlive()~=nil then
|
||||||
|
|
||||||
|
-- Aircraft was sent to this airbase to pickup troops. Initiate loadling.
|
||||||
if self.RoutePickup == true then
|
if self.RoutePickup == true then
|
||||||
self:Load( Airplane:GetPointVec2() )
|
env.info("FF load airplane "..Airplane:GetName())
|
||||||
|
self:Load( Airplane:GetCoordinate() )
|
||||||
self.RoutePickup = false
|
self.RoutePickup = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Aircraft was send to this airbase to deploy troops. Initiate unloading.
|
||||||
if self.RouteDeploy == true then
|
if self.RouteDeploy == true then
|
||||||
self:Unload()
|
self:Unload()
|
||||||
self.RouteDeploy = false
|
self.RouteDeploy = false
|
||||||
@ -216,63 +256,132 @@ function AI_CARGO_AIRPLANE:onafterLanded( Airplane, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- On after "Pickup" event. Routes transport to pickup airbase.
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
-- @param From
|
-- @param #string From From state.
|
||||||
-- @param Event
|
-- @param #string Event Event.
|
||||||
-- @param To
|
-- @param #string To To state.
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase where the troops as picked up.
|
||||||
-- @param #number Speed
|
-- @param #number Speed in km/h for travelling to pickup base.
|
||||||
function AI_CARGO_AIRPLANE:onafterPickup( Airplane, From, Event, To, Airbase, Speed )
|
function AI_CARGO_AIRPLANE:onafterPickup( Airplane, From, Event, To, Airbase, Speed )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive()~=nil then
|
||||||
self:Route( Airplane, Airbase, Speed )
|
env.info("FF onafterpick aircraft alive")
|
||||||
self.RoutePickup = true
|
|
||||||
self.Airbase = Airbase
|
-- Get closest airbase of current position.
|
||||||
|
local ClosestAirbase, DistToAirbase=Airplane:GetCoordinate():GetClosestAirbase()
|
||||||
|
|
||||||
|
env.info("FF onafterpickup closest airbase "..ClosestAirbase:GetName())
|
||||||
|
|
||||||
|
-- Two cases. Aircraft spawned in air or at an airbase.
|
||||||
|
if Airplane:InAir() then
|
||||||
|
self.Airbase=nil --> route will start in air
|
||||||
|
else
|
||||||
|
self.Airbase=ClosestAirbase
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Distance from closest to pickup airbase ==> we need to know if we are already at the pickup airbase.
|
||||||
|
local Dist=Airbase:GetCoordinate():Get2DDistance(ClosestAirbase:GetCoordinate())
|
||||||
|
env.info("Distance closest to pickup airbase = "..Dist)
|
||||||
|
|
||||||
|
if Airplane:InAir() or Dist>500 then
|
||||||
|
|
||||||
|
env.info("FF onafterpickup routing to airbase "..ClosestAirbase:GetName())
|
||||||
|
|
||||||
|
-- Route aircraft to pickup airbase.
|
||||||
|
self:Route( Airplane, Airbase, Speed )
|
||||||
|
|
||||||
|
-- Set airbase as starting point in the next Route() call.
|
||||||
|
self.Airbase = Airbase
|
||||||
|
|
||||||
|
-- Aircraft is on a pickup mission.
|
||||||
|
self.RoutePickup = true
|
||||||
|
|
||||||
|
-- Unclear!?
|
||||||
|
self.Transporting = true
|
||||||
|
self.Relocating = false
|
||||||
|
else
|
||||||
|
env.info("FF onafterpick calling landed")
|
||||||
|
|
||||||
|
-- We are already at the right airbase ==> Landed ==> triggers loading of troops. Is usually called at engine shutdown event.
|
||||||
|
self.RoutePickup=true
|
||||||
|
self:Landed()
|
||||||
|
|
||||||
|
end
|
||||||
|
else
|
||||||
|
env.info("FF onafterpick aircraft not alive")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- On after Depoly event. Routes plane to the airbase where the troops are deployed.
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
-- @param From
|
-- @param #string From From state.
|
||||||
-- @param Event
|
-- @param #string Event Event.
|
||||||
-- @param To
|
-- @param #string To To state.
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase where troups should be deployed.
|
||||||
-- @param #number Speed
|
-- @param #number Speed Speed in km/h for travelling to deploy base.
|
||||||
function AI_CARGO_AIRPLANE:onafterDeploy( Airplane, From, Event, To, Airbase, Speed )
|
function AI_CARGO_AIRPLANE:onafterDeploy( Airplane, From, Event, To, Airbase, Speed )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive()~=nil then
|
||||||
|
|
||||||
|
-- Activate uncontrolled airplane.
|
||||||
|
if Airplane:IsAlive()==false then
|
||||||
|
Airplane:SetCommand({id = 'Start', params = {}})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Route to destination airbase.
|
||||||
self:Route( Airplane, Airbase, Speed )
|
self:Route( Airplane, Airbase, Speed )
|
||||||
|
|
||||||
|
-- Aircraft is on a depoly mission.
|
||||||
self.RouteDeploy = true
|
self.RouteDeploy = true
|
||||||
|
|
||||||
|
-- Set destination airbase for next :Route() command.
|
||||||
self.Airbase = Airbase
|
self.Airbase = Airbase
|
||||||
|
|
||||||
|
-- Unclear?!
|
||||||
|
self.Transporting = false
|
||||||
|
self.Relocating = false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Load event. Checks if cargo is inside the load radius and if so starts the boarding process.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Transport plane.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Wrapper.Point#COORDINATE Coordinate Place where the cargo is guided to if it is inside the load radius.
|
||||||
function AI_CARGO_AIRPLANE:onafterLoad( Airplane, From, Event, To, Coordinate )
|
function AI_CARGO_AIRPLANE:onafterLoad( Airplane, From, Event, To, Coordinate )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive()~=nil then
|
||||||
|
|
||||||
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _,_Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
if Cargo:IsInLoadRadius( Coordinate ) then
|
self:F({_Cargo:GetName()})
|
||||||
|
local Cargo=_Cargo --Cargo.Cargo#CARGO
|
||||||
|
local InRadius = Cargo:IsInLoadRadius( Coordinate )
|
||||||
|
if InRadius then
|
||||||
self:__Board( 5 )
|
self:__Board( 5 )
|
||||||
Cargo:Board( Airplane, 25 )
|
Cargo:Board( Airplane, 25 )
|
||||||
self.Cargo = Cargo
|
self.Cargo = Cargo
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Board event. Cargo is inside the load radius and boarding is performed.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
@ -286,18 +395,28 @@ function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Loaded event. Cargo is inside the carrier and ready to be transported.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
function AI_CARGO_AIRPLANE:onafterLoaded( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterLoaded( Airplane, From, Event, To )
|
||||||
|
|
||||||
|
env.info("FF troops loaded into cargo plane")
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Unload event. Cargo is beeing unloaded, i.e. the unboarding process is started.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
@ -307,8 +426,12 @@ function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Unboard event. Checks if unboarding process is finished.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
function AI_CARGO_AIRPLANE:onafterUnboard( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterUnboard( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
@ -321,8 +444,12 @@ function AI_CARGO_AIRPLANE:onafterUnboard( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Unloaded event. Cargo has been unloaded, i.e. the unboarding process is finished.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo transport plane.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
function AI_CARGO_AIRPLANE:onafterUnloaded( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterUnloaded( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
@ -331,116 +458,74 @@ function AI_CARGO_AIRPLANE:onafterUnloaded( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Route the airplane from one airport or it's current position to another airbase.
|
||||||
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Airplane group to be routed.
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE Airbase Destination airbase.
|
||||||
|
-- @param #number Speed Speed in km/h. Default is 80% of max possible speed the group can do.
|
||||||
|
-- @param #boolean Uncontrolled If true, spawn group in uncontrolled state.
|
||||||
|
function AI_CARGO_AIRPLANE:Route( Airplane, Airbase, Speed, Uncontrolled )
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
if Airplane and Airplane:IsAlive()~=nil then
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase
|
|
||||||
-- @param #number Speed
|
|
||||||
function AI_CARGO_AIRPLANE:Route( Airplane, Airbase, Speed )
|
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
-- Set takeoff type.
|
||||||
|
local Takeoff = SPAWN.Takeoff.Cold
|
||||||
local PointVec3 = Airplane:GetPointVec3()
|
|
||||||
|
|
||||||
local Takeoff = SPAWN.Takeoff.Hot
|
|
||||||
|
|
||||||
|
-- Get template of group.
|
||||||
local Template = Airplane:GetTemplate()
|
local Template = Airplane:GetTemplate()
|
||||||
|
|
||||||
if Template then
|
|
||||||
|
|
||||||
local Points = {}
|
|
||||||
|
|
||||||
if self.Airbase then
|
|
||||||
|
|
||||||
local FromWaypoint = Template.route.points[1]
|
|
||||||
|
|
||||||
-- These are only for ships.
|
-- Nil check
|
||||||
FromWaypoint.linkUnit = nil
|
if Template==nil then
|
||||||
FromWaypoint.helipadId = nil
|
return
|
||||||
FromWaypoint.airdromeId = nil
|
|
||||||
|
|
||||||
local AirbaseID = self.Airbase:GetID()
|
|
||||||
local AirbaseCategory = self.Airbase:GetDesc().category
|
|
||||||
|
|
||||||
FromWaypoint.airdromeId = AirbaseID
|
|
||||||
|
|
||||||
FromWaypoint.alt = 0
|
|
||||||
|
|
||||||
FromWaypoint.type = GROUPTEMPLATE.Takeoff[Takeoff][1] -- type
|
|
||||||
FromWaypoint.action = GROUPTEMPLATE.Takeoff[Takeoff][2] -- action
|
|
||||||
|
|
||||||
|
|
||||||
-- Translate the position of the Group Template to the Vec3.
|
|
||||||
for UnitID = 1, #Template.units do
|
|
||||||
self:T( 'Before Translation SpawnTemplate.units['..UnitID..'].x = ' .. Template.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. Template.units[UnitID].y )
|
|
||||||
|
|
||||||
-- These cause a lot of confusion.
|
|
||||||
local UnitTemplate = Template.units[UnitID]
|
|
||||||
|
|
||||||
UnitTemplate.parking = 15
|
|
||||||
UnitTemplate.parking_id = "1"
|
|
||||||
UnitTemplate.alt = 0
|
|
||||||
|
|
||||||
local SX = UnitTemplate.x
|
|
||||||
local SY = UnitTemplate.y
|
|
||||||
local BX = FromWaypoint.x
|
|
||||||
local BY = FromWaypoint.y
|
|
||||||
local TX = PointVec3.x + ( SX - BX )
|
|
||||||
local TY = PointVec3.z + ( SY - BY )
|
|
||||||
|
|
||||||
UnitTemplate.x = TX
|
|
||||||
UnitTemplate.y = TY
|
|
||||||
|
|
||||||
self:T( 'After Translation SpawnTemplate.units['..UnitID..'].x = ' .. UnitTemplate.x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. UnitTemplate.y )
|
|
||||||
end
|
|
||||||
|
|
||||||
FromWaypoint.x = PointVec3.x
|
|
||||||
FromWaypoint.y = PointVec3.z
|
|
||||||
|
|
||||||
Points[#Points+1] = FromWaypoint
|
|
||||||
else
|
|
||||||
|
|
||||||
local GroupPoint = Airplane:GetVec2()
|
|
||||||
local GroupVelocity = Airplane:GetUnit(1):GetDesc().speedMax
|
|
||||||
|
|
||||||
local FromWaypoint = {}
|
|
||||||
FromWaypoint.x = GroupPoint.x
|
|
||||||
FromWaypoint.y = GroupPoint.y
|
|
||||||
FromWaypoint.type = "Turning Point"
|
|
||||||
FromWaypoint.action = "Turning Point"
|
|
||||||
FromWaypoint.speed = GroupVelocity
|
|
||||||
|
|
||||||
Points[#Points+1] = FromWaypoint
|
|
||||||
end
|
|
||||||
|
|
||||||
local AirbasePointVec2 = Airbase:GetPointVec2()
|
|
||||||
local ToWaypoint = AirbasePointVec2:WaypointAir(
|
|
||||||
POINT_VEC3.RoutePointAltType.BARO,
|
|
||||||
"Land",
|
|
||||||
"Landing",
|
|
||||||
Speed or Airplane:GetUnit(1):GetDesc().speedMax
|
|
||||||
)
|
|
||||||
|
|
||||||
ToWaypoint["airdromeId"] = Airbase:GetID()
|
|
||||||
ToWaypoint["speed_locked"] = true,
|
|
||||||
|
|
||||||
self:F( ToWaypoint )
|
|
||||||
|
|
||||||
Points[#Points+1] = ToWaypoint
|
|
||||||
|
|
||||||
Template.x = PointVec3.x
|
|
||||||
Template.y = PointVec3.z
|
|
||||||
|
|
||||||
self:T3( Points )
|
|
||||||
Template.route.points = Points
|
|
||||||
|
|
||||||
--self:Respawn( Template )
|
|
||||||
|
|
||||||
local GroupSpawned = Airplane:Respawn( Template )
|
|
||||||
|
|
||||||
return GroupSpawned
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
-- Waypoints of the route.
|
||||||
|
local Points={}
|
||||||
|
|
||||||
|
-- To point.
|
||||||
|
local AirbasePointVec2 = Airbase:GetPointVec2()
|
||||||
|
local ToWaypoint = AirbasePointVec2:WaypointAir(
|
||||||
|
POINT_VEC3.RoutePointAltType.BARO,
|
||||||
|
"Land",
|
||||||
|
"Landing",
|
||||||
|
Speed or Airplane:GetSpeedMax()*0.8
|
||||||
|
)
|
||||||
|
ToWaypoint["airdromeId"] = Airbase:GetID()
|
||||||
|
ToWaypoint["speed_locked"] = true
|
||||||
|
|
||||||
|
|
||||||
|
-- If self.Airbase~=nil then group is currently at an airbase, where it should be respawned.
|
||||||
|
if self.Airbase then
|
||||||
|
|
||||||
|
-- Second point of the route. First point is done in RespawnAtCurrentAirbase() routine.
|
||||||
|
Template.route.points[2] = ToWaypoint
|
||||||
|
|
||||||
|
-- Respawn group at the current airbase.
|
||||||
|
Airplane:RespawnAtCurrentAirbase(Template, Takeoff, Uncontrolled)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- From point.
|
||||||
|
local GroupPoint = Airplane:GetVec2()
|
||||||
|
local FromWaypoint = {}
|
||||||
|
FromWaypoint.x = GroupPoint.x
|
||||||
|
FromWaypoint.y = GroupPoint.y
|
||||||
|
FromWaypoint.type = "Turning Point"
|
||||||
|
FromWaypoint.action = "Turning Point"
|
||||||
|
FromWaypoint.speed = Airplane:GetSpeedMax()*0.8
|
||||||
|
|
||||||
|
-- The two route points.
|
||||||
|
Points[1] = FromWaypoint
|
||||||
|
Points[2] = ToWaypoint
|
||||||
|
|
||||||
|
local PointVec3 = Airplane:GetPointVec3()
|
||||||
|
Template.x = PointVec3.x
|
||||||
|
Template.y = PointVec3.z
|
||||||
|
|
||||||
|
Template.route.points = Points
|
||||||
|
|
||||||
|
local GroupSpawned = Airplane:Respawn(Template)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -74,7 +74,7 @@
|
|||||||
AI_CARGO_DISPATCHER = {
|
AI_CARGO_DISPATCHER = {
|
||||||
ClassName = "AI_CARGO_DISPATCHER",
|
ClassName = "AI_CARGO_DISPATCHER",
|
||||||
SetCarrier = nil,
|
SetCarrier = nil,
|
||||||
SetDeployZones = nil,
|
DeployZonesSet = nil,
|
||||||
AI_Cargo = {},
|
AI_Cargo = {},
|
||||||
PickupCargo = {}
|
PickupCargo = {}
|
||||||
}
|
}
|
||||||
@ -90,23 +90,21 @@ AI_CARGO_DISPATCHER.PickupCargo = {}
|
|||||||
-- @param #AI_CARGO_DISPATCHER self
|
-- @param #AI_CARGO_DISPATCHER self
|
||||||
-- @param Core.Set#SET_GROUP SetCarrier
|
-- @param Core.Set#SET_GROUP SetCarrier
|
||||||
-- @param Core.Set#SET_CARGO SetCargo
|
-- @param Core.Set#SET_CARGO SetCargo
|
||||||
-- @param Core.Set#SET_ZONE SetDeployZones
|
|
||||||
-- @return #AI_CARGO_DISPATCHER
|
-- @return #AI_CARGO_DISPATCHER
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Create a new cargo dispatcher
|
-- -- Create a new cargo dispatcher
|
||||||
-- SetCarrier = SET_GROUP:New():FilterPrefixes( "APC" ):FilterStart()
|
-- SetCarriers = SET_GROUP:New():FilterPrefixes( "APC" ):FilterStart()
|
||||||
-- SetCargo = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
-- SetCargos = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
||||||
-- SetDeployZone = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart()
|
-- SetDeployZone = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart()
|
||||||
-- AICargoDispatcher = AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo, SetDeployZone )
|
-- AICargoDispatcher = AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo )
|
||||||
--
|
--
|
||||||
function AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo, SetDeployZones )
|
function AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, FSM:New() ) -- #AI_CARGO_DISPATCHER
|
local self = BASE:Inherit( self, FSM:New() ) -- #AI_CARGO_DISPATCHER
|
||||||
|
|
||||||
self.SetCarrier = SetCarrier -- Core.Set#SET_GROUP
|
self.SetCarrier = SetCarrier -- Core.Set#SET_GROUP
|
||||||
self.SetCargo = SetCargo -- Core.Set#SET_CARGO
|
self.SetCargo = SetCargo -- Core.Set#SET_CARGO
|
||||||
self.SetDeployZones = SetDeployZones -- Core.Set#SET_ZONE
|
|
||||||
|
|
||||||
self:SetStartState( "Idle" )
|
self:SetStartState( "Idle" )
|
||||||
|
|
||||||
@ -144,6 +142,58 @@ function AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo, SetDeployZones )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Creates a new AI_CARGO_DISPATCHER object.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER self
|
||||||
|
-- @param Core.Set#SET_GROUP SetCarrier
|
||||||
|
-- @param Core.Set#SET_CARGO SetCargo
|
||||||
|
-- @param Core.Set#SET_ZONE DeployZonesSet
|
||||||
|
-- @return #AI_CARGO_DISPATCHER
|
||||||
|
-- @usage
|
||||||
|
--
|
||||||
|
-- -- Create a new cargo dispatcher
|
||||||
|
-- SetCarriers = SET_GROUP:New():FilterPrefixes( "APC" ):FilterStart()
|
||||||
|
-- SetCargos = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
||||||
|
-- DeployZonesSet = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart()
|
||||||
|
-- AICargoDispatcher = AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo, SetDeployZone )
|
||||||
|
--
|
||||||
|
function AI_CARGO_DISPATCHER:NewWithZones( SetCarriers, SetCargos, DeployZonesSet )
|
||||||
|
|
||||||
|
local self = AI_CARGO_DISPATCHER:New( SetCarriers, SetCargos ) -- #AI_CARGO_DISPATCHER
|
||||||
|
|
||||||
|
self.DeployZonesSet = DeployZonesSet
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Creates a new AI_CARGO_DISPATCHER object.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER self
|
||||||
|
-- @param Core.Set#SET_GROUP SetCarrier
|
||||||
|
-- @param Core.Set#SET_CARGO SetCargo
|
||||||
|
-- @param Core.Set#SET_AIRBASE PickupAirbasesSet
|
||||||
|
-- @param Core.Set#SET_AIRBASE DeployAirbasesSet
|
||||||
|
-- @return #AI_CARGO_DISPATCHER
|
||||||
|
-- @usage
|
||||||
|
--
|
||||||
|
-- -- Create a new cargo dispatcher
|
||||||
|
-- SetCarriers = SET_GROUP:New():FilterPrefixes( "APC" ):FilterStart()
|
||||||
|
-- SetCargos = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
||||||
|
-- PickupAirbasesSet = SET_AIRBASES:New()
|
||||||
|
-- DeployAirbasesSet = SET_AIRBASES:New()
|
||||||
|
-- AICargoDispatcher = AI_CARGO_DISPATCHER:New( SetCarrier, SetCargo, PickupAirbasesSet, DeployAirbasesSet )
|
||||||
|
--
|
||||||
|
function AI_CARGO_DISPATCHER:NewWithAirbases( SetCarriers, SetCargos, PickupAirbasesSet, DeployAirbasesSet )
|
||||||
|
|
||||||
|
local self = AI_CARGO_DISPATCHER:New( SetCarriers, SetCargos ) -- #AI_CARGO_DISPATCHER
|
||||||
|
|
||||||
|
self.DeployAirbasesSet = DeployAirbasesSet
|
||||||
|
self.PickupAirbasesSet = PickupAirbasesSet
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Set the home zone.
|
--- Set the home zone.
|
||||||
-- When there is nothing anymore to pickup, the carriers will go to a random coordinate in this zone.
|
-- When there is nothing anymore to pickup, the carriers will go to a random coordinate in this zone.
|
||||||
-- They will await here new orders.
|
-- They will await here new orders.
|
||||||
@ -166,6 +216,31 @@ function AI_CARGO_DISPATCHER:SetHomeZone( HomeZone )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set the home airbase. This is for air units, i.e. helicopters and airplanes.
|
||||||
|
-- When there is nothing anymore to pickup, the carriers will go back to their home base. They will await here new orders.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE HomeBase Airbase where the carriers will go after all pickup assignments are done.
|
||||||
|
-- @return #AI_CARGO_DISPATCHER self
|
||||||
|
function AI_CARGO_DISPATCHER:SetHomeBase( HomeBase )
|
||||||
|
|
||||||
|
self.HomeBase = HomeBase
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the home base.
|
||||||
|
-- When there is nothing anymore to pickup, the carriers will return to their home airbase. There they will await new orders.
|
||||||
|
-- @param #AI_CARGO_DISPATCHER self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE HomeBase The airbase where the carrier will go to, once they completed all pending assignments.
|
||||||
|
-- @return #AI_CARGO_DISPATCHER self
|
||||||
|
function AI_CARGO_DISPATCHER:SetHomeBase( HomeBase )
|
||||||
|
|
||||||
|
self.HomeBase = HomeBase
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets or randomizes the pickup location for the carrier around the cargo coordinate in a radius defined an outer and optional inner radius.
|
--- Sets or randomizes the pickup location for the carrier around the cargo coordinate in a radius defined an outer and optional inner radius.
|
||||||
-- This radius is influencing the location where the carrier will land to pickup the cargo.
|
-- This radius is influencing the location where the carrier will land to pickup the cargo.
|
||||||
@ -358,10 +433,20 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if PickupCargo then
|
if PickupCargo then
|
||||||
self.CarrierHome[Carrier] = nil
|
self.CarrierHome[Carrier] = nil
|
||||||
local PickupCoordinate = PickupCargo:GetCoordinate():GetRandomCoordinateInRadius( self.PickupOuterRadius, self.PickupInnerRadius )
|
local PickupCoordinate = PickupCargo:GetCoordinate():GetRandomCoordinateInRadius( self.PickupOuterRadius, self.PickupInnerRadius )
|
||||||
AI_Cargo:Pickup( PickupCoordinate, math.random( self.PickupMinSpeed, self.PickupMaxSpeed ) )
|
|
||||||
|
if self.PickupAirbasesSet then
|
||||||
|
-- Find airbase within 2km from the cargo with the set.
|
||||||
|
local PickupAirbase = self.PickupAirbasesSet:FindAirbaseInRange( PickupCoordinate, 4000 )
|
||||||
|
if PickupAirbase then
|
||||||
|
AI_Cargo:Pickup( PickupAirbase, math.random( self.PickupMinSpeed, self.PickupMaxSpeed ) )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
AI_Cargo:Pickup( PickupCoordinate, math.random( self.PickupMinSpeed, self.PickupMaxSpeed ) )
|
||||||
|
end
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
if self.HomeZone then
|
if self.HomeZone then
|
||||||
@ -464,12 +549,22 @@ end
|
|||||||
-- @return #AI_CARGO_DISPATCHER
|
-- @return #AI_CARGO_DISPATCHER
|
||||||
function AI_CARGO_DISPATCHER:OnAfterLoaded( From, Event, To, Carrier, Cargo )
|
function AI_CARGO_DISPATCHER:OnAfterLoaded( From, Event, To, Carrier, Cargo )
|
||||||
|
|
||||||
local DeployZone = self.SetDeployZones:GetRandomZone()
|
if self.DeployZonesSet then
|
||||||
|
|
||||||
local DeployCoordinate = DeployZone:GetCoordinate():GetRandomCoordinateInRadius( self.DeployOuterRadius, self.DeployInnerRadius )
|
local DeployZone = self.DeployZonesSet:GetRandomZone()
|
||||||
self.AI_Cargo[Carrier]:Deploy( DeployCoordinate, math.random( self.DeployMinSpeed, self.DeployMaxSpeed ) )
|
|
||||||
|
local DeployCoordinate = DeployZone:GetCoordinate():GetRandomCoordinateInRadius( self.DeployOuterRadius, self.DeployInnerRadius )
|
||||||
|
self.AI_Cargo[Carrier]:Deploy( DeployCoordinate, math.random( self.DeployMinSpeed, self.DeployMaxSpeed ) )
|
||||||
|
|
||||||
self.PickupCargo[Carrier] = nil
|
end
|
||||||
|
|
||||||
|
if self.DeployAirbasesSet then
|
||||||
|
|
||||||
|
local DeployAirbase = self.DeployAirbasesSet:GetRandomAirbase()
|
||||||
|
self.AI_Cargo[Carrier]:Deploy( DeployAirbase, math.random( self.DeployMinSpeed, self.DeployMaxSpeed ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
self.PickupCargo[Carrier] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@ AI_CARGO_DISPATCHER_APC = {
|
|||||||
-- SetDeployZone = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart()
|
-- SetDeployZone = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart()
|
||||||
-- AICargoDispatcher = AI_CARGO_DISPATCHER_APC:New( SetAPC, SetCargo, SetDeployZone, 500 )
|
-- AICargoDispatcher = AI_CARGO_DISPATCHER_APC:New( SetAPC, SetCargo, SetDeployZone, 500 )
|
||||||
--
|
--
|
||||||
function AI_CARGO_DISPATCHER_APC:New( SetAPC, SetCargo, SetDeployZone, CombatRadius )
|
function AI_CARGO_DISPATCHER_APC:NewWithZones( SetAPC, SetCargo, SetDeployZone, CombatRadius )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, AI_CARGO_DISPATCHER:New( SetAPC, SetCargo, SetDeployZone ) ) -- #AI_CARGO_DISPATCHER_APC
|
local self = BASE:Inherit( self, AI_CARGO_DISPATCHER:New( SetAPC, SetCargo, SetDeployZone ) ) -- #AI_CARGO_DISPATCHER_APC
|
||||||
|
|
||||||
|
|||||||
@ -16,8 +16,8 @@
|
|||||||
--- Brings a dynamic cargo handling capability for AI groups.
|
--- Brings a dynamic cargo handling capability for AI groups.
|
||||||
--
|
--
|
||||||
-- Airplanes can be mobilized to intelligently transport infantry and other cargo within the simulation.
|
-- Airplanes can be mobilized to intelligently transport infantry and other cargo within the simulation.
|
||||||
-- The AI\_CARGO\_DISPATCHER\_AIRPLANE module uses the @{Cargo} capabilities within the MOOSE framework.
|
-- The AI_CARGO_DISPATCHER_AIRPLANE module uses the @{Cargo} capabilities within the MOOSE framework.
|
||||||
-- CARGO derived objects must be declared within the mission to make the AI\_CARGO\_DISPATCHER\_AIRPLANE object recognize the cargo.
|
-- CARGO derived objects must be declared within the mission to make the AI_CARGO_DISPATCHER_AIRPLANE object recognize the cargo.
|
||||||
-- Please consult the @{Cargo} module for more information.
|
-- Please consult the @{Cargo} module for more information.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
@ -29,23 +29,33 @@ AI_CARGO_DISPATCHER_AIRPLANE = {
|
|||||||
|
|
||||||
--- Creates a new AI_CARGO_DISPATCHER_AIRPLANE object.
|
--- Creates a new AI_CARGO_DISPATCHER_AIRPLANE object.
|
||||||
-- @param #AI_CARGO_DISPATCHER_AIRPLANE self
|
-- @param #AI_CARGO_DISPATCHER_AIRPLANE self
|
||||||
-- @param Core.Set#SET_GROUP SetAirplane
|
-- @param Core.Set#SET_GROUP SetAirplanes Set of cargo transport airplanes.
|
||||||
-- @param Core.Set#SET_CARGO SetCargo
|
-- @param Core.Set#SET_CARGO SetCargos Set of cargo, which is supposed to be transported.
|
||||||
-- @param Core.Set#SET_ZONE SetDeployZone
|
-- @param Core.Set#SET_AIRBASE PickupAirbasesSet Set of airbases where the cargo has to be picked up.
|
||||||
-- @return #AI_CARGO_DISPATCHER_AIRPLANE
|
-- @param Core.Set#SET_AIRBASE DeployAirbasesSet Set of airbases where the cargo is deployed. Choice for each cargo is random.
|
||||||
|
-- @return #AI_CARGO_DISPATCHER_AIRPLANE self
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
--
|
||||||
-- -- Create a new cargo dispatcher
|
-- -- Create a new cargo dispatcher
|
||||||
-- SetAirplane = SET_GROUP:New():FilterPrefixes( "Airplane" ):FilterStart()
|
-- SetAirplanes = SET_GROUP:New():FilterPrefixes( "Airplane" ):FilterStart()
|
||||||
-- SetCargo = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
-- SetCargos = SET_CARGO:New():FilterTypes( "Infantry" ):FilterStart()
|
||||||
-- SetDeployZone = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart()
|
-- PickupAirbasesSet = SET_AIRBASE:New()
|
||||||
-- AICargoDispatcher = AI_CARGO_DISPATCHER_AIRPLANE:New( SetAirplane, SetCargo )
|
-- DeployAirbasesSet = SET_AIRBASE:New()
|
||||||
|
-- AICargoDispatcher = AI_CARGO_DISPATCHER_AIRPLANE:New( SetAirplanes, SetCargos, PickupAirbasesSet, DeployAirbasesSet )
|
||||||
--
|
--
|
||||||
function AI_CARGO_DISPATCHER_AIRPLANE:New( SetAirplane, SetCargo, SetDeployZones )
|
function AI_CARGO_DISPATCHER_AIRPLANE:New( SetAirplanes, SetCargos, PickupAirbasesSet, DeployAirbasesSet )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, AI_CARGO_DISPATCHER:New( SetAirplane, SetCargo, SetDeployZones ) ) -- #AI_CARGO_DISPATCHER_AIRPLANE
|
local self = BASE:Inherit( self, AI_CARGO_DISPATCHER:NewWithAirbases( SetAirplanes, SetCargos, PickupAirbasesSet, DeployAirbasesSet ) ) -- #AI_CARGO_DISPATCHER_AIRPLANE
|
||||||
|
|
||||||
|
self:SetDeploySpeed( 200, 150 )
|
||||||
|
self:SetPickupSpeed( 200, 150 )
|
||||||
|
self:SetPickupRadius( 0, 0 )
|
||||||
|
self:SetDeployRadius( 0, 0 )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function AI_CARGO_DISPATCHER_AIRPLANE:AICargo( Airplane, SetCargo )
|
||||||
|
|
||||||
|
return AI_CARGO_AIRPLANE:New( Airplane, SetCargo )
|
||||||
|
end
|
||||||
|
|||||||
@ -102,7 +102,7 @@ AI_CARGO_DISPATCHER_HELICOPTER = {
|
|||||||
--
|
--
|
||||||
function AI_CARGO_DISPATCHER_HELICOPTER:New( SetHelicopter, SetCargo, SetDeployZones )
|
function AI_CARGO_DISPATCHER_HELICOPTER:New( SetHelicopter, SetCargo, SetDeployZones )
|
||||||
|
|
||||||
local self = BASE:Inherit( self, AI_CARGO_DISPATCHER:New( SetHelicopter, SetCargo, SetDeployZones ) ) -- #AI_CARGO_DISPATCHER_HELICOPTER
|
local self = BASE:Inherit( self, AI_CARGO_DISPATCHER:NewWithZones( SetHelicopter, SetCargo, SetDeployZones ) ) -- #AI_CARGO_DISPATCHER_HELICOPTER
|
||||||
|
|
||||||
self:SetDeploySpeed( 200, 150 )
|
self:SetDeploySpeed( 200, 150 )
|
||||||
self:SetPickupSpeed( 200, 150 )
|
self:SetPickupSpeed( 200, 150 )
|
||||||
|
|||||||
@ -73,17 +73,20 @@ function AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
|||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
|
|
||||||
--- Pickup Trigger for AI_CARGO_HELICOPTER
|
--- Pickup Trigger for AI_CARGO_HELICOPTER
|
||||||
-- @function [parent=#AI_CARGO_HELICOPTER] Pickup
|
-- @function [parent=#AI_CARGO_HELICOPTER] Pickup
|
||||||
-- @param #AI_CARGO_HELICOPTER self
|
-- @param #AI_CARGO_HELICOPTER self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
|
|
||||||
--- Pickup Asynchronous Trigger for AI_CARGO_HELICOPTER
|
--- Pickup Asynchronous Trigger for AI_CARGO_HELICOPTER
|
||||||
-- @function [parent=#AI_CARGO_HELICOPTER] __Pickup
|
-- @function [parent=#AI_CARGO_HELICOPTER] __Pickup
|
||||||
-- @param #AI_CARGO_HELICOPTER self
|
-- @param #AI_CARGO_HELICOPTER self
|
||||||
-- @param #number Delay
|
-- @param #number Delay Delay in seconds.
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
|
-- @param #number Speed Speed in km/h to go to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
|
|
||||||
--- Deploy Handler OnBefore for AI_CARGO_HELICOPTER
|
--- Deploy Handler OnBefore for AI_CARGO_HELICOPTER
|
||||||
-- @function [parent=#AI_CARGO_HELICOPTER] OnBeforeDeploy
|
-- @function [parent=#AI_CARGO_HELICOPTER] OnBeforeDeploy
|
||||||
@ -91,7 +94,8 @@ function AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate Place at which cargo is deployed.
|
||||||
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- Deploy Handler OnAfter for AI_CARGO_HELICOPTER
|
--- Deploy Handler OnAfter for AI_CARGO_HELICOPTER
|
||||||
@ -101,18 +105,21 @@ function AI_CARGO_HELICOPTER:New( Helicopter, CargoSet )
|
|||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
|
|
||||||
--- Deploy Trigger for AI_CARGO_HELICOPTER
|
--- Deploy Trigger for AI_CARGO_HELICOPTER
|
||||||
-- @function [parent=#AI_CARGO_HELICOPTER] Deploy
|
-- @function [parent=#AI_CARGO_HELICOPTER] Deploy
|
||||||
-- @param #AI_CARGO_HELICOPTER self
|
-- @param #AI_CARGO_HELICOPTER self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate Place at which the cargo is deployed.
|
||||||
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
|
|
||||||
--- Deploy Asynchronous Trigger for AI_CARGO_HELICOPTER
|
--- Deploy Asynchronous Trigger for AI_CARGO_HELICOPTER
|
||||||
-- @function [parent=#AI_CARGO_HELICOPTER] __Deploy
|
-- @function [parent=#AI_CARGO_HELICOPTER] __Deploy
|
||||||
|
-- @param #number Delay Delay in seconds.
|
||||||
-- @param #AI_CARGO_HELICOPTER self
|
-- @param #AI_CARGO_HELICOPTER self
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate Place at which the cargo is deployed.
|
||||||
-- @param #number Delay
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
|
|
||||||
|
|
||||||
-- We need to capture the Crash events for the helicopters.
|
-- We need to capture the Crash events for the helicopters.
|
||||||
-- The helicopter reference is used in the semaphore AI_CARGO_QUEUE.
|
-- The helicopter reference is used in the semaphore AI_CARGO_QUEUE.
|
||||||
@ -217,7 +224,8 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
|
|||||||
|
|
||||||
if self.RoutePickup == true then
|
if self.RoutePickup == true then
|
||||||
if Helicopter:GetHeight( true ) <= 5 and Helicopter:GetVelocityKMH() < 10 then
|
if Helicopter:GetHeight( true ) <= 5 and Helicopter:GetVelocityKMH() < 10 then
|
||||||
self:Load( Helicopter:GetPointVec2() )
|
--self:Load( Helicopter:GetPointVec2() )
|
||||||
|
self:Load()
|
||||||
self.RoutePickup = false
|
self.RoutePickup = false
|
||||||
self.Relocating = true
|
self.Relocating = true
|
||||||
end
|
end
|
||||||
@ -422,7 +430,7 @@ function AI_CARGO_HELICOPTER:onafterBoard( Helicopter, From, Event, To, Cargo )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On before Land event.
|
--- On before Loaded event. Check if cargo is loaded.
|
||||||
-- @param #AI_CARGO_HELICOPTER self
|
-- @param #AI_CARGO_HELICOPTER self
|
||||||
-- @param Wrapper.Group#GROUP Helicopter
|
-- @param Wrapper.Group#GROUP Helicopter
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@ -632,11 +640,11 @@ end
|
|||||||
|
|
||||||
--- On after Deploy event.
|
--- On after Deploy event.
|
||||||
-- @param #AI_CARGO_HELICOPTER self
|
-- @param #AI_CARGO_HELICOPTER self
|
||||||
-- @param Wrapper.Group#GROUP Helicopter
|
-- @param Wrapper.Group#GROUP Helicopter Transport helicopter.
|
||||||
-- @param From
|
-- @param From
|
||||||
-- @param Event
|
-- @param Event
|
||||||
-- @param To
|
-- @param To
|
||||||
-- @param Core.Point#COORDINATE Coordinate
|
-- @param Core.Point#COORDINATE Coordinate Place at which the cargo is deployed.
|
||||||
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
-- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go.
|
||||||
function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordinate, Speed )
|
function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordinate, Speed )
|
||||||
|
|
||||||
|
|||||||
@ -1203,6 +1203,10 @@ end
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
-- @param #number Speed
|
||||||
|
-- @param #number BoardDistance
|
||||||
|
-- @param #number LoadDistance
|
||||||
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterOnBoarded( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
function CARGO_PACKAGE:onafterOnBoarded( From, Event, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
@ -1218,6 +1222,7 @@ end
|
|||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
-- @param #number Speed
|
-- @param #number Speed
|
||||||
-- @param #number UnLoadDistance
|
-- @param #number UnLoadDistance
|
||||||
-- @param #number UnBoardDistance
|
-- @param #number UnBoardDistance
|
||||||
@ -1261,6 +1266,7 @@ end
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
-- @param #number Speed
|
||||||
function CARGO_PACKAGE:onafterUnBoarded( From, Event, To, CargoCarrier, Speed )
|
function CARGO_PACKAGE:onafterUnBoarded( From, Event, To, CargoCarrier, Speed )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
@ -1304,6 +1310,8 @@ end
|
|||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
-- @param #number Speed
|
||||||
-- @param #number Distance
|
-- @param #number Distance
|
||||||
-- @param #number Angle
|
-- @param #number Angle
|
||||||
function CARGO_PACKAGE:onafterUnLoad( From, Event, To, CargoCarrier, Speed, Distance, Angle )
|
function CARGO_PACKAGE:onafterUnLoad( From, Event, To, CargoCarrier, Speed, Distance, Angle )
|
||||||
|
|||||||
@ -61,8 +61,8 @@ do -- CARGO_GROUP
|
|||||||
-- @param #number LoadRadius (optional) Distance in meters until which a cargo is loaded into the carrier. Cargo outside this radius has to be routed by other means to within the radius to be loaded.
|
-- @param #number LoadRadius (optional) Distance in meters until which a cargo is loaded into the carrier. Cargo outside this radius has to be routed by other means to within the radius to be loaded.
|
||||||
-- @param #number NearRadius (optional) Once the units are within this radius of the carrier, they are actually loaded, i.e. disappear from the scene.
|
-- @param #number NearRadius (optional) Once the units are within this radius of the carrier, they are actually loaded, i.e. disappear from the scene.
|
||||||
-- @return #CARGO_GROUP Cargo group object.
|
-- @return #CARGO_GROUP Cargo group object.
|
||||||
function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius )
|
function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius, NearRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius ) ) -- #CARGO_GROUP
|
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius, NearRadius ) ) -- #CARGO_GROUP
|
||||||
self:F( { Type, Name, LoadRadius } )
|
self:F( { Type, Name, LoadRadius } )
|
||||||
|
|
||||||
self.CargoSet = SET_CARGO:New()
|
self.CargoSet = SET_CARGO:New()
|
||||||
@ -98,7 +98,7 @@ do -- CARGO_GROUP
|
|||||||
local Unit = UNIT:Register( CargoUnitName )
|
local Unit = UNIT:Register( CargoUnitName )
|
||||||
--local WeightUnit = Unit:GetDesc().massEmpty
|
--local WeightUnit = Unit:GetDesc().massEmpty
|
||||||
--WeightGroup = WeightGroup + WeightUnit
|
--WeightGroup = WeightGroup + WeightUnit
|
||||||
local CargoUnit = CARGO_UNIT:New( Unit, Type, CargoUnitName, 10 )
|
local CargoUnit = CARGO_UNIT:New( Unit, Type, CargoUnitName, 10, LoadRadius, NearRadius )
|
||||||
self.CargoSet:Add( CargoUnitName, CargoUnit )
|
self.CargoSet:Add( CargoUnitName, CargoUnit )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -257,10 +257,11 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
--- Enter Boarding State.
|
--- Enter Boarding State.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_GROUP:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
--self:F( { CargoCarrier.UnitName, From, Event, To } )
|
--self:F( { CargoCarrier.UnitName, From, Event, To } )
|
||||||
|
|
||||||
@ -303,11 +304,12 @@ do -- CARGO_GROUP
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Leave Boarding State.
|
--- Leave Boarding State.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_GROUP:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
--self:F( { CargoCarrier.UnitName, From, Event, To } )
|
--self:F( { CargoCarrier.UnitName, From, Event, To } )
|
||||||
|
|
||||||
@ -359,10 +361,11 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
--- Enter UnBoarding State.
|
--- Enter UnBoarding State.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
||||||
self:F( {From, Event, To, ToPointVec2, NearRadius } )
|
self:F( {From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
@ -401,10 +404,11 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
--- Leave UnBoarding State.
|
--- Leave UnBoarding State.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
||||||
--self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
--self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
@ -438,10 +442,11 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
--- UnBoard Event.
|
--- UnBoard Event.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
|
-- @param #number NearRadius If distance is smaller than this number, cargo is loaded into the carrier.
|
||||||
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
|
||||||
--self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
--self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
@ -454,10 +459,10 @@ do -- CARGO_GROUP
|
|||||||
|
|
||||||
--- Enter UnLoaded State.
|
--- Enter UnLoaded State.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Core.Point#POINT_VEC2
|
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Core.Point#POINT_VEC2
|
||||||
function CARGO_GROUP:onenterUnLoaded( From, Event, To, ToPointVec2, ... )
|
function CARGO_GROUP:onenterUnLoaded( From, Event, To, ToPointVec2, ... )
|
||||||
--self:F( { From, Event, To, ToPointVec2 } )
|
--self:F( { From, Event, To, ToPointVec2 } )
|
||||||
|
|
||||||
@ -467,7 +472,7 @@ do -- CARGO_GROUP
|
|||||||
self.CargoSet:ForEach(
|
self.CargoSet:ForEach(
|
||||||
function( Cargo )
|
function( Cargo )
|
||||||
--Cargo:UnLoad( ToPointVec2 )
|
--Cargo:UnLoad( ToPointVec2 )
|
||||||
local RandomVec2=ToPointVec2:GetRandomPointVec2InRadius(10)
|
local RandomVec2=ToPointVec2:GetRandomPointVec2InRadius(20, 10)
|
||||||
Cargo:UnLoad( RandomVec2 )
|
Cargo:UnLoad( RandomVec2 )
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -592,8 +597,7 @@ do -- CARGO_GROUP
|
|||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP CargoCarrier
|
-- @param Wrapper.Group#GROUP CargoCarrier
|
||||||
-- @param #number NearRadius
|
-- @param #number NearRadius
|
||||||
-- @return #boolean The Cargo is near to the Carrier.
|
-- @return #boolean The Cargo is near to the Carrier or #nil if the Cargo is not near to the Carrier.
|
||||||
-- @return #nil The Cargo is not near to the Carrier.
|
|
||||||
function CARGO_GROUP:IsNear( CargoCarrier, NearRadius )
|
function CARGO_GROUP:IsNear( CargoCarrier, NearRadius )
|
||||||
self:F( {NearRadius = NearRadius } )
|
self:F( {NearRadius = NearRadius } )
|
||||||
|
|
||||||
|
|||||||
@ -42,9 +42,9 @@ do -- CARGO_UNIT
|
|||||||
-- @param #number LoadRadius (optional)
|
-- @param #number LoadRadius (optional)
|
||||||
-- @param #number NearRadius (optional)
|
-- @param #number NearRadius (optional)
|
||||||
-- @return #CARGO_UNIT
|
-- @return #CARGO_UNIT
|
||||||
function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, NearRadius )
|
function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, LoadRadius, NearRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoUnit, Type, Name, Weight, NearRadius ) ) -- #CARGO_UNIT
|
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoUnit, Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_UNIT
|
||||||
self:I( { Type, Name, Weight, NearRadius } )
|
self:I( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||||
|
|
||||||
self:T( CargoUnit )
|
self:T( CargoUnit )
|
||||||
self.CargoObject = CargoUnit
|
self.CargoObject = CargoUnit
|
||||||
@ -62,6 +62,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
|
-- @param #number NearRadius (optional) Defaut 25 m.
|
||||||
function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||||
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
|
-- @param #number NearRadius (optional) Defaut 100 m.
|
||||||
function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||||
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
@ -158,6 +160,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||||
|
-- @param #number NearRadius (optional) Defaut 100 m.
|
||||||
function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||||
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
self:F( { From, Event, To, ToPointVec2, NearRadius } )
|
||||||
|
|
||||||
@ -281,7 +284,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Client#CLIENT CargoCarrier
|
-- @param Wrapper.Client#CLIENT CargoCarrier
|
||||||
-- @param #number NearRadius
|
-- @param #number NearRadius Default 25 m.
|
||||||
function CARGO_UNIT:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_UNIT:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
--self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
|
--self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
|
||||||
|
|
||||||
@ -338,6 +341,7 @@ do -- CARGO_UNIT
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
-- @param #number NearRadius Default 25 m.
|
||||||
function CARGO_UNIT:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
function CARGO_UNIT:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||||
--self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
|
--self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
|
||||||
|
|
||||||
|
|||||||
@ -798,8 +798,7 @@ end
|
|||||||
-- @param Object The object that will hold the Value set by the Key.
|
-- @param Object The object that will hold the Value set by the Key.
|
||||||
-- @param Key The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!
|
-- @param Key The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!
|
||||||
-- @param Value The value to is stored in the object.
|
-- @param Value The value to is stored in the object.
|
||||||
-- @return The Value set.
|
-- @return The Value set.
|
||||||
-- @return #nil The Key was not found and thus the Value could not be retrieved.
|
|
||||||
function BASE:SetState( Object, Key, Value )
|
function BASE:SetState( Object, Key, Value )
|
||||||
|
|
||||||
local ClassNameAndID = Object:GetClassNameAndID()
|
local ClassNameAndID = Object:GetClassNameAndID()
|
||||||
@ -816,7 +815,7 @@ end
|
|||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param Object The object that holds the Value set by the Key.
|
-- @param Object The object that holds the Value set by the Key.
|
||||||
-- @param Key The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!
|
-- @param Key The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!
|
||||||
-- @return The Value retrieved.
|
-- @return The Value retrieved or nil if the Key was not found and thus the Value could not be retrieved.
|
||||||
function BASE:GetState( Object, Key )
|
function BASE:GetState( Object, Key )
|
||||||
|
|
||||||
local ClassNameAndID = Object:GetClassNameAndID()
|
local ClassNameAndID = Object:GetClassNameAndID()
|
||||||
@ -829,6 +828,10 @@ function BASE:GetState( Object, Key )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Clear the state of an object.
|
||||||
|
-- @param #BASE self
|
||||||
|
-- @param Object The object that holds the Value set by the Key.
|
||||||
|
-- @param StateName The key that is should be cleared.
|
||||||
function BASE:ClearState( Object, StateName )
|
function BASE:ClearState( Object, StateName )
|
||||||
|
|
||||||
local ClassNameAndID = Object:GetClassNameAndID()
|
local ClassNameAndID = Object:GetClassNameAndID()
|
||||||
|
|||||||
@ -308,7 +308,7 @@ end
|
|||||||
|
|
||||||
--- Sends a MESSAGE to all players.
|
--- Sends a MESSAGE to all players.
|
||||||
-- @param #MESSAGE self
|
-- @param #MESSAGE self
|
||||||
-- @param Core.Settings#Settings (Optional) Settings for message display
|
-- @param Core.Settings#Settings Settings (Optional) Settings for message display.
|
||||||
-- @return #MESSAGE
|
-- @return #MESSAGE
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Send a message created to all players.
|
-- -- Send a message created to all players.
|
||||||
|
|||||||
@ -1095,6 +1095,37 @@ do -- COORDINATE
|
|||||||
|
|
||||||
return RoutePoint
|
return RoutePoint
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the nearest airbase with respect to the current coordinates.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #number AirbaseCategory Category of the airbase.
|
||||||
|
-- @return Wrapper.Airbase#AIRBASE Closest Airbase to the given coordinate.
|
||||||
|
-- @return #number Distance to the closest airbase in meters.
|
||||||
|
function COORDINATE:GetClosestAirbase(AirbaseCategory)
|
||||||
|
local airbases=AIRBASE.GetAllAirbases()
|
||||||
|
|
||||||
|
local closest=nil
|
||||||
|
local distmin=nil
|
||||||
|
-- Loop over all airbases.
|
||||||
|
for _,_airbase in pairs(airbases) do
|
||||||
|
local airbase=_airbase --Wrapper.Airbase#AIRBASE
|
||||||
|
local category=airbase:GetDesc().category
|
||||||
|
if AirbaseCategory and AirbaseCategory==category or AirbaseCategory==nil then
|
||||||
|
local dist=self:Get2DDistance(airbase:GetCoordinate())
|
||||||
|
if closest==nil then
|
||||||
|
distmin=dist
|
||||||
|
closest=airbase
|
||||||
|
else
|
||||||
|
if dist<distmin then
|
||||||
|
distmin=dist
|
||||||
|
closest=airbase
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return closest,distmin
|
||||||
|
end
|
||||||
|
|
||||||
--- Gets the nearest parking spot.
|
--- Gets the nearest parking spot.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
@ -1182,19 +1213,27 @@ do -- COORDINATE
|
|||||||
local vec2={ x = x, y = y }
|
local vec2={ x = x, y = y }
|
||||||
return COORDINATE:NewFromVec2(vec2)
|
return COORDINATE:NewFromVec2(vec2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a table of coordinates to a destination using only roads.
|
--- Returns a table of coordinates to a destination using only roads or railroads.
|
||||||
-- The first point is the closest point on road of the given coordinate.
|
-- The first point is the closest point on road of the given coordinate.
|
||||||
-- By default, the last point is the closest point on road of the ToCoord. Hence, the coordinate itself and the final ToCoord are not necessarily included in the path.
|
-- By default, the last point is the closest point on road of the ToCoord. Hence, the coordinate itself and the final ToCoord are not necessarily included in the path.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #COORDINATE ToCoord Coordinate of destination.
|
-- @param #COORDINATE ToCoord Coordinate of destination.
|
||||||
-- @param #boolean IncludeEndpoints (Optional) Include the coordinate itself and the ToCoordinate in the path.
|
-- @param #boolean IncludeEndpoints (Optional) Include the coordinate itself and the ToCoordinate in the path.
|
||||||
|
-- @param #boolean Railroad (Optional) If true, path on railroad is returned. Default false.
|
||||||
-- @return #table Table of coordinates on road. If no path on road can be found, nil is returned or just the endpoints.
|
-- @return #table Table of coordinates on road. If no path on road can be found, nil is returned or just the endpoints.
|
||||||
-- @return #number The length of the total path.
|
-- @return #number The length of the total path.
|
||||||
function COORDINATE:GetPathOnRoad(ToCoord, IncludeEndpoints)
|
function COORDINATE:GetPathOnRoad(ToCoord, IncludeEndpoints, Railroad)
|
||||||
|
|
||||||
|
-- Set road type.
|
||||||
|
local RoadType="roads"
|
||||||
|
if Railroad==true then
|
||||||
|
RoadType="railroads"
|
||||||
|
end
|
||||||
|
|
||||||
-- DCS API function returning a table of vec2.
|
-- DCS API function returning a table of vec2.
|
||||||
local path = land.findPathOnRoads("roads", self.x, self.z, ToCoord.x, ToCoord.z)
|
local path = land.findPathOnRoads(RoadType, self.x, self.z, ToCoord.x, ToCoord.z)
|
||||||
|
|
||||||
-- Array holding the path coordinates.
|
-- Array holding the path coordinates.
|
||||||
local Path={}
|
local Path={}
|
||||||
|
|||||||
@ -809,6 +809,16 @@ function SET_GROUP:GetAliveSet()
|
|||||||
return AliveSet.Set or {}
|
return AliveSet.Set or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add a GROUP to SET_GROUP.
|
||||||
|
-- @param Core.Set#SET_GROUP self
|
||||||
|
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
||||||
|
-- @return self
|
||||||
|
function SET_GROUP:AddGroup( group )
|
||||||
|
|
||||||
|
self:Add( group:GetName(), group )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Add GROUP(s) to SET_GROUP.
|
--- Add GROUP(s) to SET_GROUP.
|
||||||
-- @param Core.Set#SET_GROUP self
|
-- @param Core.Set#SET_GROUP self
|
||||||
@ -3968,6 +3978,17 @@ function SET_AIRBASE:New()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add an AIRBASE object to SET_AIRBASE.
|
||||||
|
-- @param Core.Set#SET_AIRBASE self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE airbase Airbase that should be added to the set.
|
||||||
|
-- @return self
|
||||||
|
function SET_AIRBASE:AddAirbase( airbase )
|
||||||
|
|
||||||
|
self:Add( airbase:GetName(), airbase )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Add AIRBASEs to SET_AIRBASE.
|
--- Add AIRBASEs to SET_AIRBASE.
|
||||||
-- @param Core.Set#SET_AIRBASE self
|
-- @param Core.Set#SET_AIRBASE self
|
||||||
-- @param #string AddAirbaseNames A single name or an array of AIRBASE names.
|
-- @param #string AddAirbaseNames A single name or an array of AIRBASE names.
|
||||||
@ -4010,6 +4031,45 @@ function SET_AIRBASE:FindAirbase( AirbaseName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Finds an Airbase in range of a coordinate.
|
||||||
|
-- @param #SET_AIRBASE self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
|
-- @param #number Range
|
||||||
|
-- @return Wrapper.Airbase#AIRBASE The found Airbase.
|
||||||
|
function SET_AIRBASE:FindAirbaseInRange( Coordinate, Range )
|
||||||
|
|
||||||
|
local AirbaseFound = nil
|
||||||
|
|
||||||
|
for AirbaseName, AirbaseObject in pairs( self.Set ) do
|
||||||
|
|
||||||
|
local AirbaseCoordinate = AirbaseObject:GetCoordinate()
|
||||||
|
local Distance = Coordinate:Get2DDistance( AirbaseCoordinate )
|
||||||
|
|
||||||
|
self:F({Distance=Distance})
|
||||||
|
|
||||||
|
if Distance <= Range then
|
||||||
|
AirbaseFound = AirbaseObject
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return AirbaseFound
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Finds a random Airbase in the set.
|
||||||
|
-- @param #SET_AIRBASE self
|
||||||
|
-- @return Wrapper.Airbase#AIRBASE The found Airbase.
|
||||||
|
function SET_AIRBASE:GetRandomAirbase()
|
||||||
|
|
||||||
|
local RandomAirbase = self:GetRandom()
|
||||||
|
self:F( { RandomAirbase = RandomAirbase:GetName() } )
|
||||||
|
|
||||||
|
return RandomAirbase
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Builds a set of airbases of coalitions.
|
--- Builds a set of airbases of coalitions.
|
||||||
-- Possible current coalitions are red, blue and neutral.
|
-- Possible current coalitions are red, blue and neutral.
|
||||||
|
|||||||
@ -81,11 +81,11 @@ do -- world
|
|||||||
|
|
||||||
--- Searches a defined volume of 3d space for the specified objects within it and then can run function on each returned object. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_searchObjects).
|
--- Searches a defined volume of 3d space for the specified objects within it and then can run function on each returned object. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_searchObjects).
|
||||||
-- @function [parent=#world] searchObjects
|
-- @function [parent=#world] searchObjects
|
||||||
-- @param #DCS.Object.Category objectcategory Category (can be a table) of objects to search.
|
-- @param DCS#Object.Category objectcategory Category (can be a table) of objects to search.
|
||||||
-- @param #DCS word.VolumeType volume Shape of the search area/volume.
|
-- @param DCS#word.VolumeType volume Shape of the search area/volume.
|
||||||
-- @param #ObjectSeachHandler handler A function that handles the search.
|
-- @param ObjectSeachHandler handler A function that handles the search.
|
||||||
-- @param #table any Additional data.
|
-- @param #table any Additional data.
|
||||||
-- @return #DCS.unit
|
-- @return DCS#Unit
|
||||||
|
|
||||||
--- Returns a table of mark panels indexed numerically that are present within the mission. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_getMarkPanels)
|
--- Returns a table of mark panels indexed numerically that are present within the mission. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_getMarkPanels)
|
||||||
-- @function [parent=#world] getMarkPanels
|
-- @function [parent=#world] getMarkPanels
|
||||||
@ -959,6 +959,7 @@ do -- Group
|
|||||||
-- @field HELICOPTER
|
-- @field HELICOPTER
|
||||||
-- @field GROUND
|
-- @field GROUND
|
||||||
-- @field SHIP
|
-- @field SHIP
|
||||||
|
-- @field TRAIN
|
||||||
|
|
||||||
-- Static Functions
|
-- Static Functions
|
||||||
|
|
||||||
|
|||||||
@ -515,6 +515,7 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
for DetectionGroupID, DetectionGroupData in pairs( self.DetectionSetGroup:GetSet() ) do
|
for DetectionGroupID, DetectionGroupData in pairs( self.DetectionSetGroup:GetSet() ) do
|
||||||
--self:F( { DetectionGroupData } )
|
--self:F( { DetectionGroupData } )
|
||||||
|
self:F( {"FF", DetectionGroupData } )
|
||||||
self:__DetectionGroup( DetectDelay, DetectionGroupData, DetectionTimeStamp ) -- Process each detection asynchronously.
|
self:__DetectionGroup( DetectDelay, DetectionGroupData, DetectionTimeStamp ) -- Process each detection asynchronously.
|
||||||
self.DetectionCount = self.DetectionCount + 1
|
self.DetectionCount = self.DetectionCount + 1
|
||||||
DetectDelay = DetectDelay + 1
|
DetectDelay = DetectDelay + 1
|
||||||
@ -1877,7 +1878,7 @@ do -- DETECTION_UNITS
|
|||||||
-- @param #DETECTION_UNITS self
|
-- @param #DETECTION_UNITS self
|
||||||
-- @return #DETECTION_UNITS self
|
-- @return #DETECTION_UNITS self
|
||||||
function DETECTION_UNITS:CreateDetectionItems()
|
function DETECTION_UNITS:CreateDetectionItems()
|
||||||
|
env.info("FF createdetectionitmes")
|
||||||
-- Loop the current detected items, and check if each object still exists and is detected.
|
-- Loop the current detected items, and check if each object still exists and is detected.
|
||||||
|
|
||||||
for DetectedItemKey, DetectedItem in pairs( self.DetectedItems ) do
|
for DetectedItemKey, DetectedItem in pairs( self.DetectedItems ) do
|
||||||
|
|||||||
@ -1,172 +0,0 @@
|
|||||||
--- **Functional** - (R2.4) JTAC
|
|
||||||
--
|
|
||||||
-- ===
|
|
||||||
--
|
|
||||||
-- JTAC mimic
|
|
||||||
--
|
|
||||||
-- ## Features:
|
|
||||||
--
|
|
||||||
-- * Feature 1
|
|
||||||
-- * Feature 2
|
|
||||||
--
|
|
||||||
-- ====
|
|
||||||
--
|
|
||||||
-- # Demo Missions
|
|
||||||
--
|
|
||||||
-- ### [MOOSE - ALL Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS)
|
|
||||||
--
|
|
||||||
-- ====
|
|
||||||
--
|
|
||||||
-- # YouTube Channel
|
|
||||||
--
|
|
||||||
-- ### [MOOSE YouTube Channel](https://www.youtube.com/channel/UCjrA9j5LQoWsG4SpS8i79Qg)
|
|
||||||
--
|
|
||||||
-- ===
|
|
||||||
--
|
|
||||||
-- ### Author: **[funkyfranky](https://forums.eagle.ru/member.php?u=115026)**
|
|
||||||
--
|
|
||||||
-- ### Contributions: [FlightControl](https://forums.eagle.ru/member.php?u=89536)
|
|
||||||
--
|
|
||||||
-- ====
|
|
||||||
-- @module Functional.Jtac
|
|
||||||
-- @image JTAC.JPG
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
--- JTAC class
|
|
||||||
-- @type JTAC
|
|
||||||
-- @field #string ClassName Name of the class.
|
|
||||||
|
|
||||||
--- Easy assignment of JTAC.
|
|
||||||
--
|
|
||||||
-- A new ARTY object can be created with the @{#ARTY.New}(*group*) contructor.
|
|
||||||
-- The parameter *group* has to be a MOOSE Group object and defines ARTY group.
|
|
||||||
--
|
|
||||||
-- The ARTY FSM process can be started by the @{#ARTY.Start}() command.
|
|
||||||
--
|
|
||||||
-- ## The ARTY Process
|
|
||||||
--
|
|
||||||
-- 
|
|
||||||
--
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- @field #JTAC
|
|
||||||
JTAC={
|
|
||||||
ClassName="JTAC",
|
|
||||||
Debug=false,
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Some ID to identify who we are in output of the DCS.log file.
|
|
||||||
-- @field #string id
|
|
||||||
JTAC.id="JTAC | "
|
|
||||||
|
|
||||||
--- Arty script version.
|
|
||||||
-- @field #string version
|
|
||||||
JTAC.version="0.0.1"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- TODO list:
|
|
||||||
-- TODO: a lot.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
--- Creates a new JTAC object.
|
|
||||||
-- @param #JTAC self
|
|
||||||
-- @param Wrapper.Group#GROUP group The GROUP object for which artillery tasks should be assigned.
|
|
||||||
-- @param alias (Optional) Alias name the group will be calling itself when sending messages. Default is the group name.
|
|
||||||
-- @return #JTAC JTAC object or nil if group does not exist or is not a ground or naval group.
|
|
||||||
function JTAC:New(group, alias)
|
|
||||||
BASE:F2(group)
|
|
||||||
|
|
||||||
-- Inherits from FSM_CONTROLLABLE
|
|
||||||
local self=BASE:Inherit(self, FSM_CONTROLLABLE:New()) -- #JTAC
|
|
||||||
|
|
||||||
-- Check that group is present.
|
|
||||||
if group then
|
|
||||||
self:T(JTAC.id..string.format("JTAC script version %s. Added group %s.", JTAC.version, group:GetName()))
|
|
||||||
else
|
|
||||||
self:E(JTAC.id.."ERROR: Requested JTAC group does not exist! (Has to be a MOOSE group.)")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set the controllable for the FSM.
|
|
||||||
self:SetControllable(group)
|
|
||||||
|
|
||||||
---------------
|
|
||||||
-- Transitions:
|
|
||||||
---------------
|
|
||||||
|
|
||||||
-- Entry.
|
|
||||||
self:AddTransition("*", "Start", "Ready")
|
|
||||||
self:AddTransition("Ready", "LaserOn", "Lasing")
|
|
||||||
self:AddTransition("Lasing", "Lasing", "Lasing")
|
|
||||||
self:AddTransition("Lasing", "LaserOff", "Ready")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
-- FSM Start Event
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
--- After "Start" event.
|
|
||||||
-- @param #JTAC self
|
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
|
||||||
-- @param #string From From state.
|
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
|
||||||
function JTAC:onafterStart(Controllable, From, Event, To)
|
|
||||||
--self:_EventFromTo("onafterStart", Event, From, To)
|
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
local text=string.format("Started JTAC version %s for group %s.", JTAC.version, Controllable:GetName())
|
|
||||||
self:E(JTAC.id..text)
|
|
||||||
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- After "LaserOn" event.
|
|
||||||
-- @param #JTAC self
|
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
|
||||||
-- @param #string From From state.
|
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
|
||||||
-- @param Wrapper.Unit#UNIT Target Target that should be lased.
|
|
||||||
function JTAC:onafterLaserOn(Controllable, From, Event, To, Target)
|
|
||||||
--self:_EventFromTo("onafterStart", Event, From, To)
|
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
local text=string.format("JTAC %s lasing target %s.", Controllable:GetName(), Target:GetName())
|
|
||||||
self:E(JTAC.id..text)
|
|
||||||
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
|
||||||
|
|
||||||
-- Start lasing.
|
|
||||||
Controllable:LaseUnit(Target, self.LaserCode, self.Duration)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- After "LaserOff" event.
|
|
||||||
-- @param #JTAC self
|
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
|
||||||
-- @param #string From From state.
|
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
|
||||||
function JTAC:onafterLaserOff(Controllable, From, Event, To)
|
|
||||||
--self:_EventFromTo("onafterStart", Event, From, To)
|
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
local text=string.format("JTAC %s stoped lasing.", Controllable:GetName())
|
|
||||||
self:E(JTAC.id..text)
|
|
||||||
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
|
||||||
|
|
||||||
-- Turn of laser.
|
|
||||||
Controllable:LaseOff()
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -219,6 +219,44 @@
|
|||||||
-- Hence, the default flight plan for a RAT aircraft will be: Fly from airport A to B, get respawned at C and fly to D, get respawned at E and fly to F, ...
|
-- Hence, the default flight plan for a RAT aircraft will be: Fly from airport A to B, get respawned at C and fly to D, get respawned at E and fly to F, ...
|
||||||
-- This ensures that you always have a constant number of AI aircraft on your map.
|
-- This ensures that you always have a constant number of AI aircraft on your map.
|
||||||
--
|
--
|
||||||
|
-- ## Parking Problems
|
||||||
|
--
|
||||||
|
-- One big issue in DCS is that not all aircraft can be spawned on every airport or airbase. In particular, bigger aircraft might not have a valid parking spot at smaller airports and
|
||||||
|
-- airstripes. This can lead to multiple problems in DCS.
|
||||||
|
--
|
||||||
|
-- * Landing: When an aircraft tries to land at an airport where it does not have a valid parking spot, it is immidiately despawned the moment its wheels touch the runway, i.e.
|
||||||
|
-- when a landing event is triggered. This leads to the loss of the RAT aircraft. On possible way to circumvent the this problem is to let another RAT aircraft spawn at landing
|
||||||
|
-- and not when it shuts down its engines. See the @{RAT.RespawnAfterLanding}() function.
|
||||||
|
-- * Spawning: When a big aircraft is dynamically spawned on a small airbase a few things can go wrong. For example, it could be spawned at a parking spot with a shelter.
|
||||||
|
-- Or it could be damaged by a scenery object when it is taxiing out to the runway, or it could overlap with other aircraft on parking spots near by.
|
||||||
|
--
|
||||||
|
-- You can check yourself if an aircraft has a valid parking spot at an airbase by dragging its group on the airport in the mission editor and set it to start from ramp.
|
||||||
|
-- If it stays at the airport, it has a valid parking spot, if it jumps to another airport, it does not have a valid parking spot on that airbase.
|
||||||
|
--
|
||||||
|
-- ### Setting the Terminal Type
|
||||||
|
-- Each parking spot has a specific type depending on its size or if a helicopter spot or a shelter etc. The classification is not perfect but it is the best we have.
|
||||||
|
-- If you encounter problems described above, you can request a specific terminal type for the RAT aircraft. This can be done by the @{#RAT.SetTerminalType}(*terminaltype*)
|
||||||
|
-- function. The parameter *terminaltype* can be set as follows
|
||||||
|
--
|
||||||
|
-- * AIRBASE.TerminalType.HelicopterOnly: Special spots for Helicopers.
|
||||||
|
-- * AIRBASE.TerminalType.Shelter: Hardened Air Shelter. Currently only on Caucaus map.
|
||||||
|
-- * AIRBASE.TerminalType.OpenMed: Open/Shelter air airplane only.
|
||||||
|
-- * AIRBASE.TerminalType.OpenBig: Open air spawn points. Generally larger but does not guarantee large aircraft are capable of spawning there.
|
||||||
|
-- * AIRBASE.TerminalType.OpenMedOrBig: Combines OpenMed and OpenBig spots.
|
||||||
|
-- * AIRBASE.TerminalType.HelicopterUnsable: Combines HelicopterOnly, OpenMed and OpenBig.
|
||||||
|
-- * AIRBASE.TerminalType.FighterAircraft: Combines Shelter, OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft.
|
||||||
|
--
|
||||||
|
-- So for example
|
||||||
|
-- c17=RAT:New("C-17")
|
||||||
|
-- c17:SetTerminalType(AIRBASE.TerminalType.OpenBig)
|
||||||
|
-- c17:Spawn(5)
|
||||||
|
--
|
||||||
|
-- This would randomly spawn five C-17s but only on airports which have big open air parking spots. Note that also only destination airports are allowed
|
||||||
|
-- which do have this type of parking spot. This should ensure that the aircraft is able to land at the destination without beeing despawned immidiately.
|
||||||
|
--
|
||||||
|
-- Also, the aircraft are spawned only on the requested parking spot types and not on any other type. If no parking spot of this type is availabe at the
|
||||||
|
-- moment of spawning, the group is automatically spawned in air above the selected airport.
|
||||||
|
--
|
||||||
-- ## Examples
|
-- ## Examples
|
||||||
--
|
--
|
||||||
-- Here are a few examples, how you can modify the default settings of RAT class objects.
|
-- Here are a few examples, how you can modify the default settings of RAT class objects.
|
||||||
@ -511,7 +549,7 @@ RAT.id="RAT | "
|
|||||||
--- RAT version.
|
--- RAT version.
|
||||||
-- @list version
|
-- @list version
|
||||||
RAT.version={
|
RAT.version={
|
||||||
version = "2.3.2",
|
version = "2.3.3",
|
||||||
print = true,
|
print = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -983,11 +1021,11 @@ function RAT:SetCoalitionAircraft(color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Set country of RAT group.
|
--- Set country of RAT group.
|
||||||
-- See https://wiki.hoggitworld.com/view/DCS_enum_country
|
-- See [DCS_enum_country](https://wiki.hoggitworld.com/view/DCS_enum_country).
|
||||||
--
|
--
|
||||||
-- This overrules the coalition settings. So if you want your group to be of a specific coalition, you have to set a country that is part of that coalition.
|
-- This overrules the coalition settings. So if you want your group to be of a specific coalition, you have to set a country that is part of that coalition.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param #DCS.country.id id DCS country enumerator ID. For example country.id.USA or country.id.RUSSIA.
|
-- @param DCS#country.id id DCS country enumerator ID. For example country.id.USA or country.id.RUSSIA.
|
||||||
-- @return #RAT RAT self object.
|
-- @return #RAT RAT self object.
|
||||||
function RAT:SetCountry(id)
|
function RAT:SetCountry(id)
|
||||||
self:F2(id)
|
self:F2(id)
|
||||||
@ -995,10 +1033,17 @@ function RAT:SetCountry(id)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the terminal type the aircraft use when spawning at an airbase. Cf. https://wiki.hoggitworld.com/view/DCS_func_getParking
|
--- Set the terminal type the aircraft use when spawning at an airbase. See [DCS_func_getParking](https://wiki.hoggitworld.com/view/DCS_func_getParking).
|
||||||
|
-- Note that some additional terminal types have been introduced. Check @{Wrapper.Airbase#AIRBASE} class for details.
|
||||||
|
-- Also note that only airports which have this kind of terminal are possible departures and/or destinations.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param Wrapper.Airbase#AIRBASE.TerminalType termtype Type of terminal. Use enumerator AIRBASE.TerminalType.XXX.
|
-- @param Wrapper.Airbase#AIRBASE.TerminalType termtype Type of terminal. Use enumerator AIRBASE.TerminalType.XXX.
|
||||||
-- @return #RAT RAT self object.
|
-- @return #RAT RAT self object.
|
||||||
|
--
|
||||||
|
-- @usage
|
||||||
|
-- c17=RAT:New("C-17 BIG Plane")
|
||||||
|
-- c17:SetTerminalType(AIRBASE.TerminalType.OpenBig) -- Only very big parking spots are used.
|
||||||
|
-- c17:Spawn(5)
|
||||||
function RAT:SetTerminalType(termtype)
|
function RAT:SetTerminalType(termtype)
|
||||||
self:F2(termtype)
|
self:F2(termtype)
|
||||||
self.termtype=termtype
|
self.termtype=termtype
|
||||||
@ -3010,14 +3055,27 @@ function RAT:_PickDeparture(takeoff)
|
|||||||
if self.random_departure then
|
if self.random_departure then
|
||||||
|
|
||||||
-- Airports of friendly coalitions.
|
-- Airports of friendly coalitions.
|
||||||
for _,airport in pairs(self.airports) do
|
for _,_airport in pairs(self.airports) do
|
||||||
|
|
||||||
|
local airport=_airport --Wrapper.Airbase#AIRBASE
|
||||||
|
|
||||||
local name=airport:GetName()
|
local name=airport:GetName()
|
||||||
if not self:_Excluded(name) then
|
if not self:_Excluded(name) then
|
||||||
if takeoff==RAT.wp.air then
|
if takeoff==RAT.wp.air then
|
||||||
|
|
||||||
table.insert(departures, airport:GetZone()) -- insert zone object.
|
table.insert(departures, airport:GetZone()) -- insert zone object.
|
||||||
|
|
||||||
else
|
else
|
||||||
table.insert(departures, airport) -- insert airport object.
|
|
||||||
|
-- Check if airbase has the right terminals.
|
||||||
|
local nspots=1
|
||||||
|
if self.termtype~=nil then
|
||||||
|
nspots=airport:GetParkingSpotsNumber(self.termtype)
|
||||||
|
end
|
||||||
|
|
||||||
|
if nspots>0 then
|
||||||
|
table.insert(departures, airport) -- insert airport object.
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3034,6 +3092,14 @@ function RAT:_PickDeparture(takeoff)
|
|||||||
dep=AIRBASE:FindByName(name):GetZone()
|
dep=AIRBASE:FindByName(name):GetZone()
|
||||||
else
|
else
|
||||||
dep=AIRBASE:FindByName(name)
|
dep=AIRBASE:FindByName(name)
|
||||||
|
-- Check if the airport has a valid parking spot
|
||||||
|
if self.termtype~=nil and dep~=nil then
|
||||||
|
local _dep=dep --Wrapper.Airbase#AIRBASE
|
||||||
|
local nspots=_dep:GetParkingSpotsNumber(self.termtype)
|
||||||
|
if nspots==0 then
|
||||||
|
dep=nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif self:_ZoneExists(name) then
|
elseif self:_ZoneExists(name) then
|
||||||
if takeoff==RAT.wp.air then
|
if takeoff==RAT.wp.air then
|
||||||
@ -3098,7 +3164,8 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
|
|||||||
if random then
|
if random then
|
||||||
|
|
||||||
-- Airports of friendly coalitions.
|
-- Airports of friendly coalitions.
|
||||||
for _,airport in pairs(self.airports) do
|
for _,_airport in pairs(self.airports) do
|
||||||
|
local airport=_airport --Wrapper.Airbase#AIRBASE
|
||||||
local name=airport:GetName()
|
local name=airport:GetName()
|
||||||
if self:_IsFriendly(name) and not self:_Excluded(name) and name~=departure:GetName() then
|
if self:_IsFriendly(name) and not self:_Excluded(name) and name~=departure:GetName() then
|
||||||
|
|
||||||
@ -3110,7 +3177,14 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
|
|||||||
if landing==RAT.wp.air then
|
if landing==RAT.wp.air then
|
||||||
table.insert(destinations, airport:GetZone()) -- insert zone object.
|
table.insert(destinations, airport:GetZone()) -- insert zone object.
|
||||||
else
|
else
|
||||||
table.insert(destinations, airport) -- insert airport object.
|
-- Check if the requested terminal type is available.
|
||||||
|
local nspot=1
|
||||||
|
if self.termtype then
|
||||||
|
nspot=airport:GetParkingSpotsNumber(self.termtype)
|
||||||
|
end
|
||||||
|
if nspot>0 then
|
||||||
|
table.insert(destinations, airport) -- insert airport object.
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3130,6 +3204,14 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
|
|||||||
dest=AIRBASE:FindByName(name):GetZone()
|
dest=AIRBASE:FindByName(name):GetZone()
|
||||||
else
|
else
|
||||||
dest=AIRBASE:FindByName(name)
|
dest=AIRBASE:FindByName(name)
|
||||||
|
-- Check if the requested terminal type is available.
|
||||||
|
local nspot=1
|
||||||
|
if self.termtype then
|
||||||
|
nspot=dest:GetParkingSpotsNumber(self.termtype)
|
||||||
|
end
|
||||||
|
if nspot==0 then
|
||||||
|
dest=nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif self:_ZoneExists(name) then
|
elseif self:_ZoneExists(name) then
|
||||||
if landing==RAT.wp.air then
|
if landing==RAT.wp.air then
|
||||||
@ -3287,16 +3369,31 @@ function RAT:_GetAirportsOfMap()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get all "friendly" airports of the current map.
|
--- Get all "friendly" airports of the current map. Fills the self.airports{} table.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
function RAT:_GetAirportsOfCoalition()
|
function RAT:_GetAirportsOfCoalition()
|
||||||
for _,coalition in pairs(self.ctable) do
|
for _,coalition in pairs(self.ctable) do
|
||||||
for _,airport in pairs(self.airports_map) do
|
for _,_airport in pairs(self.airports_map) do
|
||||||
|
local airport=_airport --Wrapper.Airbase#AIRBASE
|
||||||
|
local category=airport:GetDesc().category
|
||||||
if airport:GetCoalition()==coalition then
|
if airport:GetCoalition()==coalition then
|
||||||
-- Planes cannot land on FARPs.
|
-- Planes cannot land on FARPs.
|
||||||
local condition1=self.category==RAT.cat.plane and airport:GetTypeName()=="FARP"
|
--local condition1=self.category==RAT.cat.plane and airport:GetTypeName()=="FARP"
|
||||||
|
local condition1=self.category==RAT.cat.plane and category==Airbase.Category.HELIPAD
|
||||||
-- Planes cannot land on ships.
|
-- Planes cannot land on ships.
|
||||||
local condition2=self.category==RAT.cat.plane and airport:GetCategory()==1
|
--local condition2=self.category==RAT.cat.plane and airport:GetCategory()==1
|
||||||
|
local condition2=self.category==RAT.cat.plane and category==Airbase.Category.SHIP
|
||||||
|
|
||||||
|
-- Check that airport has the requested terminal types.
|
||||||
|
-- NOT good here because we would also not allow any airport zones!
|
||||||
|
--[[
|
||||||
|
local nspots=1
|
||||||
|
if self.termtype then
|
||||||
|
nspots=airport:GetParkingSpotsNumber(self.termtype)
|
||||||
|
end
|
||||||
|
local condition3 = nspots==0
|
||||||
|
]]
|
||||||
|
|
||||||
if not (condition1 or condition2) then
|
if not (condition1 or condition2) then
|
||||||
table.insert(self.airports, airport)
|
table.insert(self.airports, airport)
|
||||||
end
|
end
|
||||||
@ -3305,8 +3402,8 @@ function RAT:_GetAirportsOfCoalition()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #self.airports==0 then
|
if #self.airports==0 then
|
||||||
local text="ERROR! No possible departure/destination airports found."
|
local text=string.format("No possible departure/destination airports found for RAT %s.", tostring(self.alias))
|
||||||
MESSAGE:New(text, 30):ToAll()
|
MESSAGE:New(text, 10):ToAll()
|
||||||
self:E(RAT.id..text)
|
self:E(RAT.id..text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -5254,7 +5351,7 @@ function RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace, departure, take
|
|||||||
|
|
||||||
if spawnonground then
|
if spawnonground then
|
||||||
|
|
||||||
-- Shíps and FARPS seem to have a build in queue.
|
-- Sh<EFBFBD>ps and FARPS seem to have a build in queue.
|
||||||
if spawnonship or spawnonfarp or spawnonrunway or automatic then
|
if spawnonship or spawnonfarp or spawnonrunway or automatic then
|
||||||
self:T(RAT.id..string.format("RAT group %s spawning at farp, ship or runway %s.", self.alias, departure:GetName()))
|
self:T(RAT.id..string.format("RAT group %s spawning at farp, ship or runway %s.", self.alias, departure:GetName()))
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,8 @@
|
|||||||
-- @field #number dtBombtrack Time step [sec] used for tracking released bomb/rocket positions. Default 0.005 seconds.
|
-- @field #number dtBombtrack Time step [sec] used for tracking released bomb/rocket positions. Default 0.005 seconds.
|
||||||
-- @field #number BombtrackThreshold Bombs/rockets/missiles are only tracked if player-range distance is smaller than this threashold [m]. Default 25000 m.
|
-- @field #number BombtrackThreshold Bombs/rockets/missiles are only tracked if player-range distance is smaller than this threashold [m]. Default 25000 m.
|
||||||
-- @field #number Tmsg Time [sec] messages to players are displayed. Default 30 sec.
|
-- @field #number Tmsg Time [sec] messages to players are displayed. Default 30 sec.
|
||||||
|
-- @field #string examinergroupname Name of the examiner group which should get all messages.
|
||||||
|
-- @field #boolean examinerexclusive If true, only the examiner gets messages. If false, clients and examiner get messages.
|
||||||
-- @field #number strafemaxalt Maximum altitude above ground for registering for a strafe run. Default is 914 m = 3000 ft.
|
-- @field #number strafemaxalt Maximum altitude above ground for registering for a strafe run. Default is 914 m = 3000 ft.
|
||||||
-- @field #number ndisplayresult Number of (player) results that a displayed. Default is 10.
|
-- @field #number ndisplayresult Number of (player) results that a displayed. Default is 10.
|
||||||
-- @field Utilities.Utils#SMOKECOLOR BombSmokeColor Color id used for smoking bomb targets.
|
-- @field Utilities.Utils#SMOKECOLOR BombSmokeColor Color id used for smoking bomb targets.
|
||||||
@ -234,6 +236,8 @@ RANGE={
|
|||||||
dtBombtrack=0.005,
|
dtBombtrack=0.005,
|
||||||
BombtrackThreshold=25000,
|
BombtrackThreshold=25000,
|
||||||
Tmsg=30,
|
Tmsg=30,
|
||||||
|
examinergroupname=nil,
|
||||||
|
examinerexclusive=nil,
|
||||||
strafemaxalt=914,
|
strafemaxalt=914,
|
||||||
ndisplayresult=10,
|
ndisplayresult=10,
|
||||||
BombSmokeColor=SMOKECOLOR.Red,
|
BombSmokeColor=SMOKECOLOR.Red,
|
||||||
@ -279,8 +283,8 @@ RANGE.MenuF10={}
|
|||||||
RANGE.id="RANGE | "
|
RANGE.id="RANGE | "
|
||||||
|
|
||||||
--- Range script version.
|
--- Range script version.
|
||||||
-- @field #number version
|
-- @field #string version
|
||||||
RANGE.version="1.2.0"
|
RANGE.version="1.2.1"
|
||||||
|
|
||||||
--TODO list:
|
--TODO list:
|
||||||
--TODO: Add custom weapons, which can be specified by the user.
|
--TODO: Add custom weapons, which can be specified by the user.
|
||||||
@ -434,6 +438,15 @@ function RANGE:SetMessageTimeDuration(time)
|
|||||||
self.Tmsg=time or RANGE.Defaults.Tmsg
|
self.Tmsg=time or RANGE.Defaults.Tmsg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set messages to examiner. The examiner will receive messages from all clients.
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #string examinergroupname Name of the group of the examiner.
|
||||||
|
-- @param #boolean exclusively If true, messages are send exclusively to the examiner, i.e. not to the clients.
|
||||||
|
function RANGE:SetMessageToExaminer(examinergroupname, exclusively)
|
||||||
|
self.examinergroupname=examinergroupname
|
||||||
|
self.examinerexclusive=exclusively
|
||||||
|
end
|
||||||
|
|
||||||
--- Set max number of player results that are displayed.
|
--- Set max number of player results that are displayed.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #number nmax Number of results. Default is 10.
|
-- @param #number nmax Number of results. Default is 10.
|
||||||
@ -2119,13 +2132,24 @@ function RANGE:_DisplayMessageToGroup(_unit, _text, _time, _clear)
|
|||||||
-- Group ID.
|
-- Group ID.
|
||||||
local _gid=_unit:GetGroup():GetID()
|
local _gid=_unit:GetGroup():GetID()
|
||||||
|
|
||||||
if _gid then
|
if _gid and not self.examinerexclusive then
|
||||||
if _clear == true then
|
if _clear == true then
|
||||||
trigger.action.outTextForGroup(_gid, _text, _time, _clear)
|
trigger.action.outTextForGroup(_gid, _text, _time, _clear)
|
||||||
else
|
else
|
||||||
trigger.action.outTextForGroup(_gid, _text, _time)
|
trigger.action.outTextForGroup(_gid, _text, _time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.examinergroupname~=nil then
|
||||||
|
local _examinerid=GROUP:FindByName(self.examinergroupname):GetID()
|
||||||
|
if _examinerid then
|
||||||
|
if _clear == true then
|
||||||
|
trigger.action.outTextForGroup(_examinerid, _text, _time, _clear)
|
||||||
|
else
|
||||||
|
trigger.action.outTextForGroup(_examinerid, _text, _time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
1129
Moose Development/Moose/Functional/Warehouse.lua
Normal file
1129
Moose Development/Moose/Functional/Warehouse.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -265,14 +265,14 @@ AIRBASE.PersianGulf = {
|
|||||||
--
|
--
|
||||||
-- Supported types are:
|
-- Supported types are:
|
||||||
--
|
--
|
||||||
-- * AIRBASE.TerminalType.Runway: Valid spawn points on runway.
|
-- * AIRBASE.TerminalType.Runway = 16: Valid spawn points on runway.
|
||||||
-- * AIRBASE.TerminalType.HelicopterOnly: Special spots for Helicopers.
|
-- * AIRBASE.TerminalType.HelicopterOnly = 40: Special spots for Helicopers.
|
||||||
-- * AIRBASE.TerminalType.Shelter: Hardened Air Shelter. Currently only on Caucaus map.
|
-- * AIRBASE.TerminalType.Shelter = 68: Hardened Air Shelter. Currently only on Caucaus map.
|
||||||
-- * AIRBASE.TerminalType.OpenMed: Open/Shelter air airplane only.
|
-- * AIRBASE.TerminalType.OpenMed = 72: Open/Shelter air airplane only.
|
||||||
-- * AIRBASE.TerminalType.OpenBig: Open air spawn points. Generally larger but does not guarantee large aircraft are capable of spawning there.
|
-- * AIRBASE.TerminalType.OpenBig = 104: Open air spawn points. Generally larger but does not guarantee large aircraft are capable of spawning there.
|
||||||
-- * AIRBASE.TerminalType.OpenMedOrBig: Combines OpenMed and OpenBig spots.
|
-- * AIRBASE.TerminalType.OpenMedOrBig = 176: Combines OpenMed and OpenBig spots.
|
||||||
-- * AIRBASE.TerminalType.HelicopterUnsable: Combines HelicopterOnly, OpenMed and OpenBig.
|
-- * AIRBASE.TerminalType.HelicopterUnsable = 216: Combines HelicopterOnly, OpenMed and OpenBig.
|
||||||
-- * AIRBASE.TerminalType.FighterAircraft: Combines Shelter. OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft.
|
-- * AIRBASE.TerminalType.FighterAircraft = 244: Combines Shelter. OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft.
|
||||||
-- @field TerminalType
|
-- @field TerminalType
|
||||||
AIRBASE.TerminalType = {
|
AIRBASE.TerminalType = {
|
||||||
Runway=16,
|
Runway=16,
|
||||||
@ -349,7 +349,7 @@ function AIRBASE.GetAllAirbases(coalition)
|
|||||||
|
|
||||||
local airbases={}
|
local airbases={}
|
||||||
for _,airbase in pairs(_DATABASE.AIRBASES) do
|
for _,airbase in pairs(_DATABASE.AIRBASES) do
|
||||||
if (coalition~=nil and self:GetCoalition()==coalition) or coalition==nil then
|
if (coalition~=nil and airbase:GetCoalition()==coalition) or coalition==nil then
|
||||||
table.insert(airbases, airbase)
|
table.insert(airbases, airbase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -335,8 +335,7 @@ end
|
|||||||
|
|
||||||
--- Returns the country of the DCS Group.
|
--- Returns the country of the DCS Group.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return DCS#country.id The country identifier.
|
-- @return DCS#country.id The country identifier or nil if the DCS Group is not existing or alive.
|
||||||
-- @return #nil The DCS Group is not existing or alive.
|
|
||||||
function GROUP:GetCountry()
|
function GROUP:GetCountry()
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
@ -350,6 +349,40 @@ function GROUP:GetCountry()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if at least one (or all) unit(s) has (have) a certain attribute.
|
||||||
|
-- See [hoggit documentation](https://wiki.hoggitworld.com/view/DCS_func_hasAttribute).
|
||||||
|
-- @param #GROUP self
|
||||||
|
-- @param #string attribute The name of the attribute the group is supposed to have. Valid attributes can be found in the "db_attributes.lua" file which is located at in "C:\Program Files\Eagle Dynamics\DCS World\Scripts\Database".
|
||||||
|
-- @param #boolean all If true, all units of the group must have the attribute in order to return true. Default is only one unit of a heterogenious group needs to have the attribute.
|
||||||
|
-- @return #boolean Group has this attribute.
|
||||||
|
function GROUP:HasAttribute(attribute, all)
|
||||||
|
|
||||||
|
-- Get all units of the group.
|
||||||
|
local _units=self:GetUnits()
|
||||||
|
|
||||||
|
local _allhave=true
|
||||||
|
local _onehas=false
|
||||||
|
|
||||||
|
for _,_unit in pairs(_units) do
|
||||||
|
local _unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
if _unit then
|
||||||
|
local _hastit=_unit:HasAttribute(attribute)
|
||||||
|
if _hastit==true then
|
||||||
|
_onehas=true
|
||||||
|
else
|
||||||
|
_allhave=false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if all==true then
|
||||||
|
return _allhave
|
||||||
|
else
|
||||||
|
return _onehas
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the maximum speed of the group.
|
--- Returns the maximum speed of the group.
|
||||||
-- If the group is heterogenious and consists of different units, the max speed of the slowest unit is returned.
|
-- If the group is heterogenious and consists of different units, the max speed of the slowest unit is returned.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
@ -1339,97 +1372,100 @@ function GROUP:Respawn( Template, Reset )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param Wrapper.Group#GROUP self
|
--- Respawn a group at an airbase.
|
||||||
function GROUP:RespawnAtAirbase( AirbaseRespawn, Takeoff, TakeoffAltitude ) -- R2.4
|
-- Note that the group has to be on parking spots at the airbase already in order for this to work.
|
||||||
self:F( { AirbaseRespawn, Takeoff, TakeoffAltitude } )
|
-- So each unit of the group is respawned at exactly the same parking spot as it currently occupies.
|
||||||
|
-- @param Wrapper.Group#GROUP self
|
||||||
local PointVec3 = AirbaseRespawn:GetPointVec3()
|
-- @param #table SpawnTemplate (Optional) The spawn template for the group. If no template is given it is exacted from the group.
|
||||||
|
-- @param Core.Spawn#SPAWN.Takeoff Takeoff (Optional) Takeoff type. Sould be either SPAWN.Takeoff.Cold or SPAWN.Takeoff.Hot. Default is SPAWN.Takeoff.Hot.
|
||||||
|
-- @param #boolean Uncontrolled (Optional) If true, spawn in uncontrolled state.
|
||||||
|
-- @return Wrapper.Group#GROUP Group spawned at airbase or nil if group could not be spawned.
|
||||||
|
function GROUP:RespawnAtCurrentAirbase(SpawnTemplate, Takeoff, Uncontrolled) -- R2.4
|
||||||
|
self:F2( { SpawnTemplate, Takeoff, Uncontrolled} )
|
||||||
|
|
||||||
|
-- Get closest airbase. Should be the one we are currently on.
|
||||||
|
local airbase=self:GetCoordinate():GetClosestAirbase()
|
||||||
|
|
||||||
|
if airbase then
|
||||||
|
self:F2("Closest airbase = "..airbase:GetName())
|
||||||
|
else
|
||||||
|
self:E("ERROR: could not find closest airbase!")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
-- Takeoff type. Default hot.
|
||||||
Takeoff = Takeoff or SPAWN.Takeoff.Hot
|
Takeoff = Takeoff or SPAWN.Takeoff.Hot
|
||||||
|
|
||||||
local SpawnTemplate = self:GetTemplate()
|
-- Coordinate of the airbase.
|
||||||
|
local AirbaseCoord=airbase:GetCoordinate()
|
||||||
|
|
||||||
|
-- Spawn template.
|
||||||
|
SpawnTemplate = SpawnTemplate or self:GetTemplate()
|
||||||
|
|
||||||
if SpawnTemplate then
|
if SpawnTemplate then
|
||||||
|
|
||||||
local SpawnPoint = SpawnTemplate.route.points[1]
|
local SpawnPoint = SpawnTemplate.route.points[1]
|
||||||
|
|
||||||
-- These are only for ships.
|
-- These are only for ships.
|
||||||
SpawnPoint.linkUnit = nil
|
SpawnPoint.linkUnit = nil
|
||||||
SpawnPoint.helipadId = nil
|
SpawnPoint.helipadId = nil
|
||||||
SpawnPoint.airdromeId = nil
|
SpawnPoint.airdromeId = nil
|
||||||
|
|
||||||
local AirbaseID = AirbaseRespawn:GetID()
|
-- Aibase id and category.
|
||||||
local AirbaseCategory = AirbaseRespawn:GetDesc().category
|
local AirbaseID = airbase:GetID()
|
||||||
self:F( { AirbaseCategory = AirbaseCategory, Ship = Airbase.Category.SHIP, Helipad = Airbase.Category.HELIPAD, Airdrome = Airbase.Category.AIRDROME } )
|
local AirbaseCategory = airbase:GetDesc().category
|
||||||
|
|
||||||
if AirbaseCategory == Airbase.Category.SHIP then
|
if AirbaseCategory == Airbase.Category.SHIP or AirbaseCategory == Airbase.Category.HELIPAD then
|
||||||
SpawnPoint.linkUnit = AirbaseID
|
SpawnPoint.linkUnit = AirbaseID
|
||||||
SpawnPoint.helipadId = AirbaseID
|
|
||||||
elseif AirbaseCategory == Airbase.Category.HELIPAD then
|
|
||||||
SpawnPoint.linkUnit = AirbaseID
|
|
||||||
SpawnPoint.helipadId = AirbaseID
|
SpawnPoint.helipadId = AirbaseID
|
||||||
elseif AirbaseCategory == Airbase.Category.AIRDROME then
|
elseif AirbaseCategory == Airbase.Category.AIRDROME then
|
||||||
SpawnPoint.airdromeId = AirbaseID
|
SpawnPoint.airdromeId = AirbaseID
|
||||||
end
|
end
|
||||||
|
|
||||||
SpawnPoint.alt = 0
|
SpawnPoint.alt = AirbaseCoord:GetLandHeight()
|
||||||
|
SpawnPoint.type = GROUPTEMPLATE.Takeoff[Takeoff][1] -- type
|
||||||
SpawnPoint.type = GROUPTEMPLATE.Takeoff[Takeoff][1] -- type
|
|
||||||
SpawnPoint.action = GROUPTEMPLATE.Takeoff[Takeoff][2] -- action
|
SpawnPoint.action = GROUPTEMPLATE.Takeoff[Takeoff][2] -- action
|
||||||
|
|
||||||
|
-- Get the units of the group.
|
||||||
|
local units=self:GetUnits()
|
||||||
|
|
||||||
-- Translate the position of the Group Template to the Vec3.
|
for UnitID,_unit in pairs(units) do
|
||||||
for UnitID = 1, #SpawnTemplate.units do
|
|
||||||
self:T( 'Before Translation SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
|
||||||
-- These cause a lot of confusion.
|
-- Get closest parking spot of current unit. Note that we look for occupied spots since the unit is currently sitting on it!
|
||||||
local UnitTemplate = SpawnTemplate.units[UnitID]
|
local Parkingspot, TermialID, Distance=unit:GetCoordinate():GetClosestParkingSpot(airbase)
|
||||||
|
|
||||||
UnitTemplate.parking = 15
|
|
||||||
UnitTemplate.parking_id = "30"
|
|
||||||
UnitTemplate.alt = 0
|
|
||||||
|
|
||||||
local SX = UnitTemplate.x
|
|
||||||
local SY = UnitTemplate.y
|
|
||||||
local BX = SpawnPoint.x
|
|
||||||
local BY = SpawnPoint.y
|
|
||||||
local TX = PointVec3.x + ( SX - BX )
|
|
||||||
local TY = PointVec3.z + ( SY - BY )
|
|
||||||
|
|
||||||
UnitTemplate.x = TX
|
--Parkingspot:MarkToAll("parking spot")
|
||||||
UnitTemplate.y = TY
|
self:T2(string.format("Closest parking spot distance = %s, terminal ID=%s", tostring(Distance), tostring(TermialID)))
|
||||||
|
|
||||||
if Takeoff == GROUP.Takeoff.Air then
|
|
||||||
UnitTemplate.alt = PointVec3.y + ( TakeoffAltitude or 200 )
|
|
||||||
--else
|
|
||||||
-- UnitTemplate.alt = PointVec3.y + 10
|
|
||||||
end
|
|
||||||
self:T( 'After Translation SpawnTemplate.units['..UnitID..'].x = ' .. UnitTemplate.x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. UnitTemplate.y )
|
|
||||||
end
|
|
||||||
|
|
||||||
SpawnPoint.x = PointVec3.x
|
|
||||||
SpawnPoint.y = PointVec3.z
|
|
||||||
|
|
||||||
if Takeoff == GROUP.Takeoff.Air then
|
|
||||||
SpawnPoint.alt = PointVec3.y + ( TakeoffAltitude or 200 )
|
|
||||||
--else
|
|
||||||
-- SpawnPoint.alt = PointVec3.y + 10
|
|
||||||
end
|
|
||||||
|
|
||||||
SpawnTemplate.x = PointVec3.x
|
-- Get unit coordinates for respawning position.
|
||||||
SpawnTemplate.y = PointVec3.z
|
local uc=unit:GetCoordinate()
|
||||||
|
SpawnTemplate.units[UnitID].x = Parkingspot.x
|
||||||
local GroupSpawned = self:Respawn( SpawnTemplate )
|
SpawnTemplate.units[UnitID].y = Parkingspot.z
|
||||||
|
SpawnTemplate.units[UnitID].alt = Parkingspot.y
|
||||||
-- When spawned in the air, we need to generate a Takeoff Event
|
|
||||||
|
|
||||||
if Takeoff == GROUP.Takeoff.Air then
|
|
||||||
for UnitID, UnitSpawned in pairs( GroupSpawned:GetUnits() ) do
|
|
||||||
SCHEDULER:New( nil, BASE.CreateEventTakeoff, { GroupSpawned, timer.getTime(), UnitSpawned:GetDCSObject() } , 1 )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return GroupSpawned
|
SpawnTemplate.units[UnitID].parking = TermialID
|
||||||
|
SpawnTemplate.units[UnitID].parking_id = nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
SpawnPoint.x = AirbaseCoord.x
|
||||||
|
SpawnPoint.y = AirbaseCoord.z
|
||||||
|
|
||||||
|
SpawnTemplate.x = AirbaseCoord.x
|
||||||
|
SpawnTemplate.y = AirbaseCoord.z
|
||||||
|
|
||||||
|
-- Set uncontrolled state.
|
||||||
|
SpawnTemplate.uncontrolled=Uncontrolled
|
||||||
|
|
||||||
|
-- Destroy and respawn.
|
||||||
|
self:Destroy()
|
||||||
|
_DATABASE:Spawn( SpawnTemplate )
|
||||||
|
|
||||||
|
-- Reset events.
|
||||||
|
self:ResetEvents()
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -57,6 +57,7 @@ Functional/ZoneCaptureCoalition.lua
|
|||||||
Functional/Artillery.lua
|
Functional/Artillery.lua
|
||||||
Functional/Suppression.lua
|
Functional/Suppression.lua
|
||||||
Functional/PseudoATC.lua
|
Functional/PseudoATC.lua
|
||||||
|
Functional/Warehouse.lua
|
||||||
|
|
||||||
AI/AI_Balancer.lua
|
AI/AI_Balancer.lua
|
||||||
AI/AI_A2A.lua
|
AI/AI_A2A.lua
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user