Skip to content

Commit

Permalink
Merge pull request #25 from walder/develop
Browse files Browse the repository at this point in the history
merge Develop with master
  • Loading branch information
walder authored Jul 31, 2020
2 parents e773c59 + 8913536 commit 7a0a2cf
Show file tree
Hide file tree
Showing 21 changed files with 897 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
demo-missions/in development dont use/
bin
.DS_STORE
133 changes: 65 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,70 @@ Visit [this DCS forum thread](https://forums.eagle.ru/showthread.php?p=4221918)

Join the [Skynet discord group](https://discord.gg/pz8wcQs) and get support setting up your mission.

Table of Contents
=================

* [Skynet\-IADS](#skynet-iads)
* [Abstract](#abstract)
* [Table of Contents](#table-of-contents)
* [Quick start](#quick-start)
* [Skynet IADS Elements](#skynet-iads-elements)
* [IADS](#iads)
* [Track files](#track-files)
* [Comand Centers](#comand-centers)
* [SAM Sites](#sam-sites)
* [Early Warning Radars](#early-warning-radars)
* [Power Sources](#power-sources)
* [Connection Nodes](#connection-nodes)
* [AWACS (Airborne Early Warning and Control System)](#awacs-airborne-early-warning-and-control-system)
* [Ships](#ships)
* [Tactics](#tactics)
* [HARM defence](#harm-defence)
* [Point defence](#point-defence)
* [Electronic Warfare](#electronic-warfare)
* [Using Skynet in the mission editor](#using-skynet-in-the-mission-editor)
* [Placing units](#placing-units)
* [Preparing a SAM site](#preparing-a-sam-site)
* [Preparing an EW radar](#preparing-an-ew-radar)
* [Adding the Skynet Code](#adding-the-skynet-code)
* [Setting up yor IADS](#setting-up-yor-iads)
* [Adding the Skynet IADS](#adding-the-skynet-iads)
* [Advanced setup](#advanced-setup)
* [IADS configuration](#iads-configuration)
* [Warm up the SAM sites of an IADS](#warm-up-the-sam-sites-of-an-iads)
* [Adding a command center](#adding-a-command-center)
* [Connecting Skynet to the MOOSE AI\_A2A\_DISPATCHER](#connecting-skynet-to-the-moose-ai_a2a_dispatcher)
* [SAM site configuration](#sam-site-configuration)
* [Adding SAM sites](#adding-sam-sites)
* [Add multiple SAM sites](#add-multiple-sam-sites)
* [Add a SAM site manually](#add-a-sam-site-manually)
* [Accessing SAM sites in the IADS](#accessing-sam-sites-in-the-iads)
* [Act as EW radar](#act-as-ew-radar)
* [Engagement zone](#engagement-zone)
* [Engagement zone options](#engagement-zone-options)
* [EW radar configuration](#ew-radar-configuration)
* [Adding EW radars](#adding-ew-radars)
* [Add multiple EW radars](#add-multiple-ew-radars)
* [Add an EW radar manually](#add-an-ew-radar-manually)
* [Accessing EW radars in the IADS](#accessing-ew-radars-in-the-iads)
* [Options for SAM sites and EW radars](#options-for-sam-sites-and-ew-radars)
* [Setting an option](#setting-an-option)
* [Daisy chaining options](#daisy-chaining-options)
* [Power sources and connection nodes](#power-sources-and-connection-nodes)
* [HARM Defence](#harm-defence-1)
* [Point defence](#point-defence-1)
* [Autonomous mode behaviour](#autonomous-mode-behaviour)
* [Autonomous mode options](#autonomous-mode-options)
* [Adding a jammer](#adding-a-jammer)
* [Advanced functions](#advanced-functions)
* [Setting debug information](#setting-debug-information)
* [Example Setup](#example-setup)
* [FAQ](#faq)
* [What air defence units shall I add to the Skynet IADS?](#what-air-defence-units-shall-i-add-to-the-skynet-iads)
* [What exactly does Skynet do with the SAMS?](#what-exactly-does-skynet-do-with-the-sams)
* [Are there known bugs?](#are-there-known-bugs)
* [How do I know if a SAM site is in range of an EW site or a SAM site in EW mode?](#how-do-i-know-if-a-sam-site-is-in-range-of-an-ew-site-or-a-sam-site-in-ew-mode)
* [How do I connect Skynet with the MOOSE AI\_A2A\_DISPATCHER and what are the benefits of that?](#how-do-i-connect-skynet-with-the-moose-ai_a2a_dispatcher-and-what-are-the-benefits-of-that)
* [Thanks](#thanks)
Table of Contents
=================
* [Skynet\-IADS](#skynet-iads)
* [Abstract](#abstract)
* [Quick start](#quick-start)
* [Skynet IADS Elements](#skynet-iads-elements)
* [IADS](#iads)
* [Track files](#track-files)
* [Comand Centers](#comand-centers)
* [SAM Sites](#sam-sites)
* [Early Warning Radars](#early-warning-radars)
* [Power Sources](#power-sources)
* [Connection Nodes](#connection-nodes)
* [AWACS (Airborne Early Warning and Control System)
](#awacs-airborne-early-warning-and-control-system)
* [Ships](#ships)
* [Tactics](#tactics)
* [HARM defence](#harm-defence)
* [Point defence](#point-defence)
* [Electronic Warfare](#electronic-warfare)
* [Using Skynet in the mission editor](#using-skynet-in-the-mission-editor)
* [Placing units](#placing-units)
* [Preparing a SAM site](#preparing-a-sam-site)
* [Preparing an EW radar](#preparing-an-ew-radar)
* [Adding the Skynet Code](#adding-the-skynet-code)
* [Adding the Skynet IADS](#adding-the-skynet-iads)
* [Advanced setup](#advanced-setup)
* [IADS configuration](#iads-configuration)
* [Warm up the SAM sites of an IADS](#warm-up-the-sam-sites-of-an-iads)
* [Adding a command center](#adding-a-command-center)
* [Connecting Skynet to the MOOSE AI\_A2A\_DISPATCHER](#connecting-skynet-to-the-moose-ai_a2a_dispatcher)
* [SAM site configuration](#sam-site-configuration)
* [Adding SAM sites](#adding-sam-sites)
* [Add multiple SAM sites](#add-multiple-sam-sites)
* [Add a SAM site manually](#add-a-sam-site-manually)
* [Accessing SAM sites in the IADS](#accessing-sam-sites-in-the-iads)
* [Act as EW radar](#act-as-ew-radar)
* [Engagement zone](#engagement-zone)
* [Engagement zone options](#engagement-zone-options)
* [EW radar configuration](#ew-radar-configuration)
* [Adding EW radars](#adding-ew-radars)
* [Add multiple EW radars](#add-multiple-ew-radars)
* [Add an EW radar manually](#add-an-ew-radar-manually)
* [Accessing EW radars in the IADS](#accessing-ew-radars-in-the-iads)
* [Options for SAM sites and EW radars](#options-for-sam-sites-and-ew-radars)
* [Setting an option](#setting-an-option)
* [Daisy chaining options](#daisy-chaining-options)
* [Power sources and connection nodes](#power-sources-and-connection-nodes)
* [HARM Defence](#harm-defence-1)
* [Point defence](#point-defence-1)
* [Autonomous mode behaviour](#autonomous-mode-behaviour)
* [Autonomous mode options](#autonomous-mode-options)
* [Adding a jammer](#adding-a-jammer)
* [Advanced functions](#advanced-functions)
* [Setting debug information](#setting-debug-information)
* [Example Setup](#example-setup)
* [FAQ](#faq)
* [What air defence units shall I add to the Skynet IADS?](#what-air-defence-units-shall-i-add-to-the-skynet-iads)
* [What exactly does Skynet do with the SAMS?](#what-exactly-does-skynet-do-with-the-sams)
* [Are there known bugs?](#are-there-known-bugs)
* [How do I know if a SAM site is in range of an EW site or a SAM site in EW mode?](#how-do-i-know-if-a-sam-site-is-in-range-of-an-ew-site-or-a-sam-site-in-ew-mode)
* [How do I connect Skynet with the MOOSE AI\_A2A\_DISPATCHER and what are the benefits of that?](#how-do-i-connect-skynet-with-the-moose-ai_a2a_dispatcher-and-what-are-the-benefits-of-that)
* [Thanks](#thanks)


# Quick start
Tired of reading already? Download the [demo mission](/demo-missions/skynet-test-persian-gulf.miz) in the persian gulf map and see Skynet in action. More complex demo missions will follow soon.
Expand Down Expand Up @@ -215,12 +214,10 @@ You can use any type of radar as an EW radar. Make sure you **name the unit** in
## Adding the Skynet Code
Skynet requires MIST. A version is provided in this repository or you can download the most current version [here](https://github.com/mrSkortch/MissionScriptingTools).
Make sure you load MIST and the compiled skynet code in to a mission. The [skynet-iads-compiled.lua](/demo-missions/skynet-iads-compiled.lua) and [mist_4_3_74.lua](/demo-missions/mist_4_3_74.lua) files are located in the [/demo-missions/](/master/demo-missions) folder.
![Mission Editor IADS Setup](/images/load-scripts.png)

## Setting up yor IADS
I recommend you create a text file e.g. 'my-iads-setup.lua' and then add the code needed to get the IADS runing. When updating the setup remember to reload the file in the mission editor. Otherwise changes will not become effective.
You can also add the code directly in the mission editor, however that input field is quite small if you write more than a few lines of code.
![Mission Editor IADS Setup](/images/iads-setup-code.png)
![Mission Editor IADS Setup](/images/load-scripts.png)

## Adding the Skynet IADS
For the IADS to work you need four lines of code.
Expand Down
Binary file added build-tools/bin/gh-md-toc.exe
Binary file not shown.
38 changes: 38 additions & 0 deletions build-tools/build-compiled-script.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$version=$args[0]
if ($version -eq $null){
echo "No Version supplied, not bulding script"
return
}
if (Test-Path ./tmp/){
Remove-Item ./tmp/
}
New-Item ./tmp/ -ItemType Directory
if (Test-Path ./tmp/skynet-iads-compiled.lua) {
Remove-Item ./tmp/skynet-iads-compiled.lua
}
Add-Content ./tmp/tmp-time.lua ("env.info(`"--- SKYNET VERSION: "+$version+" | BUILD TIME: "+(Get-Date -date (Get-Date).ToUniversalTime()-uformat "%d.%m.%Y %H%MZ")+" ---`")")
cat ../skynet-iads-source/skynet-iads-supported-types.lua, ../skynet-iads-source/skynet-iads.lua, ../skynet-iads-source/skynet-mooose-a2a-dispatcher-connector.lua, ../skynet-iads-source/skynet-iads-table-delegator.lua, ../skynet-iads-source/skynet-iads-abstract-dcs-object-wrapper.lua, ../skynet-iads-source/skynet-iads-abstract-element.lua, ../skynet-iads-source/skynet-iads-abstract-radar-element.lua, ../skynet-iads-source/skynet-iads-awacs-radar.lua, ../skynet-iads-source/skynet-iads-command-center.lua, ../skynet-iads-source/skynet-iads-contact.lua, ../skynet-iads-source/skynet-iads-early-warning-radar.lua, ../skynet-iads-source/skynet-iads-jammer.lua, ../skynet-iads-source/skynet-iads-sam-search-radar.lua, ../skynet-iads-source/skynet-iads-sam-site.lua, ../skynet-iads-source/skynet-iads-sam-tracking-radar.lua, ../skynet-iads-source/syknet-iads-sam-launcher.lua | sc ./tmp/tmp-code.lua
$code = Get-Content ./tmp/tmp-code.lua
Add-Content ./tmp/tmp-time.lua $code
Rename-Item -Path ./tmp/tmp-time.lua -NewName skynet-iads-compiled.lua
Remove-Item ./tmp/tmp-code.lua

if (Test-Path ../demo-missions/skynet-iads-compiled.lua) {
Remove-Item ../demo-missions/skynet-iads-compiled.lua
}

Move-Item -Path ./tmp/skynet-iads-compiled.lua ../demo-missions/skynet-iads-compiled.lua

$toc = ./bin/gh-md-toc.exe --hide-footer ../skynet-iads-source/README_source.md
$toc = $toc -replace "=================", "=================`n"
$toc = $toc -replace "Table of Contents", "Table of Contents`n"
$toc = $toc -replace "\)", "`)`n"
$readme = Get-Content ../skynet-iads-source/README_source.md
$readmeWithTOC = $readme -replace "{TOC_PLACEHOLDER}", $toc

if (Test-Path ../README.md) {
Remove-Item ../README.md
}

Add-Content ../README.md $readmeWithTOC
Remove-Item ./tmp/
61 changes: 6 additions & 55 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and you also may get tips on how to best implement an enhancement.
Skynet uses [semantic versioning](https://semver.org/).

# Required software
You will need a working copy of DCS (Digital Combat Simulator) to contribute to Skynet development.
You will need a working copy of DCS [([Digital Combat Simulator)](https://www.digitalcombatsimulator.com/en/) to contribute to Skynet development.

# Test first design philosophy
Skynet is developed with the [test first philosophy](https://resources.collab.net/agile-101/test-first-programming). Once you get the hang of it test first development is really great.
Expand All @@ -23,59 +23,10 @@ Check the output of the dcs.log file for information whether the tests have pass

# setting up your editor
I recomend you use [notepad++](https://notepad-plus-plus.org/downloads/) to edit lua files.
This [Post](https://community.notepad-plus-plus.org/topic/15662/help-function-list-doesn-t-support-my-language/12) has some information on how you can add a function list for LUA in notepad++

Add this line to functionList.xml located here YourDrive:\Users\%HOMEDIR%\AppData\Roaming\Notepad++
# Build workflow
All the .miz files in this respository load the skynet-iads-compiled.lua file including the unit test mission. To create a new build run build-compiled-script.ps1 in the Power Shell on Windows. After that you can load the skynet-iads-compiled.lua in to the .miz file of your choosing. Rund build-compiled-script.ps1 1.0.0 to add the version number in the script.

```lua
<association id="lua_function" langID="23" />
```

```lua


<parser
displayName="Lua w/o Class"
id ="lua_function"
commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
(?s: # Multi Line Comment
(?&lt;!-)-{2} # - start-of-comment indicator with
\x5B(?'MLCLVL'=*)\x5B # ...specific level
.*? # - whatever, until
\x5D\k'MLCLVL'\x5D # - end-of-comment indicator of equal level
)
| (?m-s:-{2}.*$) # Single Line Comment
| (?s-m: # String Literal
=\s*
\x5B(?'SLLVL'=*)\x5B # - start-of-string indicator with specific level
.*? # - whatever, until
\x5D\k'SLLVL'\x5D # - end-of-string indicator of equal level
)
"
>
<function
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
(?m) # ^ and $ match at line-breaks
(?:
^\h* # optional leading white-space at start-of-line
(?-i:local\s+)?
(?-i:function)
\s+[A-Za-z_]\w*
(?:\.[A-Za-z_]\w*)*
(?::[A-Za-z_]\w*)?
|
\s*[A-Za-z_]\w*
(?:\.[A-Za-z_]\w*)*
\s*=
\s*(?-i:function)
)
\s*\([^()]*\)
"
>
<functionName>
<nameExpr expr="(?&lt;=\bfunction\b)\s+[A-Za-z_][\w.:]*\s*\(|[A-Za-z_][\w.]*\s*=" />
<nameExpr expr="[A-Za-z_][\w.:]*" />
</functionName>
</function>
</parser>
```
Source: https://community.notepad-plus-plus.org/topic/15662/help-function-list-doesn-t-support-my-language/12
## Editing the readme file
The README.md in the root of this repository is autogenerated. Don't add new documentation in this file. Instead edit README_source.md. When running build-compiled-script.ps1 the README.md is updated with a table of contents.
Binary file not shown.
37 changes: 31 additions & 6 deletions demo-missions/skynet-iads-compiled.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
env.info("--- SKYNET VERSION: 1.1.0 | BUILD TIME: 11.07.2020 1144Z ---")
env.info("--- SKYNET VERSION: 1.1.1 | BUILD TIME: 31.07.2020 2043Z ---")
do
--this file contains the required units per sam type
samTypesDB = {
Expand Down Expand Up @@ -920,8 +920,27 @@ function SkynetIADS:setupSAMSitesAndThenActivate(setupTime)
for i = 1, #samSites do
local sam = samSites[i]
sam:goLive()
--stop harm scan, because this function will shut down point defences
sam:stopScanningForHARMs()
--point defences will go dark after sam:goLive() call on the SAM they are protecting, so we load them and call a separate goLive call here, some SAMs will therefore receive 2 goLive calls
-- this should not have a negative impact on performance
local pointDefences = sam:getPointDefences()
for j = 1, #pointDefences do
pointDefence = pointDefences[j]
pointDefence:goLive()
end
end
self.samSetupMistTaskID = mist.scheduleFunction(SkynetIADS.postSetupSAMSites, {self}, timer.getTime() + self.samSetupTime)
end

function SkynetIADS.postSetupSAMSites(self)
local samSites = self:getSAMSites()
for i = 1, #samSites do
local sam = samSites[i]
--turn on the scan again otherwise SAMs that fired a missile while in setup will not turn off anymore
sam:scanForHarms()
end
self.samSetupMistTaskID = mist.scheduleFunction(SkynetIADS.activate, {self}, timer.getTime() + self.samSetupTime)
self:activate()
end

function SkynetIADS:deactivate()
Expand Down Expand Up @@ -1121,7 +1140,7 @@ function SkynetIADS:printDetailedSAMSiteStatus()
local samSitesInCoveredArea = samSite:getSAMSitesInCoveredArea()

env.info("GROUP: "..samSite:getDCSName().." | TYPE: "..samSite:getNatoName())
env.info("ACTIVE: "..tostring(isActive).." | AUTONOMOUS: "..tostring(isAutonomous).." | IS ACTING AS EW: "..tostring(samSite:getActAsEW()).." | DETECTED TARGETS: "..#detectedTargets.." | DEFENDING HARM: "..tostring(samSite:isDefendingHARM()))
env.info("ACTIVE: "..tostring(isActive).." | AUTONOMOUS: "..tostring(isAutonomous).." | IS ACTING AS EW: "..tostring(samSite:getActAsEW()).." | DETECTED TARGETS: "..#detectedTargets.." | DEFENDING HARM: "..tostring(samSite:isDefendingHARM()).." | MISSILES IN FLIGHT:"..tostring(samSite:getNumberOfMissilesInFlight()))

if numConnectionNodes > 0 then
env.info("CONNECTION NODES: "..numConnectionNodes.." | DAMAGED: "..numDamagedConnectionNodes.." | INTACT: "..intactConnectionNodes)
Expand Down Expand Up @@ -1710,6 +1729,10 @@ function SkynetIADSAbstractRadarElement:hasMissilesInFlight()
return #self.missilesInFlight > 0
end

function SkynetIADSAbstractRadarElement:getNumberOfMissilesInFlight()
return #self.missilesInFlight
end

-- DCS does not send an event, when a missile is destroyed, so this method needs to be polled so that the missiles in flight are current, polling is done in the HARM Search call: evaluateIfTargetsContainHARMs
function SkynetIADSAbstractRadarElement:updateMissilesInFlight()
local missilesInFlight = {}
Expand Down Expand Up @@ -1975,8 +1998,10 @@ function SkynetIADSAbstractRadarElement:goDark()
controller:setOption(AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD)
end
end
--called here so if SAM is destroyed it will still activate the point defences
self:pointDefencesGoLive()
-- point defence will only go live if the Radar Emitting site it is protecting goes dark and this is due to a it defending against a HARM
if (self.harmSilenceID ~= nil) then
self:pointDefencesGoLive()
end
self.aiState = false
self:stopScanningForHARMs()
if self.iads:getDebugSettings().samWentDark then
Expand Down Expand Up @@ -2292,7 +2317,7 @@ function SkynetIADSAbstractRadarElement.evaluateIfTargetsContainHARMs(self)
-- env.info("detect as HARM: "..self:getDCSName().." "..self:getNumberOfObjectsItentifiedAsHARMS())
-- end

-- we use 2 detection cycles so a random object in the air pointing on the SAM site for a spilt second will not trigger a shutdown. shallReactToHarm adds some salt otherwise the SAM will always shut down 100% of the time.
-- we use 2 detection cycles so a random object in the air pointing at the SAM site for a spilt second will not trigger a shutdown. shallReactToHarm adds some salt otherwise the SAM will always shut down 100% of the time.
if numDetections == 2 and shallReactToHarm then
if self:shallIgnoreHARMShutdown() == false then
self.minHarmShutdownTime = self:calculateMinimalShutdownTimeInSeconds(timeToImpact)
Expand Down
Binary file modified demo-missions/skynet-test-persian-gulf -stress-test.miz
Binary file not shown.
Binary file modified demo-missions/skynet-test-persian-gulf.miz
Binary file not shown.
Binary file removed images/iads-setup-code.png
Binary file not shown.
Binary file modified images/load-scripts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7a0a2cf

Please sign in to comment.