mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1249 from FlightControl-Master/FF/Develop
Ff/develop
This commit is contained in:
@@ -119,7 +119,7 @@ function AI_A2A_CAP:New2( AICap, EngageMinSpeed, EngageMaxSpeed, EngageFloorAlti
|
|||||||
local AI_Air = AI_AIR:New( AICap )
|
local AI_Air = AI_AIR:New( AICap )
|
||||||
local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AICap, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) -- #AI_AIR_PATROL
|
local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AICap, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) -- #AI_AIR_PATROL
|
||||||
local AI_Air_Engage = AI_AIR_ENGAGE:New( AI_Air_Patrol, AICap, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType )
|
local AI_Air_Engage = AI_AIR_ENGAGE:New( AI_Air_Patrol, AICap, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType )
|
||||||
local self = BASE:Inherit( self, AI_Air_Engage )
|
local self = BASE:Inherit( self, AI_Air_Engage ) --#AI_A2A_CAP
|
||||||
|
|
||||||
self:SetFuelThreshold( .2, 60 )
|
self:SetFuelThreshold( .2, 60 )
|
||||||
self:SetDamageThreshold( 0.4 )
|
self:SetDamageThreshold( 0.4 )
|
||||||
|
|||||||
@@ -707,13 +707,14 @@ end
|
|||||||
function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
||||||
self:F( { AIGroup, From, Event, To } )
|
self:F( { AIGroup, From, Event, To } )
|
||||||
|
|
||||||
|
|
||||||
if AIGroup and AIGroup:IsAlive() then
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
|
|
||||||
|
-- Get tanker group.
|
||||||
local Tanker = GROUP:FindByName( self.TankerName )
|
local Tanker = GROUP:FindByName( self.TankerName )
|
||||||
|
|
||||||
if Tanker:IsAlive() and Tanker:IsAirPlane() then
|
if Tanker and Tanker:IsAlive() and Tanker:IsAirPlane() then
|
||||||
|
|
||||||
self:I( "Group " .. self.Controllable:GetName() .. " ... Refuelling! ( " .. self:GetState() .. "), at tanker " .. self.TankerName )
|
self:I( "Group " .. self.Controllable:GetName() .. " ... Refuelling! State=" .. self:GetState() .. ", Refuelling tanker " .. self.TankerName )
|
||||||
|
|
||||||
local RefuelRoute = {}
|
local RefuelRoute = {}
|
||||||
|
|
||||||
@@ -724,40 +725,43 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To )
|
|||||||
local ToRefuelSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed )
|
local ToRefuelSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed )
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local FromRefuelRoutePoint = FromRefuelCoord:WaypointAir(
|
local FromRefuelRoutePoint = FromRefuelCoord:WaypointAir(self.PatrolAltType, POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, ToRefuelSpeed, true)
|
||||||
self.PatrolAltType,
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
ToRefuelSpeed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air. NOT used!
|
||||||
local ToRefuelRoutePoint = FromRefuelCoord:WaypointAir(
|
local ToRefuelRoutePoint = Tanker:GetCoordinate():WaypointAir(self.PatrolAltType, POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, ToRefuelSpeed, true)
|
||||||
self.PatrolAltType,
|
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
|
||||||
ToRefuelSpeed,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
self:F( { ToRefuelSpeed = ToRefuelSpeed } )
|
self:F( { ToRefuelSpeed = ToRefuelSpeed } )
|
||||||
|
|
||||||
RefuelRoute[#RefuelRoute+1] = FromRefuelRoutePoint
|
RefuelRoute[#RefuelRoute+1] = FromRefuelRoutePoint
|
||||||
--RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint
|
RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint
|
||||||
|
|
||||||
AIGroup:OptionROEHoldFire()
|
AIGroup:OptionROEHoldFire()
|
||||||
AIGroup:OptionROTEvadeFire()
|
AIGroup:OptionROTEvadeFire()
|
||||||
|
|
||||||
|
-- Get Class name for .Resume function
|
||||||
|
local classname=self:GetClassName()
|
||||||
|
|
||||||
|
-- AI_A2A_CAP can call this function but does not have a .Resume function. Try to fix.
|
||||||
|
if classname=="AI_A2A_CAP" then
|
||||||
|
classname="AI_AIR_PATROL"
|
||||||
|
end
|
||||||
|
|
||||||
|
env.info("FF refueling classname="..classname)
|
||||||
|
|
||||||
local Tasks = {}
|
local Tasks = {}
|
||||||
Tasks[#Tasks+1] = AIGroup:TaskRefueling()
|
Tasks[#Tasks+1] = AIGroup:TaskRefueling()
|
||||||
Tasks[#Tasks+1] = AIGroup:TaskFunction( self:GetClassName() .. ".Resume", self )
|
Tasks[#Tasks+1] = AIGroup:TaskFunction( classname .. ".Resume", self )
|
||||||
RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks )
|
RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks )
|
||||||
|
|
||||||
AIGroup:Route( RefuelRoute, self.TaskDelay )
|
AIGroup:Route( RefuelRoute, self.TaskDelay )
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
-- No tanker defined ==> RTB!
|
||||||
self:RTB()
|
self:RTB()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -356,7 +356,6 @@ function AI_AIR_PATROL:onafterPatrolRoute( AIPatrol, From, Event, To )
|
|||||||
local taskOrbit=AIPatrol:TaskOrbit(c1, altitude, UTILS.KmphToMps(speedkmh), c2)
|
local taskOrbit=AIPatrol:TaskOrbit(c1, altitude, UTILS.KmphToMps(speedkmh), c2)
|
||||||
|
|
||||||
-- Task function to redo the patrol at other random position.
|
-- Task function to redo the patrol at other random position.
|
||||||
--local taskPatrol=AIPatrol:TaskFunction("AI_A2A_PATROL.PatrolRoute", self)
|
|
||||||
local taskPatrol=AIPatrol:TaskFunction("AI_AIR_PATROL.___PatrolRoute", self)
|
local taskPatrol=AIPatrol:TaskFunction("AI_AIR_PATROL.___PatrolRoute", self)
|
||||||
|
|
||||||
-- Controlled task with task condition.
|
-- Controlled task with task condition.
|
||||||
|
|||||||
@@ -298,7 +298,8 @@ end
|
|||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @param #BASE self
|
-- @param #BASE self
|
||||||
-- @param #BASE Child is the Child class from which the Parent class needs to be retrieved.
|
-- @param #BASE Child This is the Child class from which the Parent class needs to be retrieved.
|
||||||
|
-- @param #BASE FromClass (Optional) The class from which to get the parent.
|
||||||
-- @return #BASE
|
-- @return #BASE
|
||||||
function BASE:GetParent( Child, FromClass )
|
function BASE:GetParent( Child, FromClass )
|
||||||
|
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
|
|||||||
Schedule.ScheduleID = nil
|
Schedule.ScheduleID = nil
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(string.format("Error no ScheduleID for CallID=%s", tostring(CallID)))
|
self:T(string.format("Error no ScheduleID for CallID=%s", tostring(CallID)))
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -693,7 +693,7 @@ ARTY.db={
|
|||||||
|
|
||||||
--- Arty script version.
|
--- Arty script version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ARTY.version="1.1.6"
|
ARTY.version="1.1.7"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -3848,26 +3848,23 @@ end
|
|||||||
-- @param #boolean final True if it is the final waypoint.
|
-- @param #boolean final True if it is the final waypoint.
|
||||||
function ARTY._PassingWaypoint(group, arty, i, final)
|
function ARTY._PassingWaypoint(group, arty, i, final)
|
||||||
|
|
||||||
-- Debug message.
|
if group and group:IsAlive() then
|
||||||
local text=string.format("%s, passing waypoint %d.", group:GetName(), i)
|
|
||||||
if final then
|
local groupname=tostring(group:GetName())
|
||||||
text=string.format("%s, arrived at destination.", group:GetName())
|
|
||||||
end
|
|
||||||
arty:T(self.lid..text)
|
|
||||||
|
|
||||||
--[[
|
-- Debug message.
|
||||||
if final then
|
local text=string.format("%s, passing waypoint %d.", groupname, i)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(group:GetCoalition(), arty.Debug or arty.report)
|
if final then
|
||||||
else
|
text=string.format("%s, arrived at destination.", groupname)
|
||||||
MESSAGE:New(text, 10):ToAllIf(arty.Debug)
|
end
|
||||||
|
arty:T(arty.lid..text)
|
||||||
|
|
||||||
|
-- Arrived event.
|
||||||
|
if final and arty.groupname==groupname then
|
||||||
|
arty:Arrived()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
|
|
||||||
-- Arrived event.
|
|
||||||
if final and arty.groupname==group:GetName() then
|
|
||||||
arty:Arrived()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Relocate to another position, e.g. after an engagement to avoid couter strikes.
|
--- Relocate to another position, e.g. after an engagement to avoid couter strikes.
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ SUPPRESSION.MenuF10=nil
|
|||||||
|
|
||||||
--- PSEUDOATC version.
|
--- PSEUDOATC version.
|
||||||
-- @field #number version
|
-- @field #number version
|
||||||
SUPPRESSION.version="0.9.1"
|
SUPPRESSION.version="0.9.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -363,6 +363,7 @@ function SUPPRESSION:New(group)
|
|||||||
self:AddTransition("FallingBack", "FightBack", "CombatReady")
|
self:AddTransition("FallingBack", "FightBack", "CombatReady")
|
||||||
self:AddTransition("Retreating", "Retreated", "Retreated")
|
self:AddTransition("Retreating", "Retreated", "Retreated")
|
||||||
self:AddTransition("*", "Dead", "*")
|
self:AddTransition("*", "Dead", "*")
|
||||||
|
self:AddTransition("*", "Stop", "Stopped")
|
||||||
|
|
||||||
self:AddTransition("TakingCover", "Hit", "TakingCover")
|
self:AddTransition("TakingCover", "Hit", "TakingCover")
|
||||||
self:AddTransition("FallingBack", "Hit", "FallingBack")
|
self:AddTransition("FallingBack", "Hit", "FallingBack")
|
||||||
@@ -874,28 +875,14 @@ function SUPPRESSION:StatusReport(message)
|
|||||||
local roe=self.CurrentROE
|
local roe=self.CurrentROE
|
||||||
local state=self.CurrentAlarmState
|
local state=self.CurrentAlarmState
|
||||||
local life_min, life_max, life_ave, life_ave0, groupstrength=self:_GetLife()
|
local life_min, life_max, life_ave, life_ave0, groupstrength=self:_GetLife()
|
||||||
local ammotot=self.Controllable:GetAmmunition()
|
local ammotot=group:GetAmmunition()
|
||||||
|
|
||||||
--[[
|
|
||||||
local text=string.format("Status of group %s\n", name)
|
local text=string.format("State %s, Units=%d/%d, ROE=%s, AlarmState=%s, Hits=%d, Life(min/max/ave/ave0)=%d/%d/%d/%d, Total Ammo=%d",
|
||||||
text=text..string.format("Number of units: %d of %d\n", nunits, self.IniGroupStrength)
|
|
||||||
text=text..string.format("Current state: %s\n", self:GetState())
|
|
||||||
text=text..string.format("ROE: %s\n", roe)
|
|
||||||
text=text..string.format("Alarm state: %s\n", state)
|
|
||||||
text=text..string.format("Hits taken: %d\n", self.Nhit)
|
|
||||||
text=text..string.format("Life min: %3.0f\n", life_min)
|
|
||||||
text=text..string.format("Life max: %3.0f\n", life_max)
|
|
||||||
text=text..string.format("Life ave: %3.0f\n", life_ave)
|
|
||||||
text=text..string.format("Life ave0: %3.0f\n", life_ave0)
|
|
||||||
text=text..string.format("Ammo tot: %d\n", at)
|
|
||||||
text=text..string.format("Group strength: %3.0f", groupstrength)
|
|
||||||
]]
|
|
||||||
|
|
||||||
local text=string.format("State %s, Units=%d/%d, ROE=%s Alarm State=%s, Hits=%d, Life=%d/%d/%d/%d, Ammo=%d",
|
|
||||||
self:GetState(), nunits, self.IniGroupStrength, self.CurrentROE, self.CurrentAlarmState, self.Nhit, life_min, life_max, life_ave, life_ave0, ammotot)
|
self:GetState(), nunits, self.IniGroupStrength, self.CurrentROE, self.CurrentAlarmState, self.Nhit, life_min, life_max, life_ave, life_ave0, ammotot)
|
||||||
|
|
||||||
MESSAGE:New(text, 10):ToAllIf(message or self.Debug)
|
MESSAGE:New(text, 10):ToAllIf(message or self.Debug)
|
||||||
self:I(self.lid.."\n"..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -983,7 +970,6 @@ function SUPPRESSION:onafterStart(Controllable, From, Event, To)
|
|||||||
world.addEventHandler(self)
|
world.addEventHandler(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self:__Status(-1)
|
self:__Status(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -995,23 +981,40 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function SUPPRESSION:onafterStatus(Controllable, From, Event, To)
|
function SUPPRESSION:onafterStatus(Controllable, From, Event, To)
|
||||||
|
|
||||||
--local text=string.format("State=%s, ROE %d, Life=%.1f", Controllable:GetName())
|
-- Suppressed group.
|
||||||
--MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
|
||||||
|
|
||||||
local group=self.Controllable --Wrapper.Group#GROUP
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
|
|
||||||
local n=group:GetAmmunition()
|
-- Check if group object exists.
|
||||||
|
if group then
|
||||||
|
|
||||||
self:StatusReport(false)
|
-- Number of alive units.
|
||||||
|
local nunits=group:CountAliveUnits()
|
||||||
-- Retreat if completely out of ammo and retreat zone defined.
|
|
||||||
if n==0 and self.RetreatZone then
|
|
||||||
|
|
||||||
self:Retreat()
|
|
||||||
|
|
||||||
end
|
-- Check if there are units.
|
||||||
|
if nunits>0 then
|
||||||
|
|
||||||
|
-- Retreat if completely out of ammo and retreat zone defined.
|
||||||
|
local nammo=group:GetAmmunition()
|
||||||
|
if nammo==0 and self.RetreatZone then
|
||||||
|
self:Retreat()
|
||||||
|
end
|
||||||
|
|
||||||
self:__Status(-30)
|
-- Status report.
|
||||||
|
self:StatusReport(false)
|
||||||
|
|
||||||
|
-- Call status again if not "Stopped".
|
||||||
|
if self:GetState()~="Stopped" then
|
||||||
|
self:__Status(-30)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1409,27 +1412,54 @@ end
|
|||||||
function SUPPRESSION:onafterDead(Controllable, From, Event, To)
|
function SUPPRESSION:onafterDead(Controllable, From, Event, To)
|
||||||
self:_EventFromTo("onafterDead", Event, From, To)
|
self:_EventFromTo("onafterDead", Event, From, To)
|
||||||
|
|
||||||
-- Number of units left in the group.
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
local nunits=#self.Controllable:GetUnits()
|
|
||||||
|
if group then
|
||||||
local text=string.format("Group %s: One of our units just died! %d units left.", self.Controllable:GetName(), nunits)
|
|
||||||
MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
-- Number of units left in the group.
|
||||||
self:T(self.lid..text)
|
local nunits=group:CountAliveUnits()
|
||||||
|
|
||||||
-- Go to stop state.
|
local text=string.format("Group %s: One of our units just died! %d units left.", self.Controllable:GetName(), nunits)
|
||||||
if nunits==0 then
|
MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
||||||
self:T(self.lid..string.format("Stopping SUPPRESSION for group %s.", Controllable:GetName()))
|
self:T(self.lid..text)
|
||||||
self:Stop()
|
|
||||||
if self.mooseevents then
|
-- Go to stop state.
|
||||||
self:UnHandleEvent(EVENTS.Dead)
|
if nunits==0 then
|
||||||
self:UnHandleEvent(EVENTS.Hit)
|
self:Stop()
|
||||||
else
|
|
||||||
world.removeEventHandler(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:Stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- After "Stop" event.
|
||||||
|
-- @param #SUPPRESSION self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function SUPPRESSION:onafterStop(Controllable, From, Event, To)
|
||||||
|
self:_EventFromTo("onafterStop", Event, From, To)
|
||||||
|
|
||||||
|
local text=string.format("Stopping SUPPRESSION for group %s", self.Controllable:GetName())
|
||||||
|
MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
||||||
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
-- Clear all pending schedules
|
||||||
|
self.CallScheduler:Clear()
|
||||||
|
|
||||||
|
if self.mooseevents then
|
||||||
|
self:UnHandleEvent(EVENTS.Dead)
|
||||||
|
self:UnHandleEvent(EVENTS.Hit)
|
||||||
|
else
|
||||||
|
world.removeEventHandler(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
--- Event Handler
|
--- Event Handler
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -1623,95 +1653,101 @@ function SUPPRESSION:_Run(fin, speed, formation, wait)
|
|||||||
|
|
||||||
local group=self.Controllable -- Wrapper.Controllable#CONTROLLABLE
|
local group=self.Controllable -- Wrapper.Controllable#CONTROLLABLE
|
||||||
|
|
||||||
-- Clear all tasks.
|
if group and group:IsAlive() then
|
||||||
group:ClearTasks()
|
|
||||||
|
|
||||||
-- Current coordinates of group.
|
-- Clear all tasks.
|
||||||
local ini=group:GetCoordinate()
|
group:ClearTasks()
|
||||||
|
|
||||||
-- Distance between current and final point.
|
|
||||||
local dist=ini:Get2DDistance(fin)
|
|
||||||
|
|
||||||
-- Heading from ini to fin.
|
|
||||||
local heading=self:_Heading(ini, fin)
|
|
||||||
|
|
||||||
-- Number of waypoints.
|
|
||||||
local nx
|
|
||||||
if dist <= 50 then
|
|
||||||
nx=2
|
|
||||||
elseif dist <= 100 then
|
|
||||||
nx=3
|
|
||||||
elseif dist <= 500 then
|
|
||||||
nx=4
|
|
||||||
else
|
|
||||||
nx=5
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Number of intermediate waypoints.
|
|
||||||
local dx=dist/(nx-1)
|
|
||||||
|
|
||||||
-- Waypoint and task arrays.
|
-- Current coordinates of group.
|
||||||
local wp={}
|
local ini=group:GetCoordinate()
|
||||||
local tasks={}
|
|
||||||
|
|
||||||
-- First waypoint is the current position of the group.
|
|
||||||
wp[1]=ini:WaypointGround(speed, formation)
|
|
||||||
tasks[1]=group:TaskFunction("SUPPRESSION._Passing_Waypoint", self, 1, false)
|
|
||||||
|
|
||||||
if self.Debug then
|
|
||||||
local MarkerID=ini:MarkToAll(string.format("Waypoing %d of group %s (initial)", #wp, self.Controllable:GetName()))
|
|
||||||
end
|
|
||||||
|
|
||||||
self:T2(self.lid..string.format("Number of waypoints %d", nx))
|
|
||||||
for i=1,nx-2 do
|
|
||||||
|
|
||||||
local x=dx*i
|
|
||||||
local coord=ini:Translate(x, heading)
|
|
||||||
|
|
||||||
wp[#wp+1]=coord:WaypointGround(speed, formation)
|
-- Distance between current and final point.
|
||||||
tasks[#tasks+1]=group:TaskFunction("SUPPRESSION._Passing_Waypoint", self, #wp, false)
|
local dist=ini:Get2DDistance(fin)
|
||||||
|
|
||||||
self:T2(self.lid..string.format("%d x = %4.1f", i, x))
|
-- Heading from ini to fin.
|
||||||
if self.Debug then
|
local heading=self:_Heading(ini, fin)
|
||||||
local MarkerID=coord:MarkToAll(string.format("Waypoing %d of group %s", #wp, self.Controllable:GetName()))
|
|
||||||
|
-- Number of waypoints.
|
||||||
|
local nx
|
||||||
|
if dist <= 50 then
|
||||||
|
nx=2
|
||||||
|
elseif dist <= 100 then
|
||||||
|
nx=3
|
||||||
|
elseif dist <= 500 then
|
||||||
|
nx=4
|
||||||
|
else
|
||||||
|
nx=5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Number of intermediate waypoints.
|
||||||
|
local dx=dist/(nx-1)
|
||||||
|
|
||||||
|
-- Waypoint and task arrays.
|
||||||
|
local wp={}
|
||||||
|
local tasks={}
|
||||||
|
|
||||||
|
-- First waypoint is the current position of the group.
|
||||||
|
wp[1]=ini:WaypointGround(speed, formation)
|
||||||
|
tasks[1]=group:TaskFunction("SUPPRESSION._Passing_Waypoint", self, 1, false)
|
||||||
|
|
||||||
|
if self.Debug then
|
||||||
|
local MarkerID=ini:MarkToAll(string.format("Waypoing %d of group %s (initial)", #wp, self.Controllable:GetName()))
|
||||||
|
end
|
||||||
|
|
||||||
|
self:T2(self.lid..string.format("Number of waypoints %d", nx))
|
||||||
|
for i=1,nx-2 do
|
||||||
|
|
||||||
|
local x=dx*i
|
||||||
|
local coord=ini:Translate(x, heading)
|
||||||
|
|
||||||
|
wp[#wp+1]=coord:WaypointGround(speed, formation)
|
||||||
|
tasks[#tasks+1]=group:TaskFunction("SUPPRESSION._Passing_Waypoint", self, #wp, false)
|
||||||
|
|
||||||
|
self:T2(self.lid..string.format("%d x = %4.1f", i, x))
|
||||||
|
if self.Debug then
|
||||||
|
local MarkerID=coord:MarkToAll(string.format("Waypoing %d of group %s", #wp, self.Controllable:GetName()))
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
self:T2(self.lid..string.format("Total distance: %4.1f", dist))
|
||||||
|
|
||||||
|
-- Final waypoint.
|
||||||
|
wp[#wp+1]=fin:WaypointGround(speed, formation)
|
||||||
|
if self.Debug then
|
||||||
|
local MarkerID=fin:MarkToAll(string.format("Waypoing %d of group %s (final)", #wp, self.Controllable:GetName()))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Task to hold.
|
||||||
|
local ConditionWait=group:TaskCondition(nil, nil, nil, nil, wait, nil)
|
||||||
|
local TaskHold = group:TaskHold()
|
||||||
|
|
||||||
|
-- Task combo to make group hold at final waypoint.
|
||||||
|
local TaskComboFin = {}
|
||||||
|
TaskComboFin[#TaskComboFin+1] = group:TaskFunction("SUPPRESSION._Passing_Waypoint", self, #wp, true)
|
||||||
|
TaskComboFin[#TaskComboFin+1] = group:TaskControlled(TaskHold, ConditionWait)
|
||||||
|
|
||||||
|
-- Add final task.
|
||||||
|
tasks[#tasks+1]=group:TaskCombo(TaskComboFin)
|
||||||
|
|
||||||
|
-- Original waypoints of the group.
|
||||||
|
local Waypoints = group:GetTemplateRoutePoints()
|
||||||
|
|
||||||
|
-- New points are added to the default route.
|
||||||
|
for i,p in ipairs(wp) do
|
||||||
|
table.insert(Waypoints, i, wp[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set task for all waypoints.
|
||||||
|
for i,wp in ipairs(Waypoints) do
|
||||||
|
group:SetTaskWaypoint(Waypoints[i], tasks[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Submit task and route group along waypoints.
|
||||||
|
group:Route(Waypoints)
|
||||||
|
|
||||||
|
else
|
||||||
|
self:E(self.lid..string.format("ERROR: Group is not alive!"))
|
||||||
end
|
end
|
||||||
self:T2(self.lid..string.format("Total distance: %4.1f", dist))
|
|
||||||
|
|
||||||
-- Final waypoint.
|
|
||||||
wp[#wp+1]=fin:WaypointGround(speed, formation)
|
|
||||||
if self.Debug then
|
|
||||||
local MarkerID=fin:MarkToAll(string.format("Waypoing %d of group %s (final)", #wp, self.Controllable:GetName()))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Task to hold.
|
|
||||||
local ConditionWait=group:TaskCondition(nil, nil, nil, nil, wait, nil)
|
|
||||||
local TaskHold = group:TaskHold()
|
|
||||||
|
|
||||||
-- Task combo to make group hold at final waypoint.
|
|
||||||
local TaskComboFin = {}
|
|
||||||
TaskComboFin[#TaskComboFin+1] = group:TaskFunction("SUPPRESSION._Passing_Waypoint", self, #wp, true)
|
|
||||||
TaskComboFin[#TaskComboFin+1] = group:TaskControlled(TaskHold, ConditionWait)
|
|
||||||
|
|
||||||
-- Add final task.
|
|
||||||
tasks[#tasks+1]=group:TaskCombo(TaskComboFin)
|
|
||||||
|
|
||||||
-- Original waypoints of the group.
|
|
||||||
local Waypoints = group:GetTemplateRoutePoints()
|
|
||||||
|
|
||||||
-- New points are added to the default route.
|
|
||||||
for i,p in ipairs(wp) do
|
|
||||||
table.insert(Waypoints, i, wp[i])
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set task for all waypoints.
|
|
||||||
for i,wp in ipairs(Waypoints) do
|
|
||||||
group:SetTaskWaypoint(Waypoints[i], tasks[i])
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Submit task and route group along waypoints.
|
|
||||||
group:Route(Waypoints)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ AIRBASE.PersianGulf = {
|
|||||||
["Lavan_Island_Airport"] = "Lavan Island Airport",
|
["Lavan_Island_Airport"] = "Lavan Island Airport",
|
||||||
["Liwa_Airbase"] = "Liwa Airbase",
|
["Liwa_Airbase"] = "Liwa Airbase",
|
||||||
["Qeshm_Island"] = "Qeshm Island",
|
["Qeshm_Island"] = "Qeshm Island",
|
||||||
["Ras_Al_Khaimah_International_Airport"] = "Ras Al Khaimah International Airport",
|
["Ras_Al_Khaimah"] = "Ras Al Khaimah",
|
||||||
["Sas_Al_Nakheel_Airport"] = "Sas Al Nakheel Airport",
|
["Sas_Al_Nakheel_Airport"] = "Sas Al Nakheel Airport",
|
||||||
["Sharjah_Intl"] = "Sharjah Intl",
|
["Sharjah_Intl"] = "Sharjah Intl",
|
||||||
["Shiraz_International_Airport"] = "Shiraz International Airport",
|
["Shiraz_International_Airport"] = "Shiraz International Airport",
|
||||||
|
|||||||
Reference in New Issue
Block a user