diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index e07e84a40..f188ff3ea 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -358,42 +358,49 @@ WAREHOUSE.Descriptor = { --- Generalized asset attributes. Can be used to request assets with certain general characteristics. -- @type WAREHOUSE.Attribute --- @field #string TRANSPORT_PLANE Airplane with transport capability. Usually bigger, i.e. needs larger airbases and parking spots. --- @field #string TRANSPORT_HELO Helicopter with transport capability. --- @field #string TRANSPORT_APC Amoured Personell Carrier. --- @field #string TRANSPORT_SHIP Ship defined for troop transport. Since most ships can, this attribute must be manually requestet in the AddAddet() function. --- @field #string FIGHTER Fighter, interceptor, ... airplane. --- @field #string TANKER Airplane which can refuel other aircraft. --- @field #string AWACS Airborne Early Warning and Control System. --- @field #string ARTILLERY Artillery assets. --- @field #string INFANTRY Ground infantry assets. --- @field #string BOMBER Aircraft which can be used for bombing. --- @field #string TANK Tanks. --- @field #string TRUCK Unarmed ground vehicles. --- @field #string TRAIN Trains. Not that trains are **not** yet properly implemented in DCS and cannot be used currently. --- @field #string AIRCRAFTCARRIER Ship able to carrier aircraft. --- @field #string WARSHIP Armed war ship, e.g. cruisers, destroyers, firgates and corvettes. --- @filed #string UNARMED_SHIP Any unarmed naval vessel. --- @field #string OTHER Anything that does not fall into any other category. +-- @field #string AIR_TRANSPORTPLANE Airplane with transport capability. This can be used to transport other assets. +-- @field #string AIR_AWACS Airborne Early Warning and Control System. +-- @field #string AIR_FIGHTER Fighter, interceptor, ... airplane. +-- @field #string AIR_BOMBER Aircraft which can be used for strategic bombing. +-- @field #string AIR_TANKER Airplane which can refuel other aircraft. +-- @field #string AIR_TRANSPORTHELO Helicopter with transport capability. This can be used to transport other assets. +-- @field #string AIR_ATTACKHELO Attack helicopter. +-- @field #string AIR_OTHER Any airborne unit that does not fall into any other airborne category. +-- @field #string GROUND_APC Infantry carriers, in particular Amoured Personell Carrier. This can be used to transport other assets. +-- @field #string GROUND_TRUCK Unarmed ground vehicles. +-- @field #string GROUND_INFANTRY Ground infantry assets. +-- @field #string GROUND_ARTILLERY Artillery assets. +-- @field #string GROUND_TANK Tanks (modern or old). +-- @field #string GROUND_TRAIN Trains. Not that trains are **not** yet properly implemented in DCS and cannot be used currently. +-- @field #string GROUND_OTHER Any ground unit that does not fall into any other ground category. +-- @field #string NAVAL_AIRCRAFTCARRIER Aircraft carrier. +-- @field #string NAVAL_WARSHIP War ship, i.e. cruisers, destroyers, firgates and corvettes. +-- @field #string NAVAL_ARMEDSHIP Any armed ship that is not an aircraft carrier, a cruiser, destroyer, firgatte or corvette. +-- @field #string NAVAL_UNARMEDSHIP Any unarmed naval vessel. +-- @field #string NAVAL_OTHER Any naval unit that does not fall into any other naval category. +-- @field #string UNKNOWN Anything that does not fall into any other category. WAREHOUSE.Attribute = { - TRANSPORT_PLANE="Transport_Plane", - TRANSPORT_HELO="Transport_Helo", - TRANSPORT_APC="Transport_APC", - TRANSPORT_SHIP="Transport_Ship", - FIGHTER="Fighter", - TANKER="Tanker", - AWACS="AWACS", - ARTILLERY="Artillery", - ATTACKHELICOPTER="Attackhelicopter", - INFANTRY="Infantry", - BOMBER="Bomber", - TANK="Tank", - TRUCK="Truck", - TRAIN="Train", - AIRCRAFTCARRIER="Aircraftcarrier", - WAR_SHIP="Warship", - UNARMED_SHIP="Unarmedship", - OTHER="Other", + AIR_TRANSPORTPLANE="Air_TransportPlane", + AIR_AWACS="Air_AWACS", + AIR_FIGHTER="Air_Fighter", + AIR_BOMBER="Air_Bomber", + AIR_TANKER="Air_Tanker", + AIR_TRANSPORTHELO="Air_TransportHelo", + AIR_ATTACKHELO="Air_AttackHelo", + AIR_OTHER="Air_Other", + GROUND_APC="Ground_APC", + GROUND_TRUCK="Ground_Truck", + GROUND_INFANTRY="Ground_Infantry", + GROUND_ARTILLERY="Ground_Artillery", + GROUND_TANK="Ground_Tank", + GROUND_TRAIN="Ground_Train", + GROUND_OTHER="Ground_Other", + NAVAL_AIRCRAFTCARRIER="Naval_AircraftCarrier", + NAVAL_WARSHIP="Naval_WarShip", + NAVAL_ARMEDSHIP="Naval_ArmedShip", + NAVAL_UNARMEDSHIP="Naval_UnarmedShip", + NAVAL_OTHER="Naval_Other", + UNKNOWN="Unknown", } --- Cargo transport type. Defines how assets are transported to their destination. @@ -405,11 +412,11 @@ WAREHOUSE.Attribute = { -- @field #string TRAIN Transports are conducted by trains. Not yet implemented. -- @field #string SELFPROPELLED Assets go to their destination by themselves. No transport carrier needed. WAREHOUSE.TransportType = { - AIRPLANE = "Transport_Plane", - HELICOPTER = "Transport_Helo", - APC = "Transport_APC", - SHIP = "Ship", - TRAIN = "Train", + AIRPLANE = "Air_TransportPlane", + HELICOPTER = "Air_TransportHelo", + APC = "Ground_APC", + TRAIN = "Ground_Train", + SHIP = "Naval_UnarmedShip", SELFPROPELLED = "Selfpropelled", } @@ -424,7 +431,7 @@ WAREHOUSE.db = { --- Warehouse class version. -- @field #string version -WAREHOUSE.version="0.2.7w" +WAREHOUSE.version="0.2.8" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO: Warehouse todo list. @@ -844,7 +851,7 @@ end --- Set the port zone for this warehouse. -- The port zone is the zone, where all naval assets of the warehouse are spawned. -- @param #WAREHOUSE self --- @param Core.Zone#ZONE The zone defining the naval port of the warehouse. +-- @param Core.Zone#ZONE zone The zone defining the naval port of the warehouse. -- @return #WAREHOUSE self function WAREHOUSE:SetPortZone(zone) self.portzone=zone @@ -884,31 +891,32 @@ function WAREHOUSE:AddShippingLane(remotewarehouse, group) -- Add the shipping lane. Need to take care of the wrong "direction". local lane={} - lane.towarehouse=remotewarehouse.warehouse:GetName() - lane.coordinates={} + --lane.towarehouse=remotewarehouse.warehouse:GetName() + --lane.coordinates={} if distF need airbase for spawning but not for delivering to the spawn zone of the receiver. - if self.category==-1 then - self:E("ERROR: Incorrect request. Warehouse has no airbase. Transport by helicopter not possible!") - valid=false - end - - elseif request.transporttype==WAREHOUSE.TransportType.SHIP then - - -- Transport by ship. - self:E("ERROR: Incorrect request. Transport by SHIP not implemented yet!") - valid=false - - elseif request.transporttype==WAREHOUSE.TransportType.TRAIN then - - -- Transport by train. - self:E("ERROR: Incorrect request. Transport by TRAIN not implemented yet!") - valid=false - - else - -- No match. - self:E("ERROR: Incorrect request. Transport type unknown!") - valid=false - end - - end - - -- Add request as unvalid and delete it later. - if valid==false then - self:E(self.wid..string.format("Got invalid request id=%d.", request.uid)) - table.insert(invalid, request) - else - self:T3(self.wid..string.format("Got valid request id=%d.", request.uid)) - end - - end -- loop queue items. - + end end --- Check if a request is valid in general. If not, it will be removed from the queue. @@ -3339,13 +3215,16 @@ function WAREHOUSE:_CheckRequestValid(request) end if asset_train then + -- Check if there is a valid path on rail. local hasrail=self:HasConnectionRail(request.warehouse) if not hasrail then self:E("ERROR: Incorrect request. No valid path on rail for train assets!") valid=false end + else + if self.warehouse:GetName()~=request.warehouse.warehouse:GetName() then -- Check if there is a valid path on road. local hasroad=self:HasConnectionRoad(request.warehouse) @@ -3354,11 +3233,17 @@ function WAREHOUSE:_CheckRequestValid(request) valid=false end end - end + + end + elseif asset_naval then - self:E("ERROR: Incorrect request. Naval units not supported yet!") - valid=false + local shippinglane=self:HasConnectionNaval(request.warehouse) + + if not shippinglane then + self:E("ERROR: Incorrect request. No shipping lane has been defined between warehouses!") + valid=false + end end @@ -3597,14 +3482,17 @@ end --@return Wrapper.Airbase#AIRBASE.TerminalType Terminal type for this group. function WAREHOUSE:_GetTerminal(_attribute) + -- Default terminal is "large". local _terminal=AIRBASE.TerminalType.OpenBig - if _attribute==WAREHOUSE.Attribute.FIGHTER then + + + if _attribute==WAREHOUSE.Attribute.AIR_FIGHTER then -- Fighter ==> small. _terminal=AIRBASE.TerminalType.FighterAircraft - elseif _attribute==WAREHOUSE.Attribute.BOMBER or _attribute==WAREHOUSE.Attribute.TRANSPORT_PLANE or _attribute==WAREHOUSE.Attribute.TANKER or _attribute==WAREHOUSE.Attribute.AWACS then + elseif _attribute==WAREHOUSE.Attribute.AIR_BOMBER or _attribute==WAREHOUSE.Attribute.AIR_TRANSPORTPLANE or _attribute==WAREHOUSE.Attribute.AIR_TANKER or _attribute==WAREHOUSE.Attribute.AIR_AWACS then -- Bigger aircraft. _terminal=AIRBASE.TerminalType.OpenBig - elseif _attribute==WAREHOUSE.Attribute.TRANSPORT_HELO or _attribute==WAREHOUSE.Attribute.ATTACKHELICOPTER then + elseif _attribute==WAREHOUSE.Attribute.AIR_TRANSPORTHELO or _attribute==WAREHOUSE.Attribute.AIR_ATTACKHELO then -- Helicopter. _terminal=AIRBASE.TerminalType.HelicopterUsable end @@ -3963,6 +3851,7 @@ function WAREHOUSE:_HasAttribute(groupname, attribute) end --- Get the generalized attribute of a group. +-- Note that for a heterogenious group, the attribute is determined from the attribute of the first unit! -- @param #WAREHOUSE self -- @param #string groupname Name of the group. -- @return #WAREHOUSE.Attribute Generalized attribute of the group. @@ -3978,61 +3867,76 @@ function WAREHOUSE:_GetAttribute(groupname) -- TODO: need to work on ships and trucks and SAMs and ... -- Also the Yak-52 for example is OTHER since it only has the attribute "Battleplanes". - -- Airplanes + ----------- + --- Air --- + ----------- + -- Planes local transportplane=group:HasAttribute("Transports") and group:HasAttribute("Planes") - local fighter=group:HasAttribute("Fighters") or group:HasAttribute("Interceptors") or group:HasAttribute("Multirole fighters") - local tanker=group:HasAttribute("Tankers") local awacs=group:HasAttribute("AWACS") + local fighter=group:HasAttribute("Fighters") or group:HasAttribute("Interceptors") or group:HasAttribute("Multirole fighters") local bomber=group:HasAttribute("Bombers") - + local tanker=group:HasAttribute("Tankers") -- Helicopters local transporthelo=group:HasAttribute("Transport helicopters") local attackhelicopter=group:HasAttribute("Attack helicopters") - + + -------------- + --- Ground --- + -------------- -- Ground - local transportapc=group:HasAttribute("Infantry carriers") - local artillery=group:HasAttribute("Artillery") - local infantry=group:HasAttribute("Infantry") - local tank=group:HasAttribute("Old Tanks") or group:HasAttribute("Modern Tanks") + local apc=group:HasAttribute("Infantry carriers") local truck=group:HasAttribute("Trucks") and not group:GetCategory()==Group.Category.TRAIN - - -- Naval - local aircraftcarrier=group:HasAttribute("Aircraft Carriers") - local warship=group:HasAttribute("Armed ships") - local ship=group:HasAttribute("Ships") - + local infantry=group:HasAttribute("Infantry") + local artillery=group:HasAttribute("Artillery") + local tank=group:HasAttribute("Old Tanks") or group:HasAttribute("Modern Tanks") -- Train local train=group:GetCategory()==Group.Category.TRAIN + ------------- + --- Naval --- + ------------- + -- Ships + local aircraftcarrier=group:HasAttribute("Aircraft Carriers") + local warship=group:HasAttribute("Heavy armed ships") + local armedship=group:HasAttribute("Armed ships") + local unarmedship=group:HasAttribute("Unarmed ships") + + -- Define attribute. Order is important. if transportplane then - attribute=WAREHOUSE.Attribute.TRANSPORT_PLANE - elseif transporthelo then - attribute=WAREHOUSE.Attribute.TRANSPORT_HELO - elseif transportapc then - attribute=WAREHOUSE.Attribute.TRANSPORT_APC - elseif fighter then - attribute=WAREHOUSE.Attribute.FIGHTER - elseif tanker then - attribute=WAREHOUSE.Attribute.TANKER + attribute=WAREHOUSE.Attribute.AIR_TRANSPORTPLANE elseif awacs then - attribute=WAREHOUSE.Attribute.AWACS + attribute=WAREHOUSE.Attribute.AIR_AWACS + elseif fighter then + attribute=WAREHOUSE.Attribute.AIR_FIGHTER elseif bomber then - attribute=WAREHOUSE.Attribute.BOMBER - elseif artillery then - attribute=WAREHOUSE.Attribute.ARTILLERY - elseif infantry then - attribute=WAREHOUSE.Attribute.INFANTRY - elseif attackhelicopter then - attribute=WAREHOUSE.Attribute.ATTACKHELICOPTER - elseif tank then - attribute=WAREHOUSE.Attribute.TANK + attribute=WAREHOUSE.Attribute.AIR_BOMBER + elseif tanker then + attribute=WAREHOUSE.Attribute.AIR_TANKER + elseif transporthelo then + attribute=WAREHOUSE.Attribute.AIR_TRANSPORTHELO + elseif apc then + attribute=WAREHOUSE.Attribute.GROUND_APC elseif truck then - attribute=WAREHOUSE.Attribute.TRUCK + attribute=WAREHOUSE.Attribute.GROUND_TRUCK + elseif infantry then + attribute=WAREHOUSE.Attribute.GROUND_INFANTRY + elseif artillery then + attribute=WAREHOUSE.Attribute.GROUND_ARTILLERY + elseif tank then + attribute=WAREHOUSE.Attribute.GROUND_TANK elseif train then - attribute=WAREHOUSE.Attribute.TRAIN + attribute=WAREHOUSE.Attribute.GROUND_TRAIN + elseif aircraftcarrier then + attribute=WAREHOUSE.Attribute.NAVAL_AIRCRAFTCARRIER + elseif warship then + attribute=WAREHOUSE.Attribute.NAVAL_WARSHIP + elseif armedship then + attribute=WAREHOUSE.Attribute.NAVAL_ARMEDSHIP + elseif unarmedship then + attribute=WAREHOUSE.Attribute.NAVAL_UNARMEDSHIP else - attribute=WAREHOUSE.Attribute.OTHER + attribute=WAREHOUSE.Attribute.UNKNOWN end end