This commit is contained in:
Frank 2020-09-04 00:58:37 +02:00
parent 8b640912c3
commit cda1658541
5 changed files with 43 additions and 17 deletions

View File

@ -169,12 +169,14 @@ end
-- @param #number Nshots Number of shots to fire. Default 3.
-- @param #number WeaponType Type of weapon. Default auto.
-- @param #number Prio Priority of the task.
-- @return Ops.OpsGroup#OPSGROUP.Task The task table.
function ARMYGROUP:AddTaskFireAtPoint(Coordinate, Clock, Radius, Nshots, WeaponType, Prio)
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
--- Add a *waypoint* task to fire at a given coordinate.
@ -262,7 +264,7 @@ function ARMYGROUP:onafterStatus(From, Event, To)
-- 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",
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)
else
@ -368,7 +370,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
n=n or self:GetWaypointIndexNext(self.adinfinitum)
-- 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.
self:_UpdateWaypointTasks(n)
@ -830,7 +832,7 @@ function ARMYGROUP:_InitGroup()
-- Debug info.
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 cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
text=text..string.format("Elements = %d\n", #self.elements)

View File

@ -1410,6 +1410,13 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
self:SwitchRadio(self.radioLast.Freq, self.radioLast.Modu)
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.
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.
@ -2594,7 +2601,7 @@ function FLIGHTGROUP:_InitGroup()
-- Debug info.
if self.verbose>=1 then
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("Range max = %.1f km\n", self.rangemax/1000)
text=text..string.format("Ceiling = %.1f feet\n", UTILS.MetersToFeet(self.ceiling))

View File

@ -1169,7 +1169,7 @@ function NAVYGROUP:_InitGroup()
-- Debug info.
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 cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise))
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("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("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()))
self:I(self.lid..text)

View File

@ -486,7 +486,7 @@ end
-- @param #OPSGROUP self
-- @return DCS#Vec3 Vector with x,y,z components.
function OPSGROUP:GetVec3()
if self:IsAlive() then
if self:IsAlive()~=nil then
local vec3=self.group:GetVec3()
return vec3
end
@ -2803,6 +2803,10 @@ function OPSGROUP:InitWaypoints()
local coordinate=COORDINATE:New(wp.x, wp.alt, wp.y)
local speedknots=UTILS.MpsToKnots(wp.speed)
if index==1 then
self.speed=wp.speed
end
self:AddWaypoint(coordinate, speedknots, index-1, nil, false)
end
@ -3042,8 +3046,9 @@ function OPSGROUP:SwitchROE(roe)
return self
end
--- Set current ROE for the group.
--- Get name of ROE corresponding to the numerical value.
-- @param #OPSGROUP self
-- @return #string Name of ROE.
function OPSGROUP:_GetROEName(roe)
local name="unknown"
if roe==0 then
@ -3350,7 +3355,6 @@ function OPSGROUP:SwitchICLS(Channel, Morse, UnitName)
self.icls.BeaconUnit=unit
self.icls.On=true
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))
else
@ -3425,7 +3429,6 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
Frequency=Frequency or self.radioDefault.Freq
Modulation=Modulation or self.radioDefault.Modu
if self:IsInUtero() then
-- Set current radio.
@ -3433,7 +3436,8 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
self.radioLast.Freq=Frequency
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
local group=self.group --Wrapper.Group#GROUP
@ -3570,16 +3574,28 @@ end
-- @return #OPSGROUP self
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
self.callsign.NumberGroup=CallsignNumber or self.callsignDefault.NumberGroup
if self:IsInUtero() then
-- 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))
-- Give command to change the callsign.
self.group:CommandSetCallsign(self.callsign.NumberSquad, self.callsign.NumberGroup)
else
--TODO: Error
end
return self

View File

@ -814,7 +814,8 @@ end
-- @return #number The velocity in knots.
function POSITIONABLE:GetVelocityKNOTS()
self:F2( self.PositionableName )
return UTILS.MpsToKnots(self:GetVelocityMPS())
local velmps=self:GetVelocityMPS()
return UTILS.MpsToKnots(velmps)
end
--- Returns the Angle of Attack of a positionable.