mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
G2G Warehouse
This commit is contained in:
@@ -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 )
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
|||||||
-- @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.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- Pickup Handler OnAfter for AI_CARGO_AIRPLANE
|
--- Pickup Handler OnAfter for AI_CARGO_AIRPLANE
|
||||||
@@ -63,18 +63,18 @@ function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
|||||||
-- @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.
|
||||||
|
|
||||||
--- 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.
|
||||||
|
|
||||||
--- 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.
|
||||||
|
|
||||||
--- 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
|
||||||
@@ -82,7 +82,8 @@ function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
|||||||
-- @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
|
||||||
@@ -91,19 +92,21 @@ function AI_CARGO_AIRPLANE:New( Airplane, CargoSet )
|
|||||||
-- @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.
|
||||||
|
|
||||||
self:SetCarrier( Airplane )
|
self:SetCarrier( Airplane )
|
||||||
|
|
||||||
@@ -190,13 +193,12 @@ function AI_CARGO_AIRPLANE:FindCarrier( Coordinate, Radius )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after "Landed" event. Called on engine shutdown.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane 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
|
if Airplane and Airplane:IsAlive() then
|
||||||
@@ -216,8 +218,8 @@ 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
|
||||||
-- @param From
|
-- @param From
|
||||||
-- @param Event
|
-- @param Event
|
||||||
@@ -227,24 +229,34 @@ end
|
|||||||
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() then
|
||||||
self:Route( Airplane, Airbase, Speed )
|
|
||||||
|
-- Aircraft might be on the ground of the pickup airbase already.
|
||||||
|
if Airplane:InAir() then
|
||||||
|
self:Route( Airplane, Airbase, Speed )
|
||||||
|
end
|
||||||
|
-- TODO: Improve :Route() so that the aircraft can be routed from another airbase to the pickup airbase.
|
||||||
|
|
||||||
self.RoutePickup = true
|
self.RoutePickup = true
|
||||||
|
|
||||||
|
-- Set airbase as starting point in the next Route() call.
|
||||||
self.Airbase = Airbase
|
self.Airbase = Airbase
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- On after Depoly event. Routes plane to deploy airbase.
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param Wrapper.Group#GROUP Airplane
|
||||||
-- @param From
|
-- @param From
|
||||||
-- @param Event
|
-- @param Event
|
||||||
-- @param To
|
-- @param To
|
||||||
-- @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() then
|
||||||
|
|
||||||
|
-- Route to
|
||||||
self:Route( Airplane, Airbase, Speed )
|
self:Route( Airplane, Airbase, Speed )
|
||||||
self.RouteDeploy = true
|
self.RouteDeploy = true
|
||||||
self.Airbase = Airbase
|
self.Airbase = Airbase
|
||||||
@@ -253,26 +265,37 @@ function AI_CARGO_AIRPLANE:onafterDeploy( Airplane, From, Event, To, Airbase, Sp
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Load event.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Transport plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
|
-- @param Wrapper.Point#COORDINATE Coordinate
|
||||||
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() then
|
||||||
|
|
||||||
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
for _, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
|
local Cargo=Cargo --Cargo.Cargo#CARGO
|
||||||
if Cargo:IsInLoadRadius( Coordinate ) then
|
if Cargo:IsInLoadRadius( Coordinate ) 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.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
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,8 +309,12 @@ function AI_CARGO_AIRPLANE:onafterBoard( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Loaded event.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
function AI_CARGO_AIRPLANE:onafterLoaded( Airplane, From, Event, To )
|
function AI_CARGO_AIRPLANE:onafterLoaded( Airplane, From, Event, To )
|
||||||
|
|
||||||
if Airplane and Airplane:IsAlive() then
|
if Airplane and Airplane:IsAlive() then
|
||||||
@@ -296,8 +323,12 @@ function AI_CARGO_AIRPLANE:onafterLoaded( Airplane, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Unload event.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
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 +338,12 @@ function AI_CARGO_AIRPLANE:onafterUnload( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Unboard event.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
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 +356,12 @@ function AI_CARGO_AIRPLANE:onafterUnboard( Airplane, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_AIRPLANE self
|
--- On after Unloaded event.
|
||||||
-- @param Wrapper.Group#GROUP Airplane
|
-- @param #AI_CARGO_AIRPLANE self
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane Cargo plane.
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
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
|
||||||
|
|||||||
@@ -185,12 +185,12 @@ do
|
|||||||
infantry = {},
|
infantry = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- @field category
|
||||||
WAREHOUSE.category= {
|
WAREHOUSE.category= {
|
||||||
Transport=1,
|
Transport=1,
|
||||||
Figherplane=1,
|
Fighter=1,
|
||||||
AWACS=1,
|
AWACS=1,
|
||||||
Tanker=1,
|
Tanker=1,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--- WAREHOUSE constructor. Creates a new WAREHOUSE object.
|
--- WAREHOUSE constructor. Creates a new WAREHOUSE object.
|
||||||
@@ -206,10 +206,10 @@ do
|
|||||||
self.coordinate=airbase:GetCoordinate()
|
self.coordinate=airbase:GetCoordinate()
|
||||||
self.coalition=airbase:GetCoalition()
|
self.coalition=airbase:GetCoalition()
|
||||||
|
|
||||||
|
self:AddTransition("*", "Start", "Running")
|
||||||
self:AddTransition("*", "Start", "Idle")
|
self:AddTransition("*", "Status", "*")
|
||||||
self:AddTransition("*", "Status", "*")
|
self:AddTransition("*", "Request", "*")
|
||||||
self:AddTransition("*", "Request", "*")
|
self:AddTransition("*", "Delivered", "*")
|
||||||
|
|
||||||
--- Triggers the FSM event "Start".
|
--- Triggers the FSM event "Start".
|
||||||
-- @function [parent=#WAREHOUSE] Start
|
-- @function [parent=#WAREHOUSE] Start
|
||||||
@@ -236,6 +236,7 @@ do
|
|||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase requesting supply.
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase requesting supply.
|
||||||
-- @param #string Asset Asset that is requested.
|
-- @param #string Asset Asset that is requested.
|
||||||
|
-- @param #number nAsset Number of assets requested. Default 1.
|
||||||
-- @param #string TransportType Type of transport: "Plane", "Helicopter", "APC"
|
-- @param #string TransportType Type of transport: "Plane", "Helicopter", "APC"
|
||||||
|
|
||||||
--- Triggers the FSM event "Request" after a delay.
|
--- Triggers the FSM event "Request" after a delay.
|
||||||
@@ -244,8 +245,20 @@ do
|
|||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase requesting supply.
|
-- @param Wrapper.Airbase#AIRBASE Airbase Airbase requesting supply.
|
||||||
-- @param #string Asset Asset that is requested.
|
-- @param #string Asset Asset that is requested.
|
||||||
|
-- @param #number nAsset Number of assets requested. Default 1.
|
||||||
-- @param #string TransportType Type of transport: "Plane", "Helicopter", "APC"
|
-- @param #string TransportType Type of transport: "Plane", "Helicopter", "APC"
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Delivered".
|
||||||
|
-- @function [parent=#WAREHOUSE] Delivered
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param Wrapper.Group#GROUP group Group that was delivered.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Delivered" after a delay.
|
||||||
|
-- @function [parent=#WAREHOUSE] __Delivered
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param Wrapper.Group#GROUP group Group that was delivered.
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -255,7 +268,7 @@ do
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function WAREHOUSE:onafterStart(From, Event, To)
|
function WAREHOUSE:onafterStart(From, Event, To)
|
||||||
env.info("FF starting warehouse of airbase of "..self.homebase:GetName())
|
env.info("FF starting warehouse at airbase "..self.homebase:GetName())
|
||||||
|
|
||||||
-- handle events
|
-- handle events
|
||||||
-- event takeoff
|
-- event takeoff
|
||||||
@@ -272,7 +285,7 @@ do
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function WAREHOUSE:onafterStatus(From, Event, To)
|
function WAREHOUSE:onafterStatus(From, Event, To)
|
||||||
env.info("FF checking warehouse status of "..self.homebase:GetName())
|
env.info("FF checking warehouse status of airbase "..self.homebase:GetName())
|
||||||
|
|
||||||
env.info(string.format("FF warehouse at %s: number of transport planes = %d", self.homebase:GetName(), #self.plane))
|
env.info(string.format("FF warehouse at %s: number of transport planes = %d", self.homebase:GetName(), #self.plane))
|
||||||
|
|
||||||
@@ -295,14 +308,30 @@ do
|
|||||||
|
|
||||||
if TransportType=="Air" then
|
if TransportType=="Air" then
|
||||||
|
|
||||||
local template=self.plane[math.random(#self.plane)]
|
-- Get a random template from the stock list.
|
||||||
|
local _chosenone=math.random(#self.plane)
|
||||||
|
|
||||||
|
-- Select template group name.
|
||||||
|
local template=self.plane[_chosenone]
|
||||||
|
|
||||||
if template then
|
if template then
|
||||||
|
|
||||||
|
-- Spawn plane at warehouse homebase.
|
||||||
local Plane=SPAWN:New(template):SpawnAtAirbase(Airbase, nil, nil, nil, false)
|
local Plane=SPAWN:New(template):SpawnAtAirbase(Airbase, nil, nil, nil, false)
|
||||||
|
|
||||||
|
if Plane==nil then
|
||||||
|
-- Plane was not spawned correctly. Try again in 60 seconds.
|
||||||
|
self:__Request( 60, Airbase, Asset, nAsset, TransportType)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- Remove chosen plane from list.
|
||||||
|
table.remove(self.plane,_chosenone)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- New empty cargo set.
|
||||||
local CargoGroups = SET_CARGO:New()
|
local CargoGroups = SET_CARGO:New()
|
||||||
|
|
||||||
|
-- Spawn requested assets.
|
||||||
local spawn=SPAWN:New("Infantry Platoon Alpha")
|
local spawn=SPAWN:New("Infantry Platoon Alpha")
|
||||||
|
|
||||||
for i=1,nAsset do
|
for i=1,nAsset do
|
||||||
@@ -311,20 +340,49 @@ do
|
|||||||
CargoGroups:AddCargo(cargogroup)
|
CargoGroups:AddCargo(cargogroup)
|
||||||
end
|
end
|
||||||
|
|
||||||
local CargoPlane = AI_CARGO_AIRPLANE:New(Plane, CargoGroups)
|
-- Define cargo airplane.
|
||||||
|
local CargoPlane = AI_CARGO_AIRPLANE:New(Plane, CargoGroups)
|
||||||
|
|
||||||
|
-- Pickup cargo at homebase.
|
||||||
CargoPlane:__Pickup(5, self.homebase)
|
CargoPlane:__Pickup(5, self.homebase)
|
||||||
|
|
||||||
function CargoPlane:onafterLoaded( Airplane, From, Event, To, Cargo)
|
-- Set warehouse state so that we can retreive it later.
|
||||||
|
Plane:SetState(Plane, "WAREHOUSE", self)
|
||||||
|
|
||||||
|
-- Once the cargo was loaded start off to deploy airbase.
|
||||||
|
function CargoPlane:OnAfterLoaded(Airplane, From, Event, To)
|
||||||
CargoPlane:__Deploy(10, Airbase, 500)
|
CargoPlane:__Deploy(10, Airbase, 500)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Function
|
||||||
|
-- @param Wrapper.Group#GROUP Airplane
|
||||||
|
function CargoPlane:OnAfterUnloaded(Airplane, From, Event, To)
|
||||||
|
local group=CargoPlane.Cargo:GetObject()
|
||||||
|
local Airplane=Airplane --Wrapper.Group#GROUP
|
||||||
|
local warehouse Airplane:GetState(Airplane, "WAREHOUSE") --#WAREHOUSE
|
||||||
|
warehouse:__Delivered(1, group)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Warehouse
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Wrapper.Group#GROUP Group The group that was delivered.
|
||||||
|
-- @param #string Asset Asset that is requested.
|
||||||
|
-- @param #number nAssed Number of groups of that asset requested.
|
||||||
|
-- @param #string TransportType Type of transport: "Plane", "Helicopter", "APC"
|
||||||
|
function WAREHOUSE:onafterDelivered(From, Event, To, Group)
|
||||||
|
local road=Group:GetCoordinate():GetClosestPointToRoad()
|
||||||
|
local speed=Group:GetSpeedMax()*0.5
|
||||||
|
Group:RouteGroundTo(road, speed, "Off Road")
|
||||||
|
end
|
||||||
|
|
||||||
--- Add an airplane group to the warehouse stock.
|
--- Add an airplane group to the warehouse stock.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param #string templateprefix Name of the late activated template group as defined in the mission editor.
|
-- @param #string templateprefix Name of the late activated template group as defined in the mission editor.
|
||||||
@@ -342,26 +400,43 @@ do
|
|||||||
local DCScategory=DCSgroup:getCategory()
|
local DCScategory=DCSgroup:getCategory()
|
||||||
local DCStype=DCSunit:getTypeName()
|
local DCStype=DCSunit:getTypeName()
|
||||||
|
|
||||||
--env.info(string.format("FF adding %d transport plane template %s type %s, display %s", n, tostring(templateprefix), tostring(typename), tostring(displayname)))
|
-- Add this n times to the table.
|
||||||
|
|
||||||
--[[
|
|
||||||
-- Create a table with properties.
|
|
||||||
self.airplane[templateprefix]=self.airplane[templateprefix] or {}
|
|
||||||
|
|
||||||
-- Increase number in stock.
|
|
||||||
if self.airplane[templateprefix].nstock then
|
|
||||||
self.airplane[templateprefix].nstock=self.airplane[templateprefix].nstock+n
|
|
||||||
else
|
|
||||||
self.airplane[templateprefix].nstock=n
|
|
||||||
end
|
|
||||||
|
|
||||||
self.airplane[templateprefix].nstock=n
|
|
||||||
]]
|
|
||||||
|
|
||||||
for i=1,n do
|
for i=1,n do
|
||||||
table.insert(self.plane, templateprefix)
|
table.insert(self.plane, templateprefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Add an airplane group to the warehouse stock.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #string templateprefix Name of the late activated template group as defined in the mission editor.
|
||||||
|
-- @param #number n Number of groups to add to the warehouse stock.
|
||||||
|
-- @return #WAREHOUSE self
|
||||||
|
function WAREHOUSE:AddInfantry(templateprefix, n)
|
||||||
|
|
||||||
|
local n=n or 1
|
||||||
|
|
||||||
|
local group=GROUP:FindByName(templateprefix)
|
||||||
|
|
||||||
|
if group then
|
||||||
|
|
||||||
|
local DCSgroup=group:GetDCSObject()
|
||||||
|
local DCSunit=DCSgroup:getUnit(1)
|
||||||
|
local DCSdesc=DCSunit:getDesc()
|
||||||
|
local DCSdisplay=DCSunit:getDesc().displayName
|
||||||
|
local DCScategory=DCSgroup:getCategory()
|
||||||
|
local DCStype=DCSunit:getTypeName()
|
||||||
|
|
||||||
|
-- Add this n times to the table.
|
||||||
|
for i=1,n do
|
||||||
|
table.insert(self.infantry, {templatename=templateprefix, category=DCScategory, typename=DCStype})
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -799,7 +799,6 @@ end
|
|||||||
-- @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()
|
||||||
|
|||||||
Reference in New Issue
Block a user