#AUFTRAG/#OPS/#RESCUEHELO - make the NewRescueHelo AUFTRAG use Ops.Rescuehelo as basis. #2199

This commit is contained in:
Applevangelist
2025-11-22 16:18:28 +01:00
parent a5076eddba
commit 9e55118d3e
3 changed files with 68 additions and 29 deletions
+1 -1
View File
@@ -2037,7 +2037,7 @@ function AUFTRAG:NewRESCUEHELO(Carrier)
-- Mission options:
mission.missionTask=ENUMS.MissionTask.NOTHING
mission.missionFraction=0.5
mission.missionFraction=0.9
mission.optionROE=ENUMS.ROE.WeaponHold
mission.optionROT=ENUMS.ROT.NoReaction
+42 -17
View File
@@ -4302,7 +4302,27 @@ function OPSGROUP:_UpdateTask(Task, Mission)
Mission=Mission or self:GetMissionByTaskID(self.taskcurrent)
if Task.dcstask.id==AUFTRAG.SpecialTask.FORMATION then
if Mission.type == AUFTRAG.Type.RESCUEHELO then
self:T("**********")
self:T("** RESCUEHELO USED")
self:T("**********")
local param=Task.dcstask.params
local followUnit=UNIT:FindByName(param.unitname)
local helogroupname = self:GetGroup():GetName()
Task.formation = RESCUEHELO:New(followUnit,helogroupname)
Task.formation:SetRespawnOnOff(false)
Task.formation.respawninair=false
Task.formation:SetTakeoffCold()
Task.formation:SetHomeBase(followUnit)
Task.formation.helo = self:GetGroup()
-- Start formation FSM.
Task.formation:Start()
if self:IsFlightgroup() then
self:SetDespawnAfterLanding()
end
else
-- Set of group(s) to follow Mother.
local followSet=SET_GROUP:New():AddGroup(self.group)
@@ -4320,11 +4340,13 @@ function OPSGROUP:_UpdateTask(Task, Mission)
Task.formation:SetFollowTimeInterval(param.dtFollow)
-- Formation mode.
Task.formation:SetFlightModeFormation(self.group)
--Task.formation:SetFlightModeFormation(self.group)
-- Start formation FSM.
Task.formation:Start()
end
elseif Task.dcstask.id==AUFTRAG.SpecialTask.PATROLZONE then
---
@@ -8019,16 +8041,19 @@ function OPSGROUP:onafterDead(From, Event, To)
-- Get asset.
local asset=self.legion:GetAssetByName(self.groupname)
if asset then
-- Get request.
local request=self.legion:GetRequestByID(asset.rid)
-- Trigger asset dead event.
self.legion:AssetDead(asset, request)
-- Get request.
local request=self.legion:GetRequestByID(asset.rid)
-- Trigger asset dead event.
self.legion:AssetDead(asset, request)
end
end
-- Stop in 5 sec to give possible respawn attempts a chance.
self:__Stop(-5)
@@ -12719,7 +12744,7 @@ end
-- @return #OPSGROUP self
function OPSGROUP:SetDefaultCallsign(CallsignName, CallsignNumber)
self:T(self.lid..string.format("Setting Default callsing %s-%s", tostring(CallsignName), tostring(CallsignNumber)))
self:T(self.lid..string.format("Setting Default callsign %s-%s", tostring(CallsignName), tostring(CallsignNumber)))
self.callsignDefault={} --#OPSGROUP.Callsign
self.callsignDefault.NumberSquad=CallsignName
@@ -13478,8 +13503,8 @@ function OPSGROUP:GetAmmoUnit(unit, display)
if ammotable then
local weapons=#ammotable
--self:I(ammotable)
--UTILS.PrintTableToLog(ammotable)
--self:I(ammotable)
--UTILS.PrintTableToLog(ammotable)
-- Loop over all weapons.
for w=1,weapons do
@@ -13487,9 +13512,9 @@ function OPSGROUP:GetAmmoUnit(unit, display)
-- Number of current weapon.
local Nammo=ammotable[w]["count"]
-- Range in meters. Seems only to exist for missiles (not shells).
local rmin=ammotable[w]["desc"]["rangeMin"] or 0
local rmax=ammotable[w]["desc"]["rangeMaxAltMin"] or 0
-- Range in meters. Seems only to exist for missiles (not shells).
local rmin=ammotable[w]["desc"]["rangeMin"] or 0
local rmax=ammotable[w]["desc"]["rangeMaxAltMin"] or 0
-- Type name of current weapon.
local Tammo=ammotable[w]["desc"]["typeName"]
@@ -13511,7 +13536,7 @@ function OPSGROUP:GetAmmoUnit(unit, display)
-- Add up all shells.
nshells=nshells+Nammo
-- Add small and large caliber shells for guns and cannons
if ammotable[w]["desc"]["warhead"] and ammotable[w]["desc"]["warhead"]["caliber"] then
local caliber=ammotable[w]["desc"]["warhead"]["caliber"]
+25 -11
View File
@@ -234,7 +234,7 @@ _RESCUEHELOID=0
--- Class version.
-- @field #string version
RESCUEHELO.version="1.1.0"
RESCUEHELO.version="1.2.0"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
@@ -247,6 +247,7 @@ RESCUEHELO.version="1.1.0"
-- DONE: Possibility to add already present/spawned aircraft, e.g. for warehouse.
-- DONE: Add rescue event when aircraft crashes.
-- DONE: Make offset input parameter.
-- DONE: Make useable for AUFTRAG
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor
@@ -336,6 +337,9 @@ function RESCUEHELO:New(carrierunit, helogroupname)
self:AddTransition("*", "Status", "*")
self:AddTransition("*", "Stop", "Stopped")
self:I(self.lid.."Started.")
--- Triggers the FSM event "Start" that starts the rescue helo. Initializes parameters and starts event handlers.
-- @function [parent=#RESCUEHELO] Start
@@ -870,15 +874,25 @@ function RESCUEHELO:onafterStart(From, Event, To)
-- Delay before formation is started.
local delay=120
-- Spawn helo. We need to introduce an alias in case this class is used twice. This would confuse the spawn routine.
local Spawn=SPAWN:NewWithAlias(self.helogroupname, self.alias)
-- Set modex for spawn.
Spawn:InitModex(self.modex)
local UsesAliveGroup=false
local Spawn = GROUP:FindByName(self.helogroupname)
if Spawn and Spawn:IsAlive() then
self.helo=Spawn
UsesAliveGroup = true
delay = 1
else
-- Spawn helo. We need to introduce an alias in case this class is used twice. This would confuse the spawn routine.
local Spawn=SPAWN:NewWithAlias(self.helogroupname, self.alias)
-- Set modex for spawn.
Spawn:InitModex(self.modex)
end
-- Spawn in air or at airbase.
if self.takeoff==SPAWN.Takeoff.Air then
if UsesAliveGroup==false and self.takeoff==SPAWN.Takeoff.Air then
-- Carrier heading
local hdg=self.carrier:GetHeading()
@@ -898,7 +912,7 @@ function RESCUEHELO:onafterStart(From, Event, To)
-- Start formation in 1 seconds
delay=1
else
elseif UsesAliveGroup==false and self.uncontrolledac then
-- Check if an uncontrolled helo group was requested.
if self.uncontrolledac then
@@ -918,9 +932,9 @@ function RESCUEHELO:onafterStart(From, Event, To)
-- No group of that name!
self:E(string.format("ERROR: No uncontrolled (alive) rescue helo group with name %s could be found!", self.helogroupname))
return
end
end
else
elseif UsesAliveGroup==false then
-- Spawn at airbase.
self.helo=Spawn:SpawnAtAirbase(self.airbase, self.takeoff, nil, AIRBASE.TerminalType.HelicopterUsable)