FlightControl-Master / MOOSE

Mission Object Oriented Scripting Environment (MOOSE) for lua mission scripting design in DCS World
http://flightcontrol-master.github.io/MOOSE/
GNU General Public License v3.0
292 stars 94 forks source link

Same STN with SPAWN Templates #2102

Closed Maloschnikow closed 4 months ago

Maloschnikow commented 5 months ago

Hey, when using the following script

battlefieldAirInterdiction = {}

battlefieldAirInterdiction.version = 1.9
trigger.action.outText('battlefieldAirInterdiction Script v' .. tostring(battlefieldAirInterdiction.version) .. ' loaded.', 5)
env.info('battlefieldAirInterdiction Script v' .. tostring(battlefieldAirInterdiction.version) .. ' loaded.', false)

--SETUP BLUE
do
    -- Init detectionSet
    DetectionSetGroupBLUE = SET_GROUP:New():FilterPrefixes("blueEWR"):FilterStart()

    -- Init dispatching
    DetectionBLUE = DETECTION_UNITS:New( DetectionSetGroupBLUE )
    A2ADispatcherBLUE = AI_A2A_DISPATCHER:New( DetectionBLUE )

    -- Configure dispatch zone with Heli
    BLUEBorderZone = ZONE_POLYGON:New( "BLUE Border", GROUP:FindByName( "blueBorder" ) )
    A2ADispatcherBLUE:SetBorderZone( BLUEBorderZone )
    A2ADispatcherBLUE:SetDefaultOverhead( 2 )

    -- Set takeoff and landing behaviour
    A2ADispatcherBLUE:SetDefaultTakeoffFromParkingCold()
    A2ADispatcherBLUE:SetDefaultLandingAtRunway()

    -- Init CAP flight Al Ain
    A2ADispatcherBLUE:SetSquadron( "Al Ain", AIRBASE.PersianGulf.Al_Ain_International_Airport, { "SQ F-15-1" }, 10 )
    A2ADispatcherBLUE:SetSquadronCap( "Al Ain", ZONE:New( "bluePatrolZone1" ), 6000, 9000, 650, 800, 900, 1200, "BARO" ) -- 6000m min alt, 10000m max alt, 550 min patrol speed, 800 max patrol speed, 900 min intercept speed, 1200 max intercept speed
    A2ADispatcherBLUE:SetSquadronCapInterval( "Al Ain", 2, 240, 480)
    A2ADispatcherBLUE:SetSquadronFuelThreshold( "Al Ain", 0.5 )

    -- Init CAP flight Al Moktoum Intl
    A2ADispatcherBLUE:SetSquadron( "Al Moktoum Intl", AIRBASE.PersianGulf.Al_Maktoum_Intl, { "SQ M2000C-1" }, 10 )
    A2ADispatcherBLUE:SetSquadronCap( "Al Moktoum Intl", ZONE:New( "bluePatrolZone2" ), 6000, 9000, 650, 800, 900, 1200, "BARO" ) -- 6000m min alt, 10000m max alt, 550 min patrol speed, 800 max patrol speed, 900 min intercept speed, 1200 max intercept speed
    A2ADispatcherBLUE:SetSquadronCapInterval( "Al Moktoum Intl", 2, 240, 480)
    A2ADispatcherBLUE:SetSquadronFuelThreshold( "Al Moktoum Intl", 0.5 )

    -- Start detection
    DetectionBLUE:Start()

end 

--SETUP RED
do
    -- Init detectionSet
    DetectionSetGroupRED = SET_GROUP:New():FilterPrefixes("redEWR"):FilterStart()

    -- Init dispatching
    DetectionRED = DETECTION_UNITS:New( DetectionSetGroupRED )
    A2ADispatcherRED = AI_A2A_DISPATCHER:New( DetectionRED )

    -- Configure dispatch zone with Heli
    REDBorderZone = ZONE_POLYGON:New( "RED Border", GROUP:FindByName( "redBorder" ) )
    A2ADispatcherRED:SetBorderZone( REDBorderZone )
    A2ADispatcherRED:SetDefaultOverhead( 2 )

    -- Set takeoff and landing behaviour
    A2ADispatcherRED:SetDefaultTakeoffFromParkingCold()
    A2ADispatcherRED:SetDefaultLandingAtRunway()

    -- Init CAP flight Lar
    A2ADispatcherRED:SetSquadron( "Shiraz 1", AIRBASE.PersianGulf.Shiraz_International_Airport, { "SQ MiG-29S-1" }, 10 )
    A2ADispatcherRED:SetSquadronCap( "Shiraz 1", ZONE:New( "redPatrolZone1" ), 6000, 9000, 600, 800, 900, 1200, "BARO" )
    A2ADispatcherRED:SetSquadronCapInterval( "Shiraz 1", 2, 240, 480)
    A2ADispatcherRED:SetSquadronFuelThreshold( "Shiraz 1", 0.5 )

    -- Init CAP flight Lar
    A2ADispatcherRED:SetSquadron( "Lar 1", AIRBASE.PersianGulf.Lar_Airbase, { "SQ Su-27-1" }, 10 )
    A2ADispatcherRED:SetSquadronCap( "Lar 1", ZONE:New( "redPatrolZone2" ), 6000, 9000, 600, 800, 900, 1200, "BARO" )
    A2ADispatcherRED:SetSquadronCapInterval( "Lar 1", 2, 240, 480)
    A2ADispatcherRED:SetSquadronFuelThreshold( "Lar 1", 0.5 )

    -- Init CAP flight Jiroft
    A2ADispatcherRED:SetSquadron( "Jiroft 1", AIRBASE.PersianGulf.Jiroft_Airport, { "SQ MiG-31-1" }, 10 )
    A2ADispatcherRED:SetSquadronCap( "Jiroft 1", ZONE:New( "redPatrolZone3" ), 6000, 9000, 600, 800, 900, 1200, "BARO" )
    A2ADispatcherRED:SetSquadronCapInterval( "Jiroft 1", 2, 240, 480)
    A2ADispatcherRED:SetSquadronFuelThreshold( "Jiroft 1", 0.5 )

    -- Start detection
    DetectionRED:Start()

end

the all Units spawned will have the same STN, which results in fluctuating HAFU symbols on the SA page in, but not only, the Hornet. Maybe there is a way to assign a new different STN, which isn't already used. For a workaround the only solution that comes to mind is setting the squadrons to spawn only 1 unit with an interval big enough, that the unit doesn't respawn before the old one despawns. I guess reason for this is the SPAWN function (I guess this function is used in the A2ADispatcher) Hope I described the issue properly ^^

Applevangelist commented 5 months ago

That’s a tricky one bc we’d need to centralize the use of S/TNs across the mission for SPAWN. Needs a think.

Applevangelist commented 5 months ago

Ready for testing in the current build