From 1a4baeafb691ed36f90356ac46da8108b70ce74c Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 28 Oct 2018 13:15:38 +0100 Subject: [PATCH] Warehose v0.6.6 WAREHOUSE: - Improved parking spot check for airbase ship. AI_FORMATION: - Added Stop option CT: - fixes COORDINATE: - Improved landing waypoint. --- Moose Development/Moose/AI/AI_Formation.lua | 12 ++++- Moose Development/Moose/Core/Point.lua | 7 ++- .../Moose/Functional/CarrierTrainer.lua | 51 +++++++++++-------- .../Moose/Functional/Warehouse.lua | 35 ++++++++----- .../Moose/Wrapper/Controllable.lua | 6 +-- 5 files changed, 71 insertions(+), 40 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Formation.lua b/Moose Development/Moose/AI/AI_Formation.lua index cab3c528a..b086e7b70 100644 --- a/Moose Development/Moose/AI/AI_Formation.lua +++ b/Moose Development/Moose/AI/AI_Formation.lua @@ -911,7 +911,17 @@ end -- @param #string From From state. -- @param #string Event Event. -- @pram #string To The to state. -function AI_FORMATION:onbeforeFollowing( FollowGroupSet, From, Event, To ) --R2.1 +function AI_FORMATION:onafterStop(FollowGroupSet, From, Event, To) --R2.1 + self:E("Stopping formation.") +end + +--- Follow event fuction. Check if coming from state "stopped". If so the transition is rejected. +-- @param #AI_FORMATION self +-- @param Core.Set#SET_GROUP FollowGroupSet The following set of groups. +-- @param #string From From state. +-- @param #string Event Event. +-- @pram #string To The to state. +function AI_FORMATION:onbeforeFollow( FollowGroupSet, From, Event, To ) --R2.1 if From=="Stopped" then return false -- Deny transition. end diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 528ac9a84..862dc3839 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -1121,6 +1121,9 @@ do -- COORDINATE --- Build a Waypoint Air "Landing". -- @param #COORDINATE self -- @param DCS#Speed Speed Airspeed in km/h. + -- @param Wrapper.Airbase#AIRBASE airbase The airbase for takeoff and landing points. + -- @param #table DCSTasks A table of @{DCS#Task} items which are executed at the waypoint. + -- @param #string description A text description of the waypoint, which will be shown on the F10 map. -- @return #table The route point. -- @usage -- @@ -1129,8 +1132,8 @@ do -- COORDINATE -- LandingWaypoint = LandingCoord:WaypointAirLanding( 60 ) -- HeliGroup:Route( { LandWaypoint }, 1 ) -- Start landing the helicopter in one second. -- - function COORDINATE:WaypointAirLanding( Speed ) - return self:WaypointAir( nil, COORDINATE.WaypointType.Land, COORDINATE.WaypointAction.Landing, Speed ) + function COORDINATE:WaypointAirLanding( Speed, airbase, DCSTasks, description ) + return self:WaypointAir( nil, COORDINATE.WaypointType.Land, COORDINATE.WaypointAction.Landing, Speed, airbase, DCSTasks, description ) end diff --git a/Moose Development/Moose/Functional/CarrierTrainer.lua b/Moose Development/Moose/Functional/CarrierTrainer.lua index 4e00ea75d..c3f4f68e0 100644 --- a/Moose Development/Moose/Functional/CarrierTrainer.lua +++ b/Moose Development/Moose/Functional/CarrierTrainer.lua @@ -153,7 +153,7 @@ CARRIERTRAINER.MenuF10={} --- Carrier trainer class version. -- @field #string version -CARRIERTRAINER.version="0.1.1w" +CARRIERTRAINER.version="0.1.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -407,6 +407,7 @@ function CARRIERTRAINER:_InitNewRound(playerData) playerData.step=0 playerData.score=100 playerData.grade={} + playerData.debrief={} playerData.summary = "Debriefing:\n" playerData.longDownwindDone = false playerData.boltered=false @@ -423,7 +424,7 @@ end -- @param #string item Text item appeded to the debrief. function CARRIERTRAINER:_AddToSummary(playerData, step, item) --playerData.summary = playerData.summary .. item .. "\n" - table.inser(playerData.debrief, {step=step, hint=item}) + table.insert(playerData.debrief, {step=step, hint=item}) end --- Append text to result text. @@ -671,7 +672,7 @@ function CARRIERTRAINER:_AbortPattern(playerData, X, Z, posData) self:E(self.lid..text) --MESSAGE:New(text, 60):ToAllIf(self.Debug) - self:_AddToSummary(playerData, "Approach aborted.") + self:_AddToSummary(playerData, "Abort", "Approach aborted.") self:_PrintFinalScore(playerData, 30, -2) @@ -805,8 +806,8 @@ function CARRIERTRAINER:_InitStennis() self.Wake.Zmax=nil self.Wake.LimitXmin=nil self.Wake.LimitXmax=nil - self.Wake.LimitZmin=nil - self.Wake.LimitZmax=0 + self.Wake.LimitZmin=0 + self.Wake.LimitZmax=nil self.Wake.Altitude=UTILS.FeetToMeters(370) self.Wake.AoA=8.1 self.Wake.Distance=nil @@ -927,7 +928,7 @@ function CARRIERTRAINER:_Upwind(playerData) self:_SendMessageToPlayer(hint, 8, playerData) -- Debrief. - self:_AddToSummary(playerData, hint) + self:_AddToSummary(playerData, "Entering the Break", hint) -- Next step. playerData.step=3 @@ -968,8 +969,12 @@ function CARRIERTRAINER:_Break(playerData, part) -- Send message to player. self:_SendMessageToPlayer(hint, 10, playerData) - -- Debrif - self:_AddToSummary(playerData, hint) + -- Debrief + if part =="late" then + self:_AddToSummary(playerData, "Late Break", hint) + else + self:_AddToSummary(playerData, "Early Entry", hint) + end -- Nest step: late break or abeam. if (part == "early") then @@ -1003,7 +1008,7 @@ function CARRIERTRAINER:_CheckForLongDownwind(playerData) self:_SendMessageToPlayer(hint, 10, playerData) -- Debrief. - self:_AddToSummary(playerData, hint) + self:_AddToSummary(playerData, "Long Downwind Leg", hint) -- Decrease score. playerData.score=playerData.score-40 @@ -1058,7 +1063,7 @@ function CARRIERTRAINER:_Abeam(playerData) self:_SendMessageToPlayer(hintFull, 10, playerData) -- Add to debrief. - self:_AddToSummary(playerData, "Abeam", hintFull) + self:_AddToSummary(playerData, "Abeam Position", hintFull) -- Proceed to next step. playerData.step = 6 @@ -1101,7 +1106,7 @@ function CARRIERTRAINER:_Ninety(playerData) self:_SendMessageToPlayer(hintFull, 10, playerData) -- Add to debrief. - self:_AddToSummary(playerData, "At the 90:", hintFull) + self:_AddToSummary(playerData, "At the 90", hintFull) -- Long downwind not an issue any more playerData.longDownwindDone = true @@ -1144,7 +1149,7 @@ function CARRIERTRAINER:_Wake(playerData) self:_SendMessageToPlayer(hintFull, 10, playerData) -- Add to debrief. - self:_AddToSummary(playerData, "At the wake:", hintFull) + self:_AddToSummary(playerData, "At the Wake", hintFull) -- Next step: Groove. playerData.step = 8 @@ -1195,7 +1200,7 @@ function CARRIERTRAINER:_Groove(playerData) self:_SendMessageToPlayer(hintFull, 10, playerData) -- Add to debrief. - self:_AddToSummary(playerData, "Entering the Groove:", hintFull) + self:_AddToSummary(playerData, "Entering the Groove", hintFull) -- Next step. playerData.step = 9 @@ -1235,7 +1240,10 @@ function CARRIERTRAINER:_CallTheBall(playerData) local glideslopeError = math.deg(glideslope) - 3.5 if diffX>-UTILS.NMToMeters(0.75) and diffX<-100 and playerData.calledball==false then - + self:_SendMessageToPlayer("Call the ball.", 8, playerData) + playerData.calledball=true + return + end -- Check if we are beween 3/4 NM and end of ship. if diffX>-UTILS.NMToMeters(0.75) and diffX<-100 then @@ -1296,7 +1304,7 @@ function CARRIERTRAINER:_CallTheBall(playerData) self:_SendMessageToPlayer( hint, 8, playerData ) self:_PrintScore(score, playerData, true) - self:_AddToSummary(playerData, hint) + self:_AddToSummary(playerData, "Calling the Ball", hint) self:_PrintFinalScore(playerData, 60, wire) self:_HandleCollectedResult(playerData, wire) @@ -1348,7 +1356,7 @@ function CARRIERTRAINER:_Trapped(playerData, pos) local fullHint = string.format("Trapped catching the %d-wire.", wire) - self:_AddToSummary(playerData, fullHint) + self:_AddToSummary(playerData, "Trapped", fullHint) else --Boltered! @@ -1766,16 +1774,19 @@ function CARRIERTRAINER:_HandleCollectedResult(playerData, wire) playerData.totalscore = playerData.totalscore + playerData.score playerData.passes = playerData.passes + 1 + --TODO: collect results + --[[ if playerData.collectedResultString == "" then playerData.collectedResultString = newString else playerData.collectedResultString = playerData.collectedResultString .. ", " .. newString MessageToAll( playerData.callsign .. "'s " .. playerData.passes .. " passes: " .. playerData.collectedResultString .. " (TOTAL: " .. playerData.totalscore .. ")" , 30, "CollectedResult" ) end - - local heading=playerData.unit:GetCoordinate():HeadingTo(self.startZone:GetCoordinate()) - local distance=playerData.unit:GetCoordinate():Get2DDistance(self.startZone:GetCoordinate()) - local text=string.format("%s, fly heading %d for %d nm to restart the pattern.", playerData.callsign, heading, UTILS.MetersToNM(distance)) + ]] + + local heading=playerData.unit:GetCoordinate():HeadingTo(self.registerZone:GetCoordinate()) + local distance=playerData.unit:GetCoordinate():Get2DDistance(self.registerZone:GetCoordinate()) + local text=string.format("%s, fly heading %d for %d NM to restart the pattern.", playerData.callsign, heading, UTILS.MetersToNM(distance)) --"Return south 4 nm (over the trailing ship), towards WP 1, to restart the pattern." self:_SendMessageToPlayer(text, 30, playerData) end diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index bc1e840ae..2802ecc52 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -1729,7 +1729,7 @@ WAREHOUSE.db = { --- Warehouse class version. -- @field #string version -WAREHOUSE.version="0.6.5" +WAREHOUSE.version="0.6.6" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO: Warehouse todo list. @@ -6318,25 +6318,26 @@ function WAREHOUSE:_CheckRequestValid(request) -- TODO: maybe only check if spots > 0 for the necessary terminal type? At least for FARPS. -- Get necessary terminal type. - local termtype=self:_GetTerminal(asset.attribute) + local termtype_dep=self:_GetTerminal(asset.attribute, self:GetAirbaseCategory()) + local termtype_des=self:_GetTerminal(asset.attribute, request.warehouse:GetAirbaseCategory()) -- Get number of parking spots. - local np_departure=self.airbase:GetParkingSpotsNumber(termtype) - local np_destination=request.airbase:GetParkingSpotsNumber(termtype) + local np_departure=self.airbase:GetParkingSpotsNumber(termtype_dep) + local np_destination=request.airbase:GetParkingSpotsNumber(termtype_des) -- Debug info. - self:T(string.format("Asset attribute = %s, terminal type = %d, spots at departure = %d, destination = %d", asset.attribute, termtype, np_departure, np_destination)) + self:T(string.format("Asset attribute = %s, DEPARTURE: terminal type = %d, spots = %d, DESTINATION: terminal type = %d, spots = %d", asset.attribute, termtype_dep, np_departure, termtype_des, np_destination)) -- Not enough parking at sending warehouse. --if (np_departure < request.nasset) and not (self.category==Airbase.Category.SHIP or self.category==Airbase.Category.HELIPAD) then if np_departure < nasset then - self:E(string.format("ERROR: Incorrect request. Not enough parking spots of terminal type %d at warehouse. Available spots %d < %d necessary.", termtype, np_departure, nasset)) + self:E(string.format("ERROR: Incorrect request. Not enough parking spots of terminal type %d at warehouse. Available spots %d < %d necessary.", termtype_dep, np_departure, nasset)) valid=false end -- No parking at requesting warehouse. if np_destination == 0 then - self:E(string.format("ERROR: Incorrect request. No parking spots of terminal type %d at requesting warehouse. Available spots = %d!", termtype, np_destination)) + self:E(string.format("ERROR: Incorrect request. No parking spots of terminal type %d at requesting warehouse. Available spots = %d!", termtype_des, np_destination)) valid=false end @@ -6474,7 +6475,7 @@ function WAREHOUSE:_CheckRequestValid(request) self:T(text) -- Get necessary terminal type for helos or transport aircraft. - local termtype=self:_GetTerminal(request.transporttype) + local termtype=self:_GetTerminal(request.transporttype, self:GetAirbaseCategory()) -- Get number of parking spots. local np_departure=self.airbase:GetParkingSpotsNumber(termtype) @@ -6493,6 +6494,7 @@ function WAREHOUSE:_CheckRequestValid(request) if request.transporttype==WAREHOUSE.TransportType.AIRPLANE then -- Total number of parking spots for transport planes at destination. + termtype=self:_GetTerminal(request.transporttype, request.warehouse:GetAirbaseCategory()) local np_destination=request.airbase:GetParkingSpotsNumber(termtype) -- Debug info. @@ -6934,13 +6936,13 @@ end --- Get the proper terminal type based on generalized attribute of the group. --@param #WAREHOUSE self --@param #WAREHOUSE.Attribute _attribute Generlized attibute of unit. +--@param #number _category Airbase category. --@return Wrapper.Airbase#AIRBASE.TerminalType Terminal type for this group. -function WAREHOUSE:_GetTerminal(_attribute) +function WAREHOUSE:_GetTerminal(_attribute, _category) -- Default terminal is "large". local _terminal=AIRBASE.TerminalType.OpenBig - - + if _attribute==WAREHOUSE.Attribute.AIR_FIGHTER then -- Fighter ==> small. _terminal=AIRBASE.TerminalType.FighterAircraft @@ -6950,6 +6952,15 @@ function WAREHOUSE:_GetTerminal(_attribute) elseif _attribute==WAREHOUSE.Attribute.AIR_TRANSPORTHELO or _attribute==WAREHOUSE.Attribute.AIR_ATTACKHELO then -- Helicopter. _terminal=AIRBASE.TerminalType.HelicopterUsable + else + --_terminal=AIRBASE.TerminalType.OpenMedOrBig + end + + -- For ships, we allow medium spots for all fixed wing aircraft. There are smaller tankers and AWACS aircraft that can use a carrier. + if _category==Airbase.Category.SHIP then + if not (_attribute==WAREHOUSE.Attribute.AIR_TRANSPORTHELO or _attribute==WAREHOUSE.Attribute.AIR_ATTACKHELO) then + _terminal=AIRBASE.TerminalType.OpenMedOrBig + end end return _terminal @@ -7034,7 +7045,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets) local _asset=asset --#WAREHOUSE.Assetitem -- Get terminal type of this asset - local terminaltype=self:_GetTerminal(asset.attribute) + local terminaltype=self:_GetTerminal(asset.attribute, self:GetAirbaseCategory()) -- Asset specific parking. parking[_asset.uid]={} diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index ede63f9e5..d57f7fac4 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -990,11 +990,7 @@ function CONTROLLABLE:TaskRefueling() -- params = {} -- } - local DCSTask - DCSTask = { id = 'Refueling', - params = { - }, - }, + local DCSTask={id='Refueling', params={}} self:T3( { DCSTask } ) return DCSTask