From e16d6c0ca44ce74a07a0e2d62a5ba5612bdf3bc3 Mon Sep 17 00:00:00 2001 From: funkyfranky Date: Sat, 15 Sep 2018 20:26:08 +0200 Subject: [PATCH] Warehouse v0.4.6 Little adjustments. Controllable: Fixed bombing task. --- Moose Development/Moose/Core/Point.lua | 10 ++-- .../Moose/Functional/Warehouse.lua | 5 +- .../Moose/Wrapper/Controllable.lua | 52 ++++++++++++++----- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index c899a48c6..b5d173644 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -964,7 +964,7 @@ do -- COORDINATE -- @param DCS#Speed Speed Airspeed in km/h. Default is 500 km/h. -- @param #boolean SpeedLocked true means the speed is locked. -- @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 #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. function COORDINATE:WaypointAir( AltType, Type, Action, Speed, SpeedLocked, airbase, DCSTasks, description ) @@ -1028,7 +1028,7 @@ do -- COORDINATE RoutePoint.task.params = {} RoutePoint.task.params.tasks = DCSTasks or {} - self:E({RoutePoint=RoutePoint}) + self:T({RoutePoint=RoutePoint}) return RoutePoint end @@ -1037,9 +1037,11 @@ do -- COORDINATE -- @param #COORDINATE self -- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param DCS#Speed Speed Airspeed in km/h. + -- @param #table DCSTasks (Optional) A table of @{DCS#Task} items which are executed at the waypoint. + -- @param #string description (Optional) A text description of the waypoint, which will be shown on the F10 map. -- @return #table The route point. - function COORDINATE:WaypointAirTurningPoint( AltType, Speed ) - return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed ) + function COORDINATE:WaypointAirTurningPoint( AltType, Speed, DCSTasks, description ) + return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed, true, nil, DCSTasks, description ) end diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index eaa7e9ff9..73ba2f6c6 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -985,7 +985,7 @@ WAREHOUSE.db = { --- Warehouse class version. -- @field #string version -WAREHOUSE.version="0.4.5" +WAREHOUSE.version="0.4.6" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO: Warehouse todo list. @@ -5415,7 +5415,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets) -- Function calculating the overlap of two (square) objects. local function _overlap(l1,l2,dist) - local safedist=(l1/2+l2/2)*1.1 -- 10% safety margine added to safe distance! + local safedist=(l1/2+l2/2)*1.05 -- 5% safety margine added to safe distance! local safe = (dist > safedist) self:T3(string.format("l1=%.1f l2=%.1f s=%.1f d=%.1f ==> safe=%s", l1,l2,safedist,dist,tostring(safe))) return safe @@ -5543,7 +5543,6 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets) self:T(self.wid..string.format("Parking spot #%d is free for asset id=%d!", _termid, _asset.uid)) -- Add the unit as obstacle so that this spot will not be available for the next unit. - -- TODO Alternatively, I could remove this parking spot from the table, right? table.insert(obstacles, {coord=_spot, size=_asset.size, name=_asset.templatename, type="asset"}) gotit=true diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 92aed3843..256294fac 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -726,28 +726,56 @@ end -- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction. -- @param #number Altitude (optional) The altitude from where to attack. -- @param #number WeaponType (optional) The WeaponType. +-- @param #boolean Divebomb (optional) Perform dive bombing. Default false. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType ) - self:F2( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType } ) +function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb ) + self:E( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb } ) + + local _groupattack=false + if GroupAttack then + _groupattack=GroupAttack + end + + local _direction=0 + local _directionenabled=false + if Direction then + _direction=math.rad(Direction) + _directionenabled=true + end + + local _altitude=5000 + local _altitudeenabled=false + if Altitude then + _altitude=Altitude + _altitudeenabled=true + end + + local _attacktype=nil + if Divebomb then + _attacktype="Dive" + end + local DCSTask DCSTask = { id = 'Bombing', params = { - point = Vec2, - groupAttack = GroupAttack or false, + x = Vec2.x, + y = Vec2.y, + groupAttack = _groupattack, expend = WeaponExpend or "Auto", - attackQtyLimit = AttackQty and true or false, - attackQty = AttackQty, - directionEnabled = Direction and true or false, - direction = Direction, - altitudeEnabled = Altitude and true or false, - altitude = Altitude or 30, + attackQtyLimit = false, --AttackQty and true or false, + attackQty = AttackQty or 1, + directionEnabled = _directionenabled, + direction = _direction, + altitudeEnabled = _altitudeenabled, + altitude = _altitude, weaponType = WeaponType, + --attackType=_attacktype, }, - }, + } - self:T3( { DCSTask } ) + self:E( { TaskBombing=DCSTask } ) return DCSTask end