-- ***************************************************************************** -- ** Skynet Groups ** -- ********************************************************* function SpawnIADSDelayed(param) local parentMenu = param[1] local iadsConfig = param[2] local IADSObjectIndex = param[3] local delay = param[4] or 10 local difficulty = param[5] or "easy" MESSAGE:NewType(string.format("Warning, IADS [%s] Units %s will spawn in %d sec", difficulty, iadsConfig.name, delay), MESSAGE.Type.Update):ToAll() TIMER:New(SpawnIADSUnits, param):Start(delay) end function attachSAMSiteToSkynet(site, samGroupName, IADSObjectIndex, connectionNode) if type(site) == "string" then IADSArray[IADSObjectIndex].IADSObject:addSAMSite(samGroupName) IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(samGroupName):addConnectionNode(StaticObject.getByName(connectionNode)) elseif type(site) == "table" then IADSArray[IADSObjectIndex].IADSObject:addSAMSite(samGroupName) local skynetSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(samGroupName) skynetSam:addConnectionNode(StaticObject.getByName(connectionNode)) if (type(site.actAsEW) == "boolean") then jtff_log.info(string.format("actAsEW %s", tostring(site.actAsEW)),"IADS") skynetSam:setActAsEW(site.actAsEW) end if (type(site.harmDetectionChance) == "number") then jtff_log.info(string.format("HARM detection chance : %i", site.harmDetectionChance),"IADS") skynetSam:setHARMDetectionChance(site.harmDetectionChance) end if (type(site.goLiveRangePercent) == "number") then jtff_log.info(string.format("Go Live Range : %i perc", site.goLiveRangePercent),"IADS") skynetSam :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE) :setGoLiveRangeInPercent(site.goLiveRangePercent) else skynetSam :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE) end end end function attachPdSiteToSkynet(site, pdGroupName, samGroupName, IADSObjectIndex, connectionNode) local skynetSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(samGroupName) if (type(site.pointDefenses) == "string") then IADSArray[IADSObjectIndex].IADSObject:addSAMSite(pdGroupName) local skynetPdSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(pdGroupName) skynetPdSam:addConnectionNode(StaticObject.getByName(connectionNode)) if (type(site.pdactAsEw) == "boolean") then jtff_log.info(string.format("actAsEW %s", tostring(site.pdactAsEw)),"IADS") skynetPdSam:setActAsEW(site.pdactAsEw) end if (type(site.pdharmDetectionChance) == "number") then jtff_log.info(string.format("HARM detection chance : %i", site.pdharmDetectionChance),"IADS") skynetPdSam:setHARMDetectionChance(site.pdharmDetectionChance) end if (type(site.pdgoLiveRangePercent) == "number") then jtff_log.info(string.format("Go Live Range : %i perc", site.pdgoLiveRangePercent),"IADS") skynetPdSam :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE) :setGoLiveRangeInPercent(site.pdgoLiveRangePercent) else skynetPdSam :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE) end jtff_log.info(string.format("Point Defense Sam Group %s Defending SAM %s", pdGroupName, samGroupName),"IADS") skynetSam:addPointDefence(skynetPdSam) elseif (type(site.pointDefenses) == "table") then IADSArray[IADSObjectIndex].IADSObject:addSAMSite(pdGroupName) local skynetPdSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(pdGroupName) skynetPdSam:addConnectionNode(StaticObject.getByName(connectionNode)) if (type(site.pdactAsEw) == "boolean") then jtff_log.info(string.format("actAsEW %s", tostring(site.pdactAsEw)),"IADS") skynetPdSam:setActAsEW(site.pdactAsEw) end if (type(site.pdharmDetectionChance) == "number") then jtff_log.info(string.format("HARM detection chance : %i", site.pdharmDetectionChance),"IADS") skynetPdSam:setHARMDetectionChance(site.pdharmDetectionChance) end if (type(site.pdgoLiveRangePercent) == "number") then jtff_log.info(string.format("Go Live Range : %i perc", site.pdgoLiveRangePercent),"IADS") skynetPdSam :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE) :setGoLiveRangeInPercent(site.pdgoLiveRangePercent) else skynetPdSam :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE) end jtff_log.info(string.format("Point Defense Sam Group %s Defending SAM %s", pdGroupName, samGroupName),"IADS") skynetSam:addPointDefence(skynetPdSam) end end function SpawnIADSUnits(param) local parentMenu = param[1] local iadsConfig = param[2] local IADSObjectIndex = param[3] local delay = param[4] local difficulty = param[5] local iadsName = iadsConfig.name local nodesConfig = iadsConfig.nodes local difficultyArray = {"easy","medium","hard","extreme"} local somethingAlreadySpawned = false for indexdiff, currentdifficulty in ipairs(difficultyArray) do somethingAlreadySpawned = somethingAlreadySpawned or IADSArray[IADSObjectIndex].spawned[currentdifficulty] end for nodeIndex, nodeConfig in ipairs(nodesConfig) do local connection = nodeConfig.connection if (type(connection) == "table") then if ( connection.type ~= nil and connection.category ~= nil and connection.name ~= nil ) then local spawnStatic spawnStatic = SPAWNSTATIC:NewFromType(connection.type, connection.category) if (connection.coalition ~= nil) then if (connection.coalition == coalition.side.BLUE) then spawnStatic = SPAWNSTATIC:NewFromType(connection.type, connection.category, country.id.CJTF_BLUE) elseif (connection.coalition == coalition.side.RED) then spawnStatic = SPAWNSTATIC:NewFromType(connection.type, connection.category, country.id.CJTF_RED) else spawnStatic = SPAWNSTATIC:NewFromType(connection.type, connection.category, country.id.UN_PEACEKEEPERS) end end jtff_log.info(string.format("Static type to spawn %s at %i,%i -> %s", connection.type, connection.x, connection.y, connection.name),"IADS") spawnStatic:SpawnFromPointVec2(POINT_VEC2:New(connection.x, connection.y), connection.heading, connection.name) else jtff_log.error(string.format("Static to spawn has no type, category, name or position!"),"IADS") end end local ewrList = nodeConfig.ewrs local siteList = nodeConfig.sites[difficulty] for ewrIndex, ewrGroup in ipairs(ewrList) do if (not(somethingAlreadySpawned)) then local groupNameToSpawn = string.format("%s", ewrGroup) if (GROUP:FindByName(groupNameToSpawn) ~= nil) then local spawnGroup = SPAWN:New(groupNameToSpawn) jtff_log.info(string.format("SPAWN EWR : %s", groupNameToSpawn),"IADS") local groupSpawning = spawnGroup:Spawn():OptionAlarmStateRed() else jtff_log.error(string.format("EWR GROUP to spawn %s not found in mission", groupNameToSpawn),"IADS") end end end local samGroupsSpawned = {} for siteIndex, site in ipairs(siteList) do if (type(site) == "string") then local groupNameToSpawn = string.format("%s", site) if (GROUP:FindByName(groupNameToSpawn) ~= nil) then local spawnGroup = SPAWN:New(groupNameToSpawn) jtff_log.info(string.format("SPAWN SAM : %s", groupNameToSpawn),"IADS") samGroupsSpawned[siteIndex] = spawnGroup:Spawn():OptionAlarmStateRed() --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then -- attachSAMSiteToSkynet(site, samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection) --end else jtff_log.error(string.format("SAM GROUP to spawn %s not found in mission", groupNameToSpawn),"IADS") end elseif (type(site) == "table") then jtff_log.debug(string.format("SAM in config file is table"),"IADS") if (site.staticsToSpawn ~= nil) then for index, staticToSpawn in ipairs(site.staticsToSpawn) do local spawnStatic = nil if (staticToSpawn.name ~= nil) then local staticNameToSpawn = string.format("%s", staticToSpawn.name) spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn) if (staticToSpawn.coalition ~= nil) then if (staticToSpawn.coalition == coalition.side.BLUE) then spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_BLUE) elseif (staticToSpawn.coalition == coalition.side.RED) then spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_RED) else spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.UN_PEACEKEEPERS) end end local x = staticToSpawn.x local y = staticToSpawn.y local heading = staticToSpawn.heading local name = string.format("%s_%s_%i", site.sam, staticNameToSpawn,index) local static = spawnStatic:SpawnFromPointVec2( POINT_VEC2:New( x, y ), heading, name ) jtff_log.info(string.format("Static %s to spawn at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()),"IADS") elseif (staticToSpawn.type ~= nil and staticToSpawn.category ~= nil) then local staticTypeToSpawn = string.format("%s", staticToSpawn.type) local staticCategoryToSpawn = string.format("%s", staticToSpawn.category) spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn) if (staticToSpawn.coalition ~= nil) then if (staticToSpawn.coalition == coalition.side.BLUE) then spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_BLUE) elseif (staticToSpawn.coalition == coalition.side.RED) then spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_RED) else spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.UN_PEACEKEEPERS) end end local x = staticToSpawn.x local y = staticToSpawn.y local heading = staticToSpawn.heading local name = string.format("%s_%s_%i", site.sam, staticTypeToSpawn, index) local static = spawnStatic:SpawnFromPointVec2( POINT_VEC2:New( x, y ), heading, name ) jtff_log.info(string.format("Static %s to spawn at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()),"IADS") else jtff_log.error(string.format("Static to spawn has no name or type!"),"IADS") end end end local groupNameToSpawn = string.format("%s", site.sam) if (GROUP:FindByName(groupNameToSpawn) ~= nil) then local spawnGroup = SPAWN:New(groupNameToSpawn) jtff_log.info(string.format("SPAWN SAM : %s", groupNameToSpawn),"IADS") samGroupsSpawned[siteIndex] = spawnGroup:Spawn():OptionAlarmStateRed() --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then -- attachSAMSiteToSkynet(site, samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection) --end else jtff_log.error(string.format("SAM GROUP to spawn %s not found in mission", groupNameToSpawn),"IADS") end if (type(site.pointDefenses) == "string") then local pdGroupNameToSpawn = string.format("%s", site.pointDefenses) if (GROUP:FindByName(pdGroupNameToSpawn) ~= nil) then local spawnGroup = SPAWN:New(pdGroupNameToSpawn) jtff_log.info(string.format("SPAWN SAM-PointDefense : %s", pdGroupNameToSpawn),"IADS") local pdSamGroupsSpawned = spawnGroup:Spawn():OptionAlarmStateRed() --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then -- attachPdSiteToSkynet(site, pdSamGroupsSpawned:GetName(), samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection) --end else jtff_log.error(string.format("SAM-PointDefense GROUP to spawn %s not found in mission", pdGroupNameToSpawn),"IADS") end elseif (type(site.pointDefenses) == "table") then local pdSamGroupsSpawned = {} for pdindex, pdSamGroup in ipairs(site.pointDefenses) do local pdGroupNameToSpawn = string.format("%s", pdSamGroup) if (GROUP:FindByName(pdGroupNameToSpawn) ~= nil) then local spawnGroup = SPAWN:New(pdGroupNameToSpawn) jtff_log.info(string.format("SPAWN SAM-PointDefense : %s", pdGroupNameToSpawn),"IADS") pdSamGroupsSpawned[pdindex] = spawnGroup:Spawn():OptionAlarmStateRed() --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then -- attachPdSiteToSkynet(site, pdSamGroupsSpawned[pdindex]:GetName(), samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection) --end else jtff_log.error(string.format("SAM-PointDefense GROUP to spawn %s not found in mission", pdGroupNameToSpawn),"IADS") end end end end end end IADSArray[IADSObjectIndex].spawned[difficulty] = true if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then local showStatusOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().IADSStatus local showContactsOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().contacts deactivateSkynet( {iadsConfig, IADSObjectIndex,parentMenu} ) activateSkynet( {iadsConfig, IADSObjectIndex,parentMenu} ) skynetUpdateDisplay({ IADSObjectIndex,'contacts',showContactsOption }) skynetUpdateDisplay({ IADSObjectIndex,'IADSStatus',showStatusOption }) end jtff_log.info(string.format("Spawn IADS : %s-[%s] DONE", iadsName, difficulty),"IADS") manageIADSNetworkMenu(parentMenu,iadsConfig,IADSObjectIndex) MESSAGE:NewType(string.format("IADS - IADS Units %s-[%s] in place", iadsName, difficulty), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition) end function deleteIADSNetwork(param) local iadsConfig = param[1] local IADSObjectIndex = param[2] local networkRootMenu = param[3] local iadsName = iadsConfig.name local nodesConfig = iadsConfig.nodes local skynetIADSObject = IADSArray[IADSObjectIndex].IADSObject local gciDispatcherObject = IADSArray[IADSObjectIndex].GCIDispatcherObject local difficultyArray = {"easy","medium","hard","extreme"} if (skynetIADSObject ~= nil and IADSArray[IADSObjectIndex].IADSNetworkRunning == true) then deactivateSkynet({ iadsConfig, IADSObjectIndex, networkRootMenu }) end if (gciDispatcherObject ~= nil and IADSArray[IADSObjectIndex].GCIRunning == true) then deactivateGCI({ iadsConfig, IADSObjectIndex, networkRootMenu }) end for index, difficulty in ipairs(difficultyArray) do param[4] = difficulty deleteIADSUnits(param) end IADSArray[IADSObjectIndex].IADSNetworkRunning = false IADSArray[IADSObjectIndex].GCIRunning = false MESSAGE:NewType(string.format("IADS - Remove IADS : %s", iadsName), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition) manageIADSNetworkMenu(networkRootMenu, iadsConfig, IADSObjectIndex) end function deactivateSkynet(param) local iadsConfig = param[1] local IADSObjectIndex = param[2] local parentMenu = param[3] IADSArray[IADSObjectIndex].IADSObject:deactivate() IADSArray[IADSObjectIndex].IADSNetworkRunning = false manageIADSNetworkMenu(parentMenu, iadsConfig, IADSObjectIndex) MESSAGE:NewType(string.format("IADS - Skynet of %s is desactivated", iadsConfig.name), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition) end function skynetUpdateDisplay(param) local IADSObjectIndex = param[1] local option = param[2] local value = param[3] IADSArray[IADSObjectIndex].IADSObject.updateDisplay({ option = option, self = IADSArray[IADSObjectIndex].IADSObject, value = value }) end function deactivateGCI(param) local iadsConfig = param[1] local IADSObjectIndex = param[2] local parentMenu = param[3] jtff_log.info(string.format("GCI De-activation for %s", iadsConfig.name),"IADS") IADSArray[IADSObjectIndex].GCIDispatcherObject:Stop() IADSArray[IADSObjectIndex].GCIRunning = false manageIADSNetworkMenu(parentMenu, iadsConfig, IADSObjectIndex) end function activateGCI(param) local iadsConfig = param[1] local IADSObjectIndex = param[2] local parentMenu = param[3] jtff_log.info(string.format("GCI activation for %s", iadsConfig.name),"IADS") if (IADSArray[IADSObjectIndex].GCIDispatcherObject ~= nil) then IADSArray[IADSObjectIndex].GCIDispatcherObject:Start() else DetectionSetGroup = SET_GROUP:New() IADSArray[IADSObjectIndex].IADSObject:addMooseSetGroup(DetectionSetGroup) IADSArray[IADSObjectIndex].GCIDetectionArea = DETECTION_AREAS:New( DetectionSetGroup, 30000 ) IADSArray[IADSObjectIndex].GCIDispatcherObject = AI_A2A_DISPATCHER:New( IADSArray[IADSObjectIndex].GCIDetectionArea ) IADSArray[IADSObjectIndex].GCIDispatcherObject:SetEngageRadius() -- 100000 is the default value. if (iadsConfig.gci_engage_radius) then IADSArray[IADSObjectIndex].GCIDispatcherObject:SetGciRadius(iadsConfig.gci_engage_radius) else IADSArray[IADSObjectIndex].GCIDispatcherObject:SetGciRadius() end CCCPBorderZone = ZONE_POLYGON:New( iadsConfig.gci_border , GROUP:FindByName( iadsConfig.gci_border ) ) IADSArray[IADSObjectIndex].GCIDispatcherObject:SetBorderZone( CCCPBorderZone ) IADSArray[IADSObjectIndex].GCIDispatcherObject:SetDefaultTakeoffFromRunway() IADSArray[IADSObjectIndex].GCIDispatcherObject:SetDefaultLandingAtRunway() for index, gci_group in ipairs(iadsConfig.gci) do gci_group_name = string.format("GCI_%s", gci_group.airport) jtff_log.info(string.format("GCI - Group %s", gci_group_name),"IADS") IADSArray[IADSObjectIndex].GCIDispatcherObject:SetSquadron( gci_group_name, gci_group.airport, gci_group.templatePrefixes, gci_group.numberOfAircraftAvailable ) IADSArray[IADSObjectIndex].GCIDispatcherObject:SetSquadronGci( gci_group_name, 1000, 3000 ) end end IADSArray[IADSObjectIndex].GCIRunning = true manageIADSNetworkMenu(parentMenu, iadsConfig, IADSObjectIndex) MESSAGE:NewType(string.format("IADS - GCI of %s is activated", iadsConfig.name), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition) end function activateSkynet(param) local iadsConfig = param[1] local IADSObjectIndex = param[2] local parentMenu = param[3] local difficultyArray = {"easy","medium","hard","extreme"} jtff_log.info(string.format("Skynet activation for %s", iadsConfig.name),"IADS") -- create an instance of the IADS IADSArray[IADSObjectIndex].IADSObject = SkynetIADS:create(iadsConfig.name) ---debug settings remove from here on if you do not wan't any output on what the IADS is doing by default local iadsDebug = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings() local DEBUG_IADS if log_levels[JTFF_LOGLEVEL] <= log_levels['debug'] then DEBUG_IADS=true else DEBUG_IADS=false end iadsDebug.IADSStatus = DEBUG_IADS iadsDebug.radarWentDark = DEBUG_IADS iadsDebug.contacts = DEBUG_IADS iadsDebug.radarWentLive = DEBUG_IADS iadsDebug.noWorkingCommmandCenter = DEBUG_IADS iadsDebug.ewRadarNoConnection = DEBUG_IADS iadsDebug.samNoConnection = DEBUG_IADS iadsDebug.jammerProbability = DEBUG_IADS iadsDebug.addedEWRadar = DEBUG_IADS iadsDebug.hasNoPower = DEBUG_IADS iadsDebug.harmDefence = DEBUG_IADS iadsDebug.samSiteStatusEnvOutput = DEBUG_IADS iadsDebug.earlyWarningRadarStatusEnvOutput = DEBUG_IADS iadsDebug.commandCenterStatusEnvOutput = DEBUG_IADS ---end remove debug --- -- add a command center: for index, headQuarter in ipairs(iadsConfig.headQuarter) do local commandCenter = StaticObject.getByName(headQuarter) IADSArray[IADSObjectIndex].IADSObject:addCommandCenter(commandCenter) end for index, node in ipairs(iadsConfig.nodes) do local connectionName = "" if (type(node.connection) == "string") then connectionName = node.connection else connectionName = node.connection.name end jtff_log.info(string.format("Connection Node %s", connectionName),"IADS") local connectionNode = StaticObject.getByName(connectionName) for index, ewr in ipairs(node.ewrs) do if (ewr ~= nil and connectionNode ~= nil) then jtff_log.info(string.format("EWR Unit name in config file : %s", ewr),"IADS") local set_ewr_units = SET_UNIT:New():FilterPrefixes(ewr):FilterOnce() set_ewr_units:ForEachUnit(function(ewr_alive) if ewr_alive:IsAlive() then jtff_log.info(string.format("Alive EWR Unit name found %s", ewr_alive:Name()),"IADS") IADSArray[IADSObjectIndex].IADSObject:addEarlyWarningRadar(ewr_alive:Name()) IADSArray[IADSObjectIndex].IADSObject:getEarlyWarningRadarByUnitName(ewr_alive:Name()):addConnectionNode(connectionNode) end end) end end for indexdiff, difficulty in ipairs(difficultyArray) do if IADSArray[IADSObjectIndex].spawned[difficulty] then for siteIndex, site in ipairs(node.sites[difficulty]) do if (site ~= nil and connectionNode ~= nil) then if (type(site) == "string") then jtff_log.info(string.format("Sam Group name in config file : %s", site),"IADS") local set_group_alive = SET_GROUP:New():FilterPrefixes(site):FilterOnce() set_group_alive:ForEachGroupAlive(function(group_alive) jtff_log.info(string.format("Alive Sam Group found %s", group_alive:GetName()),"IADS") attachSAMSiteToSkynet(site, group_alive:GetName(), IADSObjectIndex, connectionName) end) elseif (type(site) == "table") then jtff_log.info(string.format("Sam Group name in config file : %s", site.sam),"IADS") local set_group_alive = SET_GROUP:New():FilterPrefixes(site.sam):FilterOnce() set_group_alive:ForEachGroupAlive(function(samGroupAlive) jtff_log.info(string.format("Alive Sam Group found %s", samGroupAlive:GetName()),"IADS") attachSAMSiteToSkynet(site, samGroupAlive:GetName(), IADSObjectIndex, connectionName) if (type(site.pointDefenses) == "string") then local set_pdgroup_alive = SET_GROUP:New():FilterPrefixes(site.pointDefenses):FilterOnce() set_pdgroup_alive:ForEachGroupAlive(function(pdGroupAlive) jtff_log.info(string.format("Alive Point Defense Sam Group found %s", pdGroupAlive:GetName()),"IADS") attachPdSiteToSkynet(site,pdGroupAlive:GetName(), samGroupAlive:GetName(), IADSObjectIndex, connectionName) end) elseif (type(site.pointDefenses) == "table") then for pdIndex, pdSamGroupName in ipairs(site.pointDefenses) do jtff_log.info(string.format("Point Defense Sam Group name in config file : %s", pdSamGroupName),"IADS") local set_pdgroup_alive = SET_GROUP:New():FilterPrefixes(pdSamGroupName):FilterOnce() set_pdgroup_alive:ForEachGroupAlive(function(pdGroupAlive) jtff_log.info(string.format("Alive Point Defense Sam Group found %s", pdGroupAlive:GetName()),"IADS") attachPdSiteToSkynet(site,pdGroupAlive:GetName(), samGroupAlive:GetName(), IADSObjectIndex, connectionName) end) end end end) end end end end end end -- activate the radio menu to toggle IADS Status output --if (iadsConfig.radioMenu) then -- jtff_log.trace(string.format("Add radio menu %s", iadsConfig.name),"IADS") -- IADSArray[IADSObjectIndex].IADSObject:addRadioMenu() --end -- activate the IADS IADSArray[IADSObjectIndex].IADSObject:activate() IADSArray[IADSObjectIndex].IADSNetworkRunning = true manageIADSNetworkMenu(parentMenu, iadsConfig, IADSObjectIndex) MESSAGE:NewType(string.format("Skynet of %s activate in 60 secondes", iadsConfig.name), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition) end function deleteIADSUnits(param) local iadsConfig = param[1] local IADSObjectIndex = param[2] local parentMenu = param[3] local difficulty = param[4] local iadsName = iadsConfig.name local nodesConfig = iadsConfig.nodes local difficultyArray = {"easy","medium","hard","extreme"} local difficultiesAlreadySpawned = 0 for indexdiff, currentdifficulty in ipairs(difficultyArray) do if (IADSArray[IADSObjectIndex].spawned[currentdifficulty]) then difficultiesAlreadySpawned = difficultiesAlreadySpawned + 1 end end for index, nodeConfig in ipairs(nodesConfig) do local connection = nodeConfig.connection destroyStatic(connection) local ewrList = nodeConfig.ewrs if (difficultiesAlreadySpawned <= 1) then for index, ewrGroup in ipairs(ewrList) do local groupNameToDelete = string.format("%s", ewrGroup) destroyGroup(groupNameToDelete) end end local sitesList = nodeConfig.sites[difficulty] for siteindex, site in ipairs(sitesList) do if (type(site) == "string") then local groupNameToDelete = string.format("%s", site) destroyGroup(groupNameToDelete) elseif (type(site) == "table") then local groupNameToDelete = string.format("%s", site.sam) destroyGroup(groupNameToDelete) end if (type( site.staticsToSpawn) == "table") then destroyStatics(site.staticsToSpawn, site.sam) end if (type(site.pointDefenses) == "string") then local groupNameToDelete = string.format("%s", site.pointDefenses) destroyGroup(groupNameToDelete) elseif (type(site.pointDefenses) == "table") then for pdIndex, pdSamGroupName in ipairs(site.pointDefenses) do local groupNameToDelete = string.format("%s", pdSamGroupName) destroyGroup(groupNameToDelete) end end end end IADSArray[IADSObjectIndex].spawned[difficulty] = false if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then local showStatusOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().IADSStatus local showContactsOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().contacts deactivateSkynet( {iadsConfig, IADSObjectIndex,parentMenu} ) activateSkynet( {iadsConfig, IADSObjectIndex,parentMenu} ) skynetUpdateDisplay({ IADSObjectIndex,'contacts',showContactsOption }) skynetUpdateDisplay({ IADSObjectIndex,'IADSStatus',showStatusOption }) end manageIADSNetworkMenu(parentMenu,iadsConfig,IADSObjectIndex) end function manageIADSNetworkMenu(networkRootMenu, iadsconfig, IADSObjectIndex) local difficultyArray = {"easy","medium","hard","extreme"} local anyDifficultySpawned = false local skynetIADSObject = IADSArray[IADSObjectIndex].IADSObject for index, difficulty in ipairs(difficultyArray) do anyDifficultySpawned = anyDifficultySpawned or IADSArray[IADSObjectIndex].spawned[difficulty] end networkRootMenu:RemoveSubMenus() if (anyDifficultySpawned) then --Il y a au moins 1 groupe de difficulté spawné : on affiche les menus skynet Ad-Hoc local CommandIADSDetroy = MENU_MISSION_COMMAND:New( "[Whole IADS Network] Delete", networkRootMenu, deleteIADSNetwork, { iadsconfig, IADSObjectIndex, networkRootMenu } ) if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then --Le reseau tourne déjà, on affiche le menu de desactivation du reseau et les menus de troubleshooting local CommandIADSShowStatus = MENU_MISSION_COMMAND:New( "Show IADS Status", networkRootMenu, skynetUpdateDisplay, { IADSObjectIndex, 'IADSStatus', true } ) local CommandIADSHideStatus = MENU_MISSION_COMMAND:New( "Hide IADS Status", networkRootMenu, skynetUpdateDisplay, { IADSObjectIndex, 'IADSStatus', false } ) local CommandIADSShowContacts = MENU_MISSION_COMMAND:New( "Show contacts", networkRootMenu, skynetUpdateDisplay, { IADSObjectIndex, 'contacts', true } ) local CommandIADSHideContacts = MENU_MISSION_COMMAND:New( "Hide contacts", networkRootMenu, skynetUpdateDisplay, { IADSObjectIndex, 'contacts', false } ) local CommandIADSDisable = MENU_MISSION_COMMAND:New( "Disable Skynet", networkRootMenu, deactivateSkynet, { iadsconfig, IADSObjectIndex, networkRootMenu } ) --TODO: A tweaker pour que les objets skynets seront basés sur la coalition et non sur la mission globale if (type(iadsconfig.gci) == "table") then if (IADSArray[IADSObjectIndex].GCIRunning) then local CommandGCIDeActivate = MENU_MISSION_COMMAND:New( "GCI Unactivation", networkRootMenu, deactivateGCI, { iadsconfig, IADSObjectIndex, networkRootMenu } ) else local CommandGCIActivate = MENU_MISSION_COMMAND:New( "GCI Activation", networkRootMenu, activateGCI, { iadsconfig, IADSObjectIndex, networkRootMenu } ) end end else --On affiche le menu d activation skynet local CommandIADSActivate = MENU_MISSION_COMMAND:New("Skynet Activation", networkRootMenu, activateSkynet, { iadsconfig, IADSObjectIndex, networkRootMenu }) end end for index, difficulty in ipairs(difficultyArray) do if IADSArray[IADSObjectIndex].spawned[difficulty] then local CommandIADSDetroyEasy = MENU_MISSION_COMMAND:New( "[" .. difficulty .. "] Delete", networkRootMenu, deleteIADSUnits, { iadsconfig, IADSObjectIndex, networkRootMenu, difficulty } ) else local isThereSomethingToSpawn = false for indexnodes, nodeconfig in ipairs(iadsconfig.nodes) do local tbl_json_txt = net.lua2json(nodeconfig.sites[difficulty]) --jtff_log.debug(string.format('network=%s node=%s difficulty=%s sites config=%s', iadsconfig.name, nodeconfig.connection, difficulty, tbl_json_txt),"IADS") local difficultySiteNumberToSpawn = 0 for indexsite, siteconfig in ipairs(nodeconfig.sites[difficulty]) do difficultySiteNumberToSpawn = indexsite if indexsite >= 1 then isThereSomethingToSpawn = true end end if (type(nodeconfig.connection) == "string") then jtff_log.info(string.format('network=%s node=%s difficulty=%s sites number=%d', iadsconfig.name, nodeconfig.connection, difficulty, difficultySiteNumberToSpawn),"IADS") else jtff_log.info(string.format('network=%s node=%s difficulty=%s sites number=%d', iadsconfig.name, nodeconfig.connection.name, difficulty, difficultySiteNumberToSpawn),"IADS") end end if isThereSomethingToSpawn then local RadioCommandAddDifficulty = MENU_MISSION_COMMAND:New( "[" .. difficulty .. "] Spawn", networkRootMenu, SpawnIADSDelayed, { networkRootMenu, iadsconfig, IADSObjectIndex, spawnStandardDelay, difficulty} ) end end end end function addExtraSamTypeDB() samTypesDB['FPS-117'] = { ['type'] = 'ewr', ['searchRadar'] = { ['FPS-117'] = { ['name'] = { ['NATO'] = 'Seek Igloo', }, }, }, ['harm_detection_chance'] = 60 } samTypesDB['FPS-117 Dome'] = { ['type'] = 'ewr', ['searchRadar'] = { ['FPS-117 Dome'] = { ['name'] = { ['NATO'] = 'Seek Igloo', }, }, }, ['harm_detection_chance'] = 60 } samTypesDB['EWR P-37 BAR LOCK'] = { ['type'] = 'ewr', ['searchRadar'] = { ['EWR P-37 BAR LOCK'] = { ['name'] = { ['NATO'] = 'Bar lock', }, }, }, ['harm_detection_chance'] = 60 } samTypesDB['EWR 55G6U NEBO-U'] = { ['type'] = 'ewr', ['searchRadar'] = { ['EWR 55G6U NEBO-U'] = { ['name'] = { ['NATO'] = 'Nebo-U', }, }, }, ['harm_detection_chance'] = 65 } samTypesDB['EWR 1L119 Nebo-SVU'] = { ['type'] = 'ewr', ['searchRadar'] = { ['EWR 1L119 Nebo-SVU'] = { ['name'] = { ['NATO'] = 'Nebo-SVU', }, }, }, ['harm_detection_chance'] = 75 } samTypesDB['EWR Generic radar tower'] = { ['type'] = 'ewr', ['searchRadar'] = { ['EWR Generic radar tower'] = { ['name'] = { ['NATO'] = 'EWR Generic radar tower', }, }, }, ['harm_detection_chance'] = 60 } end IADSArray = {} compteur = 0 mainRadioMenuForSkynet = MENU_MISSION:New("Skynet-IADS", nil ) addExtraSamTypeDB() for index, skynetconfig in ipairs(SkynetConfig) do if ( skynetconfig.enable ) then compteur = compteur + 1 env.info('Ajout menu radio pour IADS Skynet : '.. skynetconfig.name..'...') IADSArray[compteur] = { customconfig = skynetconfig, IADSObject = nil, spawned = { easy = false, medium = false, hard = false, extreme = false, }, IADSNetworkRunning = false, GCIRunning = false, GCIDetectionArea = nil, GCIDispatcherObject = nil, radioMenuForSkynet = MENU_MISSION:New(skynetconfig.name , mainRadioMenuForSkynet) } manageIADSNetworkMenu(IADSArray[compteur].radioMenuForSkynet, skynetconfig, compteur) end end