Warehouse v0.4.6

Little adjustments.
Controllable: Fixed bombing task.
This commit is contained in:
funkyfranky
2018-09-15 20:26:08 +02:00
parent d9bcb8b168
commit e16d6c0ca4
3 changed files with 48 additions and 19 deletions

View File

@@ -964,7 +964,7 @@ do -- COORDINATE
-- @param DCS#Speed Speed Airspeed in km/h. Default is 500 km/h. -- @param DCS#Speed Speed Airspeed in km/h. Default is 500 km/h.
-- @param #boolean SpeedLocked true means the speed is locked. -- @param #boolean SpeedLocked true means the speed is locked.
-- @param Wrapper.Airbase#AIRBASE airbase The airbase for takeoff and landing points. -- @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. -- @param #string description A text description of the waypoint, which will be shown on the F10 map.
-- @return #table The route point. -- @return #table The route point.
function COORDINATE:WaypointAir( AltType, Type, Action, Speed, SpeedLocked, airbase, DCSTasks, description ) function COORDINATE:WaypointAir( AltType, Type, Action, Speed, SpeedLocked, airbase, DCSTasks, description )
@@ -1028,7 +1028,7 @@ do -- COORDINATE
RoutePoint.task.params = {} RoutePoint.task.params = {}
RoutePoint.task.params.tasks = DCSTasks or {} RoutePoint.task.params.tasks = DCSTasks or {}
self:E({RoutePoint=RoutePoint}) self:T({RoutePoint=RoutePoint})
return RoutePoint return RoutePoint
end end
@@ -1037,9 +1037,11 @@ do -- COORDINATE
-- @param #COORDINATE self -- @param #COORDINATE self
-- @param #COORDINATE.WaypointAltType AltType The altitude type. -- @param #COORDINATE.WaypointAltType AltType The altitude type.
-- @param DCS#Speed Speed Airspeed in km/h. -- @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. -- @return #table The route point.
function COORDINATE:WaypointAirTurningPoint( AltType, Speed ) function COORDINATE:WaypointAirTurningPoint( AltType, Speed, DCSTasks, description )
return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed ) return self:WaypointAir( AltType, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, Speed, true, nil, DCSTasks, description )
end end

View File

@@ -985,7 +985,7 @@ WAREHOUSE.db = {
--- Warehouse class version. --- Warehouse class version.
-- @field #string version -- @field #string version
WAREHOUSE.version="0.4.5" WAREHOUSE.version="0.4.6"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Warehouse todo list. -- TODO: Warehouse todo list.
@@ -5415,7 +5415,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
-- Function calculating the overlap of two (square) objects. -- Function calculating the overlap of two (square) objects.
local function _overlap(l1,l2,dist) 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) local safe = (dist > safedist)
self:T3(string.format("l1=%.1f l2=%.1f s=%.1f d=%.1f ==> safe=%s", l1,l2,safedist,dist,tostring(safe))) self:T3(string.format("l1=%.1f l2=%.1f s=%.1f d=%.1f ==> safe=%s", l1,l2,safedist,dist,tostring(safe)))
return 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)) 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. -- 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"}) table.insert(obstacles, {coord=_spot, size=_asset.size, name=_asset.templatename, type="asset"})
gotit=true gotit=true

View File

@@ -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 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 Altitude (optional) The altitude from where to attack.
-- @param #number WeaponType (optional) The WeaponType. -- @param #number WeaponType (optional) The WeaponType.
-- @param #boolean Divebomb (optional) Perform dive bombing. Default false.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType ) function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb )
self:F2( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType } ) 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 local DCSTask
DCSTask = { DCSTask = {
id = 'Bombing', id = 'Bombing',
params = { params = {
point = Vec2, x = Vec2.x,
groupAttack = GroupAttack or false, y = Vec2.y,
groupAttack = _groupattack,
expend = WeaponExpend or "Auto", expend = WeaponExpend or "Auto",
attackQtyLimit = AttackQty and true or false, attackQtyLimit = false, --AttackQty and true or false,
attackQty = AttackQty, attackQty = AttackQty or 1,
directionEnabled = Direction and true or false, directionEnabled = _directionenabled,
direction = Direction, direction = _direction,
altitudeEnabled = Altitude and true or false, altitudeEnabled = _altitudeenabled,
altitude = Altitude or 30, altitude = _altitude,
weaponType = WeaponType, weaponType = WeaponType,
--attackType=_attacktype,
}, },
}, }
self:T3( { DCSTask } ) self:E( { TaskBombing=DCSTask } )
return DCSTask return DCSTask
end end