mirror of
https://github.com/iTracerFacer/DCS_MissionDev.git
synced 2025-12-03 04:14:46 +00:00
Lots of little changes.
This commit is contained in:
parent
c2bde278a4
commit
9ce92421e6
Binary file not shown.
@ -235,7 +235,7 @@ function BuildAFARP(Coordinate)
|
|||||||
local m = MESSAGE:New(string.format("FARP %s in operation!",FName),15,"CTLD"):ToBlue()
|
local m = MESSAGE:New(string.format("FARP %s in operation!",FName),15,"CTLD"):ToBlue()
|
||||||
end
|
end
|
||||||
|
|
||||||
function my_ctld:OnAfterCratesBuild(From,Event,To,Group,Unit,Vehicle)
|
function blue_ctld:OnAfterCratesBuild(From,Event,To,Group,Unit,Vehicle)
|
||||||
local name = Vehicle:GetName()
|
local name = Vehicle:GetName()
|
||||||
if string.find(name,"FOB",1,true) then
|
if string.find(name,"FOB",1,true) then
|
||||||
local Coord = Vehicle:GetCoordinate()
|
local Coord = Vehicle:GetCoordinate()
|
||||||
@ -361,7 +361,14 @@ function blue_ctld:OnAfterTroopsDeployed(From,Event,To,Group,Unit,Troops)
|
|||||||
-- Red CTLD Functions
|
-- Red CTLD Functions
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function red_ctld:OnAfterCratesBuild(From,Event,To,Group,Unit,Vehicle)
|
||||||
|
local name = Vehicle:GetName()
|
||||||
|
if string.find(name,"FOB",1,true) then
|
||||||
|
local Coord = Vehicle:GetCoordinate()
|
||||||
|
Vehicle:Destroy(false)
|
||||||
|
BuildAFARP(Coord)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function red_ctld:OnAfterTroopsDeployed(From,Event,To,Group,Unit,Troops)
|
function red_ctld:OnAfterTroopsDeployed(From,Event,To,Group,Unit,Troops)
|
||||||
if Unit then
|
if Unit then
|
||||||
|
|||||||
@ -74,7 +74,21 @@ local RED_AA_ZONES = {
|
|||||||
ZONE:New("RED-AA-13"),
|
ZONE:New("RED-AA-13"),
|
||||||
ZONE:New("RED-AA-14"),
|
ZONE:New("RED-AA-14"),
|
||||||
ZONE:New("RED-AA-15"),
|
ZONE:New("RED-AA-15"),
|
||||||
ZONE:New("RED-AA-16")
|
ZONE:New("RED-AA-16"),
|
||||||
|
ZONE:New("RED-AA-17"),
|
||||||
|
ZONE:New("RED-AA-18"),
|
||||||
|
ZONE:New("RED-AA-19"),
|
||||||
|
ZONE:New("RED-AA-20"),
|
||||||
|
ZONE:New("RED-AA-21"),
|
||||||
|
ZONE:New("RED-AA-22"),
|
||||||
|
ZONE:New("RED-AA-23"),
|
||||||
|
ZONE:New("RED-AA-24"),
|
||||||
|
ZONE:New("RED-AA-25"),
|
||||||
|
ZONE:New("RED-AA-26"),
|
||||||
|
ZONE:New("RED-AA-27"),
|
||||||
|
ZONE:New("RED-AA-28"),
|
||||||
|
ZONE:New("RED-AA-29"),
|
||||||
|
ZONE:New("RED-AA-30")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,43 +1,109 @@
|
|||||||
-- Define the patrol zone
|
-- Debugging flag
|
||||||
local patrolZone = ZONE:New("AWACS_PatrolZone")
|
local DEBUG = true
|
||||||
|
|
||||||
-- Define AWACS and its escorts
|
-- Define AWACS and its escorts
|
||||||
local awacsGroup = "BLUE EWR AWACS" -- Name of AWACS group from mission editor
|
local awacsGroupName = "BLUE EWR AWACS"
|
||||||
local escortGroup1 = "BlueAWACS_Escort_Group1" -- First escort group
|
local escortGroup1Name = "BlueAWACS_Escort_Group1"
|
||||||
local escortGroup2 = "BlueAWACS_Escort_Group2" -- Second escort group
|
|
||||||
|
|
||||||
-- Spawn the AWACS and set up patrol behavior
|
-- Configuration parameters
|
||||||
local awacs = SPAWN:New(awacsGroup)
|
local patrolAltMin = 5000
|
||||||
:InitLimit(1, 0) -- Limit to one active instance of AWACS
|
local patrolAltMax = 8000
|
||||||
:OnSpawnGroup(function(group)
|
local escortFollowDistance = 1000
|
||||||
-- Define patrol within the zone
|
local respawnCheckInterval = 10
|
||||||
local awacsPatrol = AI_PATROL_ZONE:New(group, patrolZone, 5000, 10000, 500, 800)
|
local maxEscortSpawns = 10 -- maximum number of escort spawns - might take this out.
|
||||||
awacsPatrol:ManageFuelOn(.7, 300) -- AWACS returns to base when low on fuel
|
|
||||||
|
|
||||||
-- Event handler for AWACS being attacked
|
-- Function to print debug messages if DEBUG is enabled
|
||||||
group:HandleEvent(EVENTS.Hit)
|
local function DebugMessage(message)
|
||||||
function group:OnEventHit(EventData)
|
if DEBUG and message then
|
||||||
group:RouteRTB() -- AWACS returns to base when attacked
|
env.info("[AWACS DEBUG] " .. tostring(message))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Function to send a message to all players
|
||||||
|
local function Announce(message, soundFile)
|
||||||
|
if message then
|
||||||
|
MESSAGE:New(message, 15):ToAll()
|
||||||
|
end
|
||||||
|
if soundFile then
|
||||||
|
--local sound = SOUND:New(soundFile)
|
||||||
|
--sound:ToAll()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Define the patrol zone
|
||||||
|
local patrolZone = ZONE:New("AWACS_PatrolZone")
|
||||||
|
if patrolZone then
|
||||||
|
DebugMessage("Patrol zone created: " .. patrolZone:GetName())
|
||||||
|
else
|
||||||
|
DebugMessage("ERROR: Patrol zone 'AWACS_PatrolZone' not found. Check the mission editor.")
|
||||||
|
return -- Exit if the patrol zone is not defined
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Define the AWACS spawn
|
||||||
|
local awacsSpawn = SPAWN:New(awacsGroupName):InitLimit(1, 0)
|
||||||
|
|
||||||
|
-- Function to spawn and attach escorts to AWACS
|
||||||
|
function spawnEscort(escortGroupName, awacsGroup)
|
||||||
|
if not escortGroupName or not awacsGroup then
|
||||||
|
DebugMessage("ERROR: Invalid escort group name or AWACS group.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
DebugMessage("Spawning escort: " .. escortGroupName)
|
||||||
|
Announce("Spawning escort for AWACS.", "escort_spawn.ogg")
|
||||||
|
|
||||||
|
local escortSpawn = SPAWN:New(escortGroupName):InitLimit(1, maxEscortSpawns)
|
||||||
|
|
||||||
|
escortSpawn:OnSpawnGroup(function(escortGroup)
|
||||||
|
if not escortGroup then
|
||||||
|
DebugMessage("ERROR: Escort group failed to spawn.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
DebugMessage("Escort spawned: " .. escortGroup:GetName())
|
||||||
|
|
||||||
|
-- Set the escort group to follow the AWACS
|
||||||
|
SCHEDULER:New(nil, function()
|
||||||
|
if awacsGroup:IsAlive() and escortGroup:IsAlive() then
|
||||||
|
escortGroup:TaskFollow(awacsGroup, escortFollowDistance)
|
||||||
|
DebugMessage("Escort assigned to follow AWACS.")
|
||||||
|
else
|
||||||
|
DebugMessage("AWACS or escort is not alive.")
|
||||||
|
end
|
||||||
|
end, {}, 3, respawnCheckInterval)
|
||||||
|
end):Spawn()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Start AWACS in a patrol pattern within the patrol zone
|
||||||
|
awacsSpawn:InitRepeatOnEngineShutDown()
|
||||||
|
:OnSpawnGroup(function(awacsGroup)
|
||||||
|
if not awacsGroup then
|
||||||
|
DebugMessage("ERROR: AWACS group failed to spawn.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
DebugMessage("AWACS spawned: " .. awacsGroup:GetName())
|
||||||
|
Announce("AWACS is now airborne and patrolling.", "awacs_spawn.ogg")
|
||||||
|
|
||||||
|
-- Create a patrol task for the AWACS in the defined zone
|
||||||
|
local patrolTask = AI_PATROL_ZONE:New(patrolZone, patrolAltMin, patrolAltMax)
|
||||||
|
patrolTask:SetControllable(awacsGroup)
|
||||||
|
patrolTask:__Start(1)
|
||||||
|
DebugMessage("Patrol task assigned to AWACS.")
|
||||||
|
|
||||||
|
-- Spawn and manage escorts
|
||||||
|
spawnEscort(escortGroup1Name, awacsGroup)
|
||||||
end)
|
end)
|
||||||
:Spawn()
|
:Spawn()
|
||||||
|
|
||||||
-- Spawn the first escort and attach to AWACS
|
-- Create a scheduled task to check if AWACS is alive and respawn if destroyed
|
||||||
local escort1 = SPAWN:New(escortGroup1)
|
SCHEDULER:New(nil, function()
|
||||||
:InitLimit(1, 0)
|
local awacsGroup = awacsSpawn:GetLastAliveGroup()
|
||||||
:OnSpawnGroup(function(escortGroup)
|
if not awacsGroup or not awacsGroup:IsAlive() then
|
||||||
-- Attach the escort to follow AWACS
|
DebugMessage("AWACS destroyed. Respawning...")
|
||||||
local awacsEscort1 = ESCORT:New(awacs, escortGroup)
|
Announce("AWACS has been destroyed! Respawning...", "awacs_destroyed.ogg")
|
||||||
awacsEscort1:Escort()
|
awacsSpawn:Spawn()
|
||||||
end)
|
end
|
||||||
:Spawn()
|
end, {}, 0, respawnCheckInterval)
|
||||||
|
|
||||||
-- Spawn the second escort and attach to AWACS
|
|
||||||
local escort2 = SPAWN:New(escortGroup2)
|
|
||||||
:InitLimit(1, 0)
|
|
||||||
:OnSpawnGroup(function(escortGroup)
|
|
||||||
-- Attach the second escort to follow AWACS
|
|
||||||
local awacsEscort2 = ESCORT:New(awacs, escortGroup)
|
|
||||||
awacsEscort2:Escort()
|
|
||||||
end)
|
|
||||||
:Spawn()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user