Warehouse 0.1.9

Many bugs spotted
This commit is contained in:
funkyfranky 2018-08-16 23:10:23 +02:00
parent 22da329fca
commit 5a2e1f01b4
4 changed files with 112 additions and 100 deletions

View File

@ -2116,7 +2116,7 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live
end end
-- Modify the spawn template to follow the flight plan. -- Modify the spawn template to follow the flight plan.
local successful=self:_ModifySpawnTemplate(waypoints, livery, _lastpos, departure, takeoff) local successful=self:_ModifySpawnTemplate(waypoints, livery, _lastpos, departure, takeoff, parkingdata)
if not successful then if not successful then
return nil return nil
end end

View File

@ -191,7 +191,7 @@ WAREHOUSE.TransportType = {
--- Warehouse class version. --- Warehouse class version.
-- @field #string version -- @field #string version
WAREHOUSE.version="0.1.8w" WAREHOUSE.version="0.1.9"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Warehouse todo list. -- TODO: Warehouse todo list.
@ -1118,7 +1118,7 @@ function WAREHOUSE:onafterRequest(From, Event, To, Request)
CargoTransport = AI_CARGO_DISPATCHER_HELICOPTER:New(TransportSet, CargoGroups, DeployZoneSet) CargoTransport = AI_CARGO_DISPATCHER_HELICOPTER:New(TransportSet, CargoGroups, DeployZoneSet)
-- Home zone. -- Home zone.
CargoTransport:Setairbase(self.airbase) --CargoTransport:Setairbase(self.airbase)
--CargoTransport:SetHomeZone(self.spawnzone) --CargoTransport:SetHomeZone(self.spawnzone)
elseif Request.transporttype==WAREHOUSE.TransportType.APC then elseif Request.transporttype==WAREHOUSE.TransportType.APC then
@ -1563,17 +1563,21 @@ end
function WAREHOUSE:_RouteAirRat(Aircraft, ToAirbase, Speed) function WAREHOUSE:_RouteAirRat(Aircraft, ToAirbase, Speed)
if Aircraft and Aircraft:IsAlive()~=nil then if Aircraft and Aircraft:IsAlive()~=nil then
-- Get parking data of all units. -- Get parking data of all units.
local parkingdata={} local parkingdata={}
local units=Aircraft:GetUnits() local units=Aircraft:GetUnits()
for _,_unit in pairs(units) do for _,_unit in pairs(units) do
local unit=_unit --Wrapper.Unit#UNIT local unit=_unit --Wrapper.Unit#UNIT
local _spot,_terminal,_distance=unit:GetCoordinate():GetClosestOccupiedParkingSpot(self.airbase) local _spot,_terminal,_distance=unit:GetCoordinate():GetClosestOccupiedParkingSpot(self.airbase)
table.insert(parkingdata, {spot=_spot, TerminalID=_terminal}) table.insert(parkingdata, {Coordinate=_spot, TerminalID=_terminal})
end end
env.info("FF parking data")
self:E(parkingdata)
-- Create a RAT object to use its flight plan. -- Create a RAT object to use its flight plan.
local rat=RAT:New(Aircraft) local rat=RAT:New(Aircraft:GetName())
-- Init some parameters. -- Init some parameters.
rat:SetDeparture(self.airbase:GetName()) rat:SetDeparture(self.airbase:GetName())
@ -1590,12 +1594,16 @@ function WAREHOUSE:_RouteAirRat(Aircraft, ToAirbase, Speed)
Aircraft:Destroy() Aircraft:Destroy()
-- Spawn RAT aircraft at specific parking sports. -- Spawn RAT aircraft at specific parking sports.
local spawnindex=rat:_SpawnWithRoute(self.airbase:GetName(), ToAirbase:GetName(), RAT.wp.cold, nil, nil, nil, nil, nil, parkingdata) local spawnindex=rat:_SpawnWithRoute(self.airbase:GetName(), ToAirbase:GetName(), RAT.wp.hot, nil, nil, nil, nil, nil, parkingdata)
-- Get the group and check it's name. -- Get the group and check it's name.
local group=rat.ratcraft[spawnindex].group --Wrapper.Group#GROUP local group=rat.ratcraft[spawnindex].group --Wrapper.Group#GROUP
self:E(self.wid..string.format("Spawned new RAT aircraft as group %s", group:GetName())) self:E(self.wid..string.format("Spawned new RAT aircraft as group %s", group:GetName()))
group:SmokeBlue()
-- Activate group.
local bla=group:SetCommand({id='Start', params={}})
self:E({bla=bla})
return group return group
end end

View File

@ -680,6 +680,8 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
local _termid=parkingspot.TerminalID local _termid=parkingspot.TerminalID
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) then
-- Very safe uses the DCS getParking() info to check if a spot is free. Unfortunately, the function returns free=false until the aircraft has actually taken-off. -- Very safe uses the DCS getParking() info to check if a spot is free. Unfortunately, the function returns free=false until the aircraft has actually taken-off.
if verysafe and (parkingspot.Free==false or parkingspot.TOAC==true) then if verysafe and (parkingspot.Free==false or parkingspot.TOAC==true) then
@ -772,7 +774,7 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
if nvalid>=_nspots then if nvalid>=_nspots then
return validspots return validspots
end end
end -- check terminal type
end end
-- Retrun spots we found, even if there were not enough. -- Retrun spots we found, even if there were not enough.

View File

@ -119,11 +119,13 @@ end
-- @param DCS#Unit DCSUnit An existing DCS Unit object reference. -- @param DCS#Unit DCSUnit An existing DCS Unit object reference.
-- @return #UNIT self -- @return #UNIT self
function UNIT:Find( DCSUnit ) function UNIT:Find( DCSUnit )
if DCSUnit then
local UnitName = DCSUnit:getName() local UnitName = DCSUnit:getName()
local UnitFound = _DATABASE:FindUnit( UnitName ) local UnitFound = _DATABASE:FindUnit( UnitName )
return UnitFound return UnitFound
end end
return nil
end
--- Find a UNIT in the _DATABASE using the name of an existing DCS Unit. --- Find a UNIT in the _DATABASE using the name of an existing DCS Unit.
-- @param #UNIT self -- @param #UNIT self