mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
This commit is contained in:
parent
8b640912c3
commit
cda1658541
@ -169,12 +169,14 @@ end
|
|||||||
-- @param #number Nshots Number of shots to fire. Default 3.
|
-- @param #number Nshots Number of shots to fire. Default 3.
|
||||||
-- @param #number WeaponType Type of weapon. Default auto.
|
-- @param #number WeaponType Type of weapon. Default auto.
|
||||||
-- @param #number Prio Priority of the task.
|
-- @param #number Prio Priority of the task.
|
||||||
|
-- @return Ops.OpsGroup#OPSGROUP.Task The task table.
|
||||||
function ARMYGROUP:AddTaskFireAtPoint(Coordinate, Clock, Radius, Nshots, WeaponType, Prio)
|
function ARMYGROUP:AddTaskFireAtPoint(Coordinate, Clock, Radius, Nshots, WeaponType, Prio)
|
||||||
|
|
||||||
local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, Coordinate:GetVec2(), Radius, Nshots, WeaponType)
|
local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, Coordinate:GetVec2(), Radius, Nshots, WeaponType)
|
||||||
|
|
||||||
self:AddTask(DCStask, Clock, nil, Prio)
|
local task=self:AddTask(DCStask, Clock, nil, Prio)
|
||||||
|
|
||||||
|
return task
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a *waypoint* task to fire at a given coordinate.
|
--- Add a *waypoint* task to fire at a given coordinate.
|
||||||
@ -262,7 +264,7 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
-- Info text.
|
-- Info text.
|
||||||
local text=string.format("%s: Wp=%d/%d-->%d Speed=%.1f (%d) Heading=%03d ROE=%d Alarm=%d Formation=%s Tasks=%d Missions=%d",
|
local text=string.format("%s: Wp=%d/%d-->%d Speed=%.1f (%d) Heading=%03d ROE=%d Alarm=%d Formation=%s Tasks=%d Missions=%d",
|
||||||
fsmstate, self.currentwp, #self.waypoints, self:GetWaypointIndexNext(), speed, UTILS.MpsToKnots(self.speed), hdg, self.option.ROE, self.option.Alarm, self.option.Formation, nTaskTot, nMissions)
|
fsmstate, self.currentwp, #self.waypoints, self:GetWaypointIndexNext(), speed, UTILS.MpsToKnots(self.speed or 0), hdg, self.option.ROE, self.option.Alarm, self.option.Formation, nTaskTot, nMissions)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -368,7 +370,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
|
|||||||
n=n or self:GetWaypointIndexNext(self.adinfinitum)
|
n=n or self:GetWaypointIndexNext(self.adinfinitum)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("FF Update route n=%d", n))
|
--self:I(self.lid..string.format("FF Update route n=%d", n))
|
||||||
|
|
||||||
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
||||||
self:_UpdateWaypointTasks(n)
|
self:_UpdateWaypointTasks(n)
|
||||||
@ -830,7 +832,7 @@ function ARMYGROUP:_InitGroup()
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Initialized Army Group %s:\n", self.groupname)
|
local text=string.format("Initialized Army Group %s:\n", self.groupname)
|
||||||
text=text..string.format("AC type = %s\n", self.actype)
|
text=text..string.format("Unit type = %s\n", self.actype)
|
||||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||||
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
||||||
text=text..string.format("Elements = %d\n", #self.elements)
|
text=text..string.format("Elements = %d\n", #self.elements)
|
||||||
|
|||||||
@ -1410,6 +1410,13 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
self:SwitchRadio(self.radioLast.Freq, self.radioLast.Modu)
|
self:SwitchRadio(self.radioLast.Freq, self.radioLast.Modu)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set callsign.
|
||||||
|
if self.callsignDefault then
|
||||||
|
self:SwitchCallsign(self.callsignDefault.NumberSquad, self.callsignDefault.NumberGroup)
|
||||||
|
else
|
||||||
|
self:SetDefaultCallsign(self.callsign.NumberSquad, self.callsign.NumberGroup)
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: make this input.
|
-- TODO: make this input.
|
||||||
self.group:SetOption(AI.Option.Air.id.PROHIBIT_JETT, true)
|
self.group:SetOption(AI.Option.Air.id.PROHIBIT_JETT, true)
|
||||||
self.group:SetOption(AI.Option.Air.id.PROHIBIT_AB, true) -- Does not seem to work. AI still used the after burner.
|
self.group:SetOption(AI.Option.Air.id.PROHIBIT_AB, true) -- Does not seem to work. AI still used the after burner.
|
||||||
@ -2594,7 +2601,7 @@ function FLIGHTGROUP:_InitGroup()
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
if self.verbose>=1 then
|
if self.verbose>=1 then
|
||||||
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
local text=string.format("Initialized Flight Group %s:\n", self.groupname)
|
||||||
text=text..string.format("AC type = %s\n", self.actype)
|
text=text..string.format("Unit type = %s\n", self.actype)
|
||||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||||
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
text=text..string.format("Range max = %.1f km\n", self.rangemax/1000)
|
||||||
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))
|
||||||
|
|||||||
@ -1169,7 +1169,7 @@ function NAVYGROUP:_InitGroup()
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("Initialized Navy Group %s:\n", self.groupname)
|
local text=string.format("Initialized Navy Group %s:\n", self.groupname)
|
||||||
text=text..string.format("AC type = %s\n", self.actype)
|
text=text..string.format("Unit type = %s\n", self.actype)
|
||||||
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedmax))
|
||||||
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
|
||||||
text=text..string.format("Elements = %d\n", #self.elements)
|
text=text..string.format("Elements = %d\n", #self.elements)
|
||||||
@ -1177,7 +1177,7 @@ function NAVYGROUP:_InitGroup()
|
|||||||
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On))
|
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On))
|
||||||
text=text..string.format("Ammo = %d (G=%d/R=%d/M=%d/T=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Missiles, self.ammo.Torpedos)
|
text=text..string.format("Ammo = %d (G=%d/R=%d/M=%d/T=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Missiles, self.ammo.Torpedos)
|
||||||
text=text..string.format("FSM state = %s\n", self:GetState())
|
text=text..string.format("FSM state = %s\n", self:GetState())
|
||||||
text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive()))
|
text=text..string.format("Is alive = %s\n", tostring(self:IsAlive()))
|
||||||
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
|
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
|||||||
@ -486,7 +486,7 @@ end
|
|||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @return DCS#Vec3 Vector with x,y,z components.
|
-- @return DCS#Vec3 Vector with x,y,z components.
|
||||||
function OPSGROUP:GetVec3()
|
function OPSGROUP:GetVec3()
|
||||||
if self:IsAlive() then
|
if self:IsAlive()~=nil then
|
||||||
local vec3=self.group:GetVec3()
|
local vec3=self.group:GetVec3()
|
||||||
return vec3
|
return vec3
|
||||||
end
|
end
|
||||||
@ -2803,6 +2803,10 @@ function OPSGROUP:InitWaypoints()
|
|||||||
local coordinate=COORDINATE:New(wp.x, wp.alt, wp.y)
|
local coordinate=COORDINATE:New(wp.x, wp.alt, wp.y)
|
||||||
local speedknots=UTILS.MpsToKnots(wp.speed)
|
local speedknots=UTILS.MpsToKnots(wp.speed)
|
||||||
|
|
||||||
|
if index==1 then
|
||||||
|
self.speed=wp.speed
|
||||||
|
end
|
||||||
|
|
||||||
self:AddWaypoint(coordinate, speedknots, index-1, nil, false)
|
self:AddWaypoint(coordinate, speedknots, index-1, nil, false)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -3042,8 +3046,9 @@ function OPSGROUP:SwitchROE(roe)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set current ROE for the group.
|
--- Get name of ROE corresponding to the numerical value.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
|
-- @return #string Name of ROE.
|
||||||
function OPSGROUP:_GetROEName(roe)
|
function OPSGROUP:_GetROEName(roe)
|
||||||
local name="unknown"
|
local name="unknown"
|
||||||
if roe==0 then
|
if roe==0 then
|
||||||
@ -3350,7 +3355,6 @@ function OPSGROUP:SwitchICLS(Channel, Morse, UnitName)
|
|||||||
self.icls.BeaconUnit=unit
|
self.icls.BeaconUnit=unit
|
||||||
self.icls.On=true
|
self.icls.On=true
|
||||||
|
|
||||||
|
|
||||||
if self:IsInUtero() then
|
if self:IsInUtero() then
|
||||||
self:T2(self.lid..string.format("Switching ICLS to Channel %d Morse %s on unit %s when GROUP is SPAWNED", self.icls.Channel, tostring(self.icls.Morse), self.icls.BeaconName))
|
self:T2(self.lid..string.format("Switching ICLS to Channel %d Morse %s on unit %s when GROUP is SPAWNED", self.icls.Channel, tostring(self.icls.Morse), self.icls.BeaconName))
|
||||||
else
|
else
|
||||||
@ -3425,7 +3429,6 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
|
|||||||
Frequency=Frequency or self.radioDefault.Freq
|
Frequency=Frequency or self.radioDefault.Freq
|
||||||
Modulation=Modulation or self.radioDefault.Modu
|
Modulation=Modulation or self.radioDefault.Modu
|
||||||
|
|
||||||
|
|
||||||
if self:IsInUtero() then
|
if self:IsInUtero() then
|
||||||
|
|
||||||
-- Set current radio.
|
-- Set current radio.
|
||||||
@ -3433,7 +3436,8 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
|
|||||||
self.radioLast.Freq=Frequency
|
self.radioLast.Freq=Frequency
|
||||||
self.radioLast.Modu=Modulation
|
self.radioLast.Modu=Modulation
|
||||||
|
|
||||||
self:T2(self.lid..string.format("Switching radio to frequency %.3f MHz %s when GROUP is SPAWNED", self.radioLast.Freq, UTILS.GetModulationName(self.radioLast.Modu)))
|
self:T2(self.lid..string.format("Switching radio to frequency %.3f MHz %s when GROUP is SPAWNED", self.radioLast.Freq, UTILS.GetModulationName(self.radioLast.Modu)))
|
||||||
|
|
||||||
elseif self:IsAlive() then
|
elseif self:IsAlive() then
|
||||||
|
|
||||||
local group=self.group --Wrapper.Group#GROUP
|
local group=self.group --Wrapper.Group#GROUP
|
||||||
@ -3570,16 +3574,28 @@ end
|
|||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:SwitchCallsign(CallsignName, CallsignNumber)
|
function OPSGROUP:SwitchCallsign(CallsignName, CallsignNumber)
|
||||||
|
|
||||||
if self:IsAlive() then
|
CallsignName=CallsignName or self.callsignDefault.NumberSquad
|
||||||
|
CallsignNumber=CallsignNumber or self.callsignDefault.NumberGroup
|
||||||
|
|
||||||
self.callsign.NumberSquad=CallsignName or self.callsignDefault.NumberSquad
|
if self:IsInUtero() then
|
||||||
self.callsign.NumberGroup=CallsignNumber or self.callsignDefault.NumberGroup
|
|
||||||
|
-- Set default callsign. We switch to this when group is spawned.
|
||||||
|
self:SetDefaultCallsign(CallsignName, CallsignNumber)
|
||||||
|
|
||||||
|
elseif self:IsAlive() then
|
||||||
|
|
||||||
|
-- Set current callsign.
|
||||||
|
self.callsign.NumberSquad=CallsignName
|
||||||
|
self.callsign.NumberGroup=CallsignNumber
|
||||||
|
|
||||||
|
-- Debug.
|
||||||
self:I(self.lid..string.format("Switching callsign to %d-%d", self.callsign.NumberSquad, self.callsign.NumberGroup))
|
self:I(self.lid..string.format("Switching callsign to %d-%d", self.callsign.NumberSquad, self.callsign.NumberGroup))
|
||||||
|
|
||||||
|
-- Give command to change the callsign.
|
||||||
self.group:CommandSetCallsign(self.callsign.NumberSquad, self.callsign.NumberGroup)
|
self.group:CommandSetCallsign(self.callsign.NumberSquad, self.callsign.NumberGroup)
|
||||||
|
|
||||||
|
else
|
||||||
|
--TODO: Error
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -814,7 +814,8 @@ end
|
|||||||
-- @return #number The velocity in knots.
|
-- @return #number The velocity in knots.
|
||||||
function POSITIONABLE:GetVelocityKNOTS()
|
function POSITIONABLE:GetVelocityKNOTS()
|
||||||
self:F2( self.PositionableName )
|
self:F2( self.PositionableName )
|
||||||
return UTILS.MpsToKnots(self:GetVelocityMPS())
|
local velmps=self:GetVelocityMPS()
|
||||||
|
return UTILS.MpsToKnots(velmps)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the Angle of Attack of a positionable.
|
--- Returns the Angle of Attack of a positionable.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user