- options set via flightgroup
- fixed little bug in OPSGROUP emission default
This commit is contained in:
Frank 2024-04-04 23:39:56 +02:00
parent 08fb4e3736
commit 532cc0b4df
2 changed files with 52 additions and 53 deletions

View File

@ -2229,28 +2229,29 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live
self:_PlaceMarkers(waypoints, wpdesc, self.SpawnIndex) self:_PlaceMarkers(waypoints, wpdesc, self.SpawnIndex)
end end
-- TODO: Use FLIGHTGROUP functions for invisible, immortal, etc.
-- Set group to be invisible. -- Set group to be invisible.
if self.invisible then if self.invisible then
self:_CommandInvisible(group, true) flightgroup:SetDefaultInvisible(true)
flightgroup:SwitchInvisible(true)
end end
-- Set group to be immortal. -- Set group to be immortal.
if self.immortal then if self.immortal then
self:_CommandImmortal(group, true) flightgroup:SetDefaultImmortal(true)
flightgroup:SwitchImmortal(true)
end end
-- Set group to be immortal. -- Set group to be immortal.
if self.eplrs then if self.eplrs then
group:CommandEPLRS(true, 1) flightgroup:SetDefaultEPLRS(true)
flightgroup:SwitchEPLRS(true)
end end
-- Set ROE, default is "weapon hold". -- Set ROE, default is "weapon hold".
self:_SetROE(group, self.roe) self:_SetROE(flightgroup, self.roe)
-- Set ROT, default is "no reaction". -- Set ROT, default is "no reaction".
self:_SetROT(group, self.rot) self:_SetROT(flightgroup, self.rot)
-- Init ratcraft array. -- Init ratcraft array.
local ratcraft={} --#RAT.RatCraft local ratcraft={} --#RAT.RatCraft
@ -4652,39 +4653,19 @@ function RAT:_ActivateUncontrolled()
if departureFlightControl then if departureFlightControl then
self:T(self.lid..string.format("RAT group %s is ready for takeoff", group:GetName())) self:T(self.lid..string.format("RAT group %s is ready for takeoff", group:GetName()))
ratcraft.flightgroup:SetReadyForTakeoff(true) ratcraft.flightgroup:SetReadyForTakeoff(true)
ratcraft.active=true
else else
-- Start aircraft. -- Start aircraft.
self:T(self.lid..string.format("RAT group %s is switching to controlled now", group:GetName())) self:T(self.lid..string.format("RAT group %s is switching to controlled now", group:GetName()))
self:_CommandStartUncontrolled(group) ratcraft.flightgroup:StartUncontrolled()
end end
end
end
--- Start uncontrolled aircraft group.
-- @param #RAT self
-- @param Wrapper.Group#GROUP group Group to be activated.
function RAT:_CommandStartUncontrolled(group)
-- Start command.
local StartCommand = {id = 'Start', params = {}}
-- Debug message
local text=string.format("Uncontrolled: Activating group %s.", group:GetName())
self:T(self.lid..text)
-- Activate group.
group:SetCommand(StartCommand)
-- Spawn index.
local ratcraft=self:_GetRatcraftFromGroup(group)
-- Set status to active. -- Set status to active.
ratcraft.active=true ratcraft.active=true
-- Set status to "Ready and Starting Engines". -- Set status to "Ready and Starting Engines".
self:_SetStatus(group, RAT.status.EventBirth) self:_SetStatus(group, RAT.status.EventBirth)
end
end end
--- Set RAT group to (in-)visible for other AI forces. --- Set RAT group to (in-)visible for other AI forces.
@ -4888,33 +4869,51 @@ end
--- Set ROE for a group. --- Set ROE for a group.
-- @param #RAT self -- @param #RAT self
-- @param Wrapper.Group#GROUP group Group for which the ROE is set. -- @param Ops.FlightGroup#FLIGHTGROUP flightgroup Group for which the ROE is set.
-- @param #string roe ROE of group. -- @param #string roe ROE of group.
function RAT:_SetROE(group, roe) function RAT:_SetROE(flightgroup, roe)
self:T(self.lid.."Setting ROE to "..roe.." for group "..group:GetName())
if self.roe==RAT.ROE.returnfire then roe=roe or self.roe
group:OptionROEReturnFire()
elseif self.roe==RAT.ROE.weaponfree then self:T(self.lid.."Setting ROE to "..roe.." for group "..flightgroup:GetName())
group:OptionROEWeaponFree()
local _roe=ENUMS.ROE.WeaponHold
if roe==RAT.ROE.returnfire then
_roe=ENUMS.ROE.ReturnFire
elseif roe==RAT.ROE.weaponfree then
_roe=ENUMS.ROE.OpenFireWeaponFree
else else
group:OptionROEHoldFire()
end end
flightgroup:SetDefaultROE(_roe)
flightgroup:SwitchROE(_roe)
end end
--- Set ROT for a group. --- Set ROT for a group.
-- @param #RAT self -- @param #RAT self
-- @param Wrapper.Group#GROUP group Group for which the ROT is set. -- @param Ops.FlightGroup#FLIGHTGROUP flightgroup Group for which the ROT is set.
-- @param #string rot ROT of group. -- @param #string rot ROT of group.
function RAT:_SetROT(group, rot) function RAT:_SetROT(flightgroup, rot)
self:T(self.lid.."Setting ROT to "..rot.." for group "..group:GetName())
if self.rot==RAT.ROT.passive then rot=rot or self.rot
group:OptionROTPassiveDefense()
elseif self.rot==RAT.ROT.evade then self:T(self.lid.."Setting ROT to "..rot.." for group "..flightgroup:GetName())
group:OptionROTEvadeFire()
local _rot=ENUMS.ROT.NoReaction
if rot==RAT.ROT.passive then
_rot=ENUMS.ROT.PassiveDefense
elseif rot==RAT.ROT.evade then
_rot=ENUMS.ROT.EvadeFire
else else
group:OptionROTNoReaction()
end end
flightgroup:SetDefaultROT(_rot)
flightgroup:SwitchROT(_rot)
end end

View File

@ -12031,7 +12031,7 @@ function OPSGROUP:GetEPLRS()
return self.option.EPLRS or self.optionDefault.EPLRS return self.option.EPLRS or self.optionDefault.EPLRS
end end
--- Set the default EPLRS for the group. --- Set the default emission state for the group.
-- @param #OPSGROUP self -- @param #OPSGROUP self
-- @param #boolean OnOffSwitch If `true`, EPLRS is on by default. If `false` default EPLRS setting is off. If `nil`, default is on if group has EPLRS and off if it does not have a datalink. -- @param #boolean OnOffSwitch If `true`, EPLRS is on by default. If `false` default EPLRS setting is off. If `nil`, default is on if group has EPLRS and off if it does not have a datalink.
-- @return #OPSGROUP self -- @return #OPSGROUP self
@ -12040,7 +12040,7 @@ function OPSGROUP:SetDefaultEmission(OnOffSwitch)
if OnOffSwitch==nil then if OnOffSwitch==nil then
self.optionDefault.Emission=true self.optionDefault.Emission=true
else else
self.optionDefault.EPLRS=OnOffSwitch self.optionDefault.Emission=OnOffSwitch
end end
return self return self