mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
- Fixed bug in parking spot distance for ships. - Added enroute anti-ship task for anti-ship missions.
This commit is contained in:
parent
f23416dfb8
commit
888734b7d1
@ -5282,6 +5282,10 @@ function AUFTRAG:GetDCSMissionTask()
|
|||||||
-- ANTISHIP Mission --
|
-- ANTISHIP Mission --
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
-- Add enroute anti-ship task.
|
||||||
|
local DCStask=CONTROLLABLE.EnRouteTaskAntiShip(nil)
|
||||||
|
table.insert(self.enrouteTasks, DCStask)
|
||||||
|
|
||||||
self:_GetDCSAttackTask(self.engageTarget, DCStasks)
|
self:_GetDCSAttackTask(self.engageTarget, DCStasks)
|
||||||
|
|
||||||
elseif self.type==AUFTRAG.Type.AWACS then
|
elseif self.type==AUFTRAG.Type.AWACS then
|
||||||
@ -5620,8 +5624,6 @@ function AUFTRAG:GetDCSMissionTask()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--table.insert(DCStasks, DCStask)
|
|
||||||
|
|
||||||
elseif self.type==AUFTRAG.Type.BARRAGE then
|
elseif self.type==AUFTRAG.Type.BARRAGE then
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
|||||||
@ -875,16 +875,14 @@ function FLIGHTGROUP:Status()
|
|||||||
if element.parking then
|
if element.parking then
|
||||||
|
|
||||||
-- Get distance to assigned parking spot.
|
-- Get distance to assigned parking spot.
|
||||||
local dist=element.unit:GetCoord():Get2DDistance(element.parking.Coordinate)
|
local dist=self:_GetDistToParking(element.parking, element.unit:GetCoord())
|
||||||
|
|
||||||
--env.info(string.format("FF dist to parking spot %d = %.1f meters", element.parking.TerminalID, dist))
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Distance to parking spot %d = %.1f meters", element.parking.TerminalID, dist))
|
||||||
|
|
||||||
-- If distance >10 meters, we consider the unit as taxiing.
|
-- If distance >10 meters, we consider the unit as taxiing. At least for fighters, the initial distance seems to be around 1.8 meters.
|
||||||
-- At least for fighters, the initial distance seems to be around 1.8 meters.
|
|
||||||
if dist>12 and element.engineOn then
|
if dist>12 and element.engineOn then
|
||||||
--if element.status==OPSGROUP.ElementStatus.ENGINEON then
|
|
||||||
self:ElementTaxiing(element)
|
self:ElementTaxiing(element)
|
||||||
--end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -4604,6 +4602,53 @@ function FLIGHTGROUP:_GetPlayerData()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get distance to parking spot. Takes extra care of ships.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot Spot Parking Spot.
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Reference coordinate.
|
||||||
|
-- @return #number Distance to parking spot in meters.
|
||||||
|
function FLIGHTGROUP:_GetDistToParking(Spot, Coordinate)
|
||||||
|
|
||||||
|
local dist=99999
|
||||||
|
|
||||||
|
if Spot then
|
||||||
|
|
||||||
|
-- Get the airbase this spot belongs to.
|
||||||
|
local airbase=AIRBASE:FindByName(Spot.AirbaseName)
|
||||||
|
|
||||||
|
|
||||||
|
if airbase:IsShip() then --or airbase:IsHelipad() then
|
||||||
|
|
||||||
|
-- Vec2 of airbase.
|
||||||
|
local a=airbase:GetVec2()
|
||||||
|
|
||||||
|
-- Vec2 of parking spot.
|
||||||
|
local b=Spot.Coordinate:GetVec2()
|
||||||
|
|
||||||
|
-- Vec2 of ref coordinate.
|
||||||
|
local c=Coordinate:GetVec2()
|
||||||
|
|
||||||
|
-- Vector from ref coord to airbase. This still needs to be rotated.
|
||||||
|
local t=UTILS.Vec2Substract(c,a)
|
||||||
|
|
||||||
|
-- Get the heading of the unit.
|
||||||
|
local unit=UNIT:FindByName(Spot.AirbaseName)
|
||||||
|
local hdg=unit:GetHeading()
|
||||||
|
|
||||||
|
-- Rotate the vector so that it corresponds to facing "North".
|
||||||
|
t=UTILS.Vec2Rotate2D(t, -hdg)
|
||||||
|
|
||||||
|
-- Distance from spot to ref coordinate.
|
||||||
|
dist=UTILS.VecDist2D(b,t)
|
||||||
|
else
|
||||||
|
-- Normal case.
|
||||||
|
dist=Coordinate:Get2DDistance(Spot.Coordinate)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -3756,6 +3756,7 @@ function OPSGROUP:AddTaskEnroute(task)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not gotit then
|
if not gotit then
|
||||||
|
self:T(self.lid..string.format("Adding enroute task"))
|
||||||
table.insert(self.taskenroute, task)
|
table.insert(self.taskenroute, task)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1105,6 +1105,7 @@ function AIRBASE:_InitParkingSpots()
|
|||||||
park.TerminalType=spot.Term_Type
|
park.TerminalType=spot.Term_Type
|
||||||
park.TOAC=spot.TO_AC
|
park.TOAC=spot.TO_AC
|
||||||
park.ClientSpot, park.ClientName=isClient(park.Coordinate)
|
park.ClientSpot, park.ClientName=isClient(park.Coordinate)
|
||||||
|
park.AirbaseName=self.AirbaseName
|
||||||
|
|
||||||
self.NparkingTotal=self.NparkingTotal+1
|
self.NparkingTotal=self.NparkingTotal+1
|
||||||
|
|
||||||
|
|||||||
@ -1557,6 +1557,27 @@ function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes,
|
|||||||
return DCSTask
|
return DCSTask
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (AIR) Enroute anti-ship task.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param DCS#AttributeNameArray TargetTypes Array of target categories allowed to engage. Default `{"Ships"}`.
|
||||||
|
-- @param #number Priority (Optional) All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. Default 0.
|
||||||
|
-- @return DCS#Task The DCS task structure.
|
||||||
|
function CONTROLLABLE:EnRouteTaskAntiShip(TargetTypes, Priority)
|
||||||
|
|
||||||
|
local DCSTask = {
|
||||||
|
id = 'EngageTargets',
|
||||||
|
key = "AntiShip",
|
||||||
|
--auto = false,
|
||||||
|
--enabled = true,
|
||||||
|
params = {
|
||||||
|
targetTypes = TargetTypes or {"Ships"},
|
||||||
|
priority = Priority or 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DCSTask
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- (AIR) Engaging a controllable. The task does not assign the target controllable to the unit/controllable to attack now; it just allows the unit/controllable to engage the target controllable as well as other assigned targets.
|
--- (AIR) Engaging a controllable. The task does not assign the target controllable to the unit/controllable to attack now; it just allows the unit/controllable to engage the target controllable as well as other assigned targets.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user