[SCR] Missile Defense Mk2 (v2.28 - 17.12.11)

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

[SCR] Missile Defense Mk2 (v2.28 - 17.12.11)

Post by Gazz » Fri, 6. Mar 09, 20:41

English / Deutsch (contains no text so works with every language)

MD Mk2 is not compatible with X3: Albion Prelude.
That is probably because an improved version or it is already included in vanilla AP.


[ external image ]
Turret Missile Defense Mk2
  • This script improves several Egosoft turret scripts.

    Missile Defense (Player)
    Missile Defense (AI)
    Missile Defense Only (Player)
    Attack Enemies (AI)
    Attack Enemies (Player)

    "Protect Ship" is not covered because it never shoots at missiles so there would not be any real advantage over the ES script.
  • All ships in the game will use those instead of the original versions.

    On player owned ships you will have to restart the turret script if you used the original Egosoft scripts before. Version updates from MD Mk2 v2.00+ to the current version do not require a restart.
  • Obviously it uses more CPU power than the default scripts but the difference is very small. (for a change)
  • The default missile defense scripts were painfully inadequate when more than one missile was incoming.
    In fact, all MD turrets of a ship were concentrating on the closest missile even if it was on the other side of the ship.
    They never attempted to target the second closest missile instead - the one they could have hit.

    Especially the engagement of multiple incoming missiles is massively improved.
  • Target priorities

    Missiles always and without exception take priority.

    With "Missiles Only" the priorities stop right here.

    The turret will fire back at ships it was attacked by.

    The turret can also attack the current (script) target of it's ship if it's executing one of these orders:
    • Kill all enemies
    • Kill all enemies and land
    • Kill enemies in range
Turret Attack Enemies Mk2
  • This is the other default script that AI ships' turrets use and it aggressively targets anything... hostile.
  • The target priorities have undergone slight tweaking as well.
    (1, 5, and 6 are changes compared to the original Egosoft script)
    1. If the turret can fire capital ship lasers like PPC it at least attempts to find a worthy target instead of toying with the fighter drone that happens to be the closest target.
      On player ships it does not check if the turret can load big guns but if there is one in the first slot of the turret. This check is repeated every 2 minutes and when the script is restarted.
    2. the turret fires back at ships that have caused damage
    3. it fires at the target that it's ship is attacking (under autopilot control)
    4. it fires at any enemy within it's firing arc.
    5. If no enemy target is found, it does missile defense.
    6. Only if a massive missile attack is incoming, the turret assigns priority 1 to missile defense until the situation is under control.
      No ship can afford to ignore an M7M's missile barrage and an M6 can't ignore even a single Firestorm Torpedo...
Rate of Fire
  • Egosoft Missile Defense generally fires all lasers at a low rate, other ES turret scripts at a mediocre rate.
  • MD Mk2 always uses a low rate of fire when firing at missiles.

    When firing at ships, it automatically adjusts it to the installed lasers.
    PRG/PBE are fired at a high rate and even the ROF of heavy lasers like PPC can be slightly improved because the script tries to find the optimal "wait"... that is when all lasers have recycled.

    It's actually a very simple system. If "fire" is successful, lower the delay. If not (lasers not ready, yet), it must have been too short so increase it. A "calculation" like that isn't costly.

    This is very different to the approach of some other turret scripts, that just reduce the script's "wait" in general. The whole script would then always run at the fastest possible pace, whether that's useful or not.
Automatic Weapon Switching
  • The script includes an "Artificial Life Plugin".
    Using this you can adjust which ships should automatically switch lasers depending on the range / enemy.
  • Available modes:
    • OFFLINE. Your ships as well as the AI will use vanilla scripts.
    • Vanilla mode. Player ships never switch weapons. AI ships do.
    • Player big ships. M6, M1, etc. will switch automatically.
    • Player big ships + TL. Same + TL.
    • All ships switch weapons automatically. Not recommended but it's your game. =)
  • Changes will take effect after the next save / reload and then possibly after one more sector change.
[ external image ] Download: ZIP


Installation
Copy the contents of the zip into \TC\ so that the scripts end up in the \scripts\ folder.

Deinstallation
Delete setup.plugin.gz.missile.def.mk2.xml.

Tech Stuff
Scripts can detect if Missile Defense Mk2 is currently active in the game:

Code: Select all

$Dummy1 =  last load time 
$Msl.Def.Mk2 = get global variable: name='GZ.MSL.DEF.MK2' 
skip if $Dummy1 == $Msl.Def.Mk2 
|$Msl.Def.Mk2 = null
This returns an accurate and current value even after setup script has been deleted.

Added for scripters and personal laziness:
plugin.gz.missile.load.auto
This script can be started without any arguments on any turret and then automatically runs with "intelligent defaults", like doing Attack Enemies on PPC turrets but preferring Missile Defense on small laser turrets.

Incompatibilities
Roger's EES / Changeling.
MD Mk2 voluntarily ceases to function if these are detected.

Resources used:
none
Last edited by Gazz on Sat, 17. Dec 11, 15:08, edited 42 times in total.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 6. Mar 09, 20:41

For comparison: what Egosoft Missile Defense does
  • Frequency:
    If the ship is not attacking something (using a script!) then always wait for 5-8 sec until acquiring a new target.
  • Look for targets in this order:
    • the closest missile (to the ship, not the turret)
    • some ship that has hit me
    • the target my ship is attacking (using a script)
    • If my ship is executing "Kill all enemies", search for any enemy ship within this turret arc
  • If the found target is the closest missile, all "Missile Defense" turrets of my ship will lock onto this exact missile the next time they are looking for a new target.
    If a turret can not fire at it, it will still do nothing else until the missile is destroyed.
    Since MD turrets are typically opposed (up/down), 50 % of a ships anti-missile capacity is usually shut down by design.
  • If non-missile target: keep firing until target is destroyed or leaves this turret's arc.
    Does not switch if a missile happens to show up during this.
  • If no target, wait and start over.
  • If ship is docked, wait for up to 80 sec.
    That means that if the ship launches from somewhere, it's missile defense turrets are (individually) dead for up to 80 seconds.
Known problems:

Frequency:
If the ship is not actively attacking something - like when you board a neutral ship and "apologise" - the enforced delay between any 2 missiles is 5-8 seconds. Regardless of missiles incoming or not.
During that time a Hammer torpedo moves 1650 m.
Vanilla capital ships only ever run the Missile Defense script on turrets with short range lasers so they have maybe 2500 m laser range.
Due to that timer the turret has to be very lucky to be able to even look at a 2nd missile in the incoming swarm.

Most likely that is the reason why "ships never react when missiles are fired from far away".
Technically they do try to defend but they only get one chance to target the first missile if it's within range after the current 5-8 sec "tick".
When the waiting time is up and the script is looking for the next missile, the whole missile swarm has used this time to cross Flak range and it's over.
At this point the "Minimum range" condition may already apply. See below.

This is one of the reasons why boarding is such a laughably trivial affair with M7M.
Fire measured barrage, apologise, fire boarding pods. Transfer jumpdrive and send new ship to homebase. Next, please.


Minimum range:
If a ship is attacked with numerous small missiles like Flail, one of them is bound to get close to the ship.
If that happens, the closest missile (the only one turret scripts can target) has gotten behind the turret camera.
No turret can just turn 180° and "look behind".
Now all turrets target this missile. And they can not see it. So they wait.
Once it impacts (which will be soon), they look for a new missile.
However, since they were not doing anything while waiting for this one missile to be destroyed, another few missiles have gone into below minimum range.
So the turrets wait until this missile, too, is destroyed or enters their firing arc. (fat chance)
Since they were not doing anything while... umm... do you see a pattern here...?

So once the first missile of a swarm hits, there is a high chance that all Missile Defense turrets of the ship will "freeze" and oscillate between waiting and starting to turn towards the next missile - which they will not have time to complete.


Turret arcs:
On the average capital ship (like an M2), the front turret is running "Attack enemies".
This turret script never ever fires at missiles.
If a player-controlled M7M tags this M2 with a few Flails then the ship eventually starts chasing the M7M.
This means that there is no missile defense whatsoever in a slim corridor straight ahead.
Remember the chasing part? That slim corridor is the exact path that every missile fired from the M7M will take to travel to this target.

So there is an exactly 0 % chance that an M2 can shoot down any of your missiles or boarding pods while it's chasing you.



And some people still consider M7M balanced.
Cost: Maybe 1.5 MCr in ammo plus (reusable) marines
- a few Flail to aggro the ship and fine tune the shield level
- maybe 20 Hammers to drop the shields
- 1-4 boarding pods
Profit: Maybe 90 MCr
- One M2 with possibly some equipment leftover.

That's an interest rate of 5000 % on your... investment.
Not bad for a few minute's work, considering that there is no risk to you or your marines whatsoever (except for the fighting on board of the target ship) and no chance of failure once you have a handfull of decent marines.
Last edited by Gazz on Thu, 9. Jun 11, 20:38, edited 10 times in total.

StormMagi
Posts: 1335
Joined: Sat, 17. Mar 07, 03:53
x4

Post by StormMagi » Fri, 6. Mar 09, 20:51

How well does this work with MARS?
MOD XR Show Skills

Flying spaceships since 1993.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 6. Mar 09, 21:11

Not at all.
It's a completely separate script. They have nothing to do with each other.

For a transport with some peashooter turret it should work perfectly fine where MARS is monstrous overkill - in terms of CPU cost for what that little turret could possibly do. But it's your CPU so... *shrug*

There are no controls and no configuration and there won't be any.
Other than possibly small tweaks I don't expect that I'll improve it any more.

An M7 with 3 Missile Defense turrets (2 or which were Gauss, so no classic anti-missile lasers) was able to fend off 60 hammer torpedoes before any reached the ship.
They arrived near simultaneous, too, being fired from 4 M7M at once.
Compare that to the original. (But don't be in the target ship when you do)
Last edited by Gazz on Sat, 7. Mar 09, 13:06, edited 3 times in total.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

StormMagi
Posts: 1335
Joined: Sat, 17. Mar 07, 03:53
x4

Post by StormMagi » Fri, 6. Mar 09, 21:59

Ok, Btw the download link just links to the gif for downloading
MOD XR Show Skills

Flying spaceships since 1993.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 6. Mar 09, 22:02

No.
It works fine with both MSIE and Firefox.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

StormMagi
Posts: 1335
Joined: Sat, 17. Mar 07, 03:53
x4

Post by StormMagi » Fri, 6. Mar 09, 22:06

my bad looks like my copy of FF doesnt like it
MOD XR Show Skills

Flying spaceships since 1993.

Ook
Posts: 39
Joined: Sun, 28. Dec 03, 12:53
x3tc

Post by Ook » Fri, 6. Mar 09, 22:51

I have the same problem with MSIE 7, using `View Source` shows faulty html code is the reason.

The download image is an <a></a> tag instead of an <img /> tag as it should be.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 6. Mar 09, 22:58

There are no HTML tags in that post. It's all BB Code.

Apparently your browser or the browser / forum combination messes up somewhere in the conversion.
Or it's time to sacrifice another chicken.

Maybe you have some creative settings in your forum config?
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

someone else
Posts: 2972
Joined: Sun, 18. Jun 06, 13:37
x3tc

Post by someone else » Fri, 3. Apr 09, 18:08

mmmh... I downloaded it and it is just fine, :D I don't want all AI bigships to use MARS (It will be madness) and still I don't want to be on the only ship in the universe who can shoot down missiles :lol: (I feel it's like cheating). Good thing Gazz!

I have an idea on the "downloading problem":
maybe some disorienting comes from the fact that your download link links to the download page of your site (where a wealth of life-saving scripts/mods are listed). If the others right clicked on it and selected "save with name" they saved the page of your site, not the "missile defence mk2".

semiliterate
Posts: 357
Joined: Sat, 13. Dec 08, 22:02

Post by semiliterate » Fri, 3. Apr 09, 23:54

um, if this is the only thing in the ship script debug thing in the SE, and i have a constant ping of some kind (i can't tell which pinging noise it is because it's about ten a second), could it be this?

if not, do you know what instruction in a script would play a pinging sound, so i can search for it?

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Sat, 4. Apr 09, 00:13

play sample

or using the simple explorer file search,

play sample 



I'm pretty certain it's not from Missile Defense Mk2, though.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Sat, 4. Apr 09, 00:14

play sample

or using the simple explorer file search,

play &# 160;sample &# 160;
(remove all spaces)


I'm pretty certain the pingadingaling is not from Missile Defense Mk2, though.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

semiliterate
Posts: 357
Joined: Sat, 13. Dec 08, 22:02

Post by semiliterate » Sat, 4. Apr 09, 02:28

oh woops

um, i should have posted that in the Missile Safety thread. but thanks, i'll have a look.

Hieronymos
Posts: 830
Joined: Fri, 30. Dec 05, 22:14
x3

Post by Hieronymos » Thu, 16. Apr 09, 03:28

Finally blundered to your thread Gazz. Thanks for creating this! It's perfect for both player & ai M4+/M3/M3+, and even M6's that don't rate MARS--and its cpu needs.

So the script just targets missle nearest each turret?
Meaning it doesn't have any threat evaluation/weighting abilities like MARS for different missle types?

Will it target enemy fighters in range if no missles are present (if said fighter(s) haven't (yet) attacked ship?

Thanks Gazz, you're a lifesaver.
............

It just occurred that this script would be an amazing foundation for a slightly more sophisticated "Point Defense" script, that would prioritize missle targettting, but then switch to heavier weapons (like FAA,CFA) for firing on closest fighter.

I'm assuming here (displaying my ignorance probably) that the uber-high muzzle velocity weapons like PBE and kyons are the best anti-missle weapons, right? And that Flaks are perhaps not as good, and much much more power hungry? So if script would choose 'best (available) anti-missle wpn' when firing on missles, and then 'best (available) anti-fighter wpn' when firing on fighters..then a low-cpu PD product!

This all assumes that your research with MARS has created tables of 'best' weapons for each target type: BigShips, fighters, missles..right?

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Thu, 16. Apr 09, 12:08

Hieronymos wrote:So the script just targets missle nearest each turret?
Meaning it doesn't have any threat evaluation/weighting abilities like MARS for different missle types?
It uses an extremely basic system but certainly does not just target the nearest missile (to ship or turret). We've seen how well that works.

Will it target enemy fighters in range if no missles are present (if said fighter(s) haven't (yet) attacked ship?
See first post...

It uses the same rules as the Egosoft Missile Defense.

Hieronymos wrote:It just occurred that this script would be an amazing foundation for a slightly more sophisticated "Point Defense" script, that would prioritize missle targettting, but then switch to heavier weapons (like FAA,CFA) for firing on closest fighter.
If you wish to create one based on this script - go ahead.

You really should figure out what exactly you want... first. =P
Fighters are far less cooperating targets, with their evasive maneuvers and all that. They also come in many different sizes, speeds, and shield strengths, making laser selection an interesting problem.
And even if you have a proper laser for it, how do you tell (in script terms) which one is the best target?

A point Defense script would have to deter attackers, right? Shooting at the closest fighter typically hits the one that has ended it's attack run and is breaking away / evading.
It's not attacking, no threat.
In that situation, MARS would switch targets to the other fighter that's currently doing an attack run, so it's not just shooting "at some target" but at the immediate threat of an attacking fighter, often enough interrupting the attack run.
The "closest fighter" would be a secondary objective.

All this can be evaluated - at a cost. For your Point Defense script you'll first need to find a set of very simple rules for what is a "Point Defense" worthy fighter/missile target and what is not.
Planning, planning, planning. That saves you soooo many headaches when implementing it.

This all assumes that your research with MARS has created tables of 'best' weapons for each target type: BigShips, fighters, missles..right?
Wrong. There are no tables in MARS, telling it to always use PBE against M5. It's true that lasers are given default target ranges but MARS treats those as suggestions, not rules. The actual laser stats are far more important.
Much to the dismay of the control freak players who insist to only use PRG against fighters or only attacking capital ships with PPC...

Yet, I get a chuckle out of the odd pirate M5, peacefully passing at some 5 km out... and getting snuffed out with PPC rounds out of nowhere.
Note to self: Flying in a straight line = bad idea.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Hieronymos
Posts: 830
Joined: Fri, 30. Dec 05, 22:14
x3

Post by Hieronymos » Fri, 17. Apr 09, 01:53

It's true that lasers are given default target ranges but MARS treats those as suggestions, not rules. The actual laser stats are far more important.
Much to the dismay of the control freak players who insist to only use PRG against fighters or only attacking capital ships with PPC...
Any list of 'best' weapons for specific target types of course implies full understanding of all weapon stats, especially: projectile speed & range.
It was a little easier with 3R, imo, as pretty much every weapon class was 'graduated': A-IRE, B-IRE..and so on.
You really should figure out what exactly you want... first. =P
Since MissleDefense mk2 is excellent as a simple but effective, low-cpu intensive anti-missle program, it will suffice for fighters and many corvettes.

But we have several dedicated Flak-ships (an M6+ and Light M7 armed primarily with FAA/CFA), as well as other M7 & TL with modded turret rigs geared only for targets corvette & smaller..or for just fighters and missles.

For these ships we need something that is good vs. missles, but also more aggressive vs. fighters..and mostly ignores BigShips.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 17. Apr 09, 07:34

Hieronymos wrote:For these ships we need something that is good vs. missles, but also more aggressive vs. fighters..and mostly ignores BigShips.
Why?
If there's an enemy M2 at 1800m, why should a Flak turret not shoot at it?
It's certainly going to hurt you a lot more than 1 or 2 fighters. M2 fire continuously while fighters waste about 2/3 if their firepower evading and lining up for another attack run.

So what exactly makes fighters more dangerous than an M2?
Noone has ever told me a convincing reason why it would be more important to shoot fighters instead of capital ships.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

strude
Posts: 1471
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Fri, 17. Apr 09, 16:31

Since this overwrites standard Egosoft files, will it be ok on Steam installions? I would figure doing a verify might re-download the original files.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

Hieronymos
Posts: 830
Joined: Fri, 30. Dec 05, 22:14
x3

Post by Hieronymos » Sat, 18. Apr 09, 00:00

So what exactly makes fighters more dangerous than an M2?
Of course a single fighter is nothing compared to an M2. But in higher numbers they're lethal. E.g.: 30 M.D.-armed M3's (total cost: ~MCr.100.) will give any M2 (total cost: ~MCr.100.) a damed good run for its' money!

DDRS has created certain specialty vessels, like Flakships. The Boron Tigerfish M6+ Flak Corvette has three 1x FAA turrets; but only M4-ish weapons at Main. The Argon Charon M7 Light Flak Frigate carries mainly FAA,CFA in its turrets--nothing bigger (there are other Jager-type M6's and M7's that carry big guns--but are weak on flak). Also, many DDRS ships have "light flak" turrets, like a 4x (quad) IRE turret; or a 3x PRG,PAC,IRE turret; or a 2x alphaKyon,PRG,MD,IRE,PAC turret.

Such specialty vessels and turrets have been created to target fighters, missles and drones--including CombatDrones currently under development. Their combat efficiency is highest against such target classes, and begins to drop sharply against corvette and larger targets. They are thus the XTC equivalants of the USN Aegis Missle Cruiser & the Phalanx CIWS, respectively.

As such, they are only meant to be used as parts of Combined Arms teams, where other vessels: Multirole & Jager are used for engaging larger targets.

My point is that Flakships and 'light flak' turrets are devastatingly effective against fighters (especially M5 & M4) and many missles..but are almost useless against heavily shielded M7's,M2's. Thus, if both enemy fighters and Capitals are engaged simulataneously, the Flakships need to focus on wiping out the fighters while the Jagers & Multirole units engage the BigShip threats.

Missle Defense mk2 is currently the best simple anti-missle script available, but it seems to ignore fighters that haven't attacked yet--even if flying within range of FAA's that are currently not engaging missles. It also will not tell a turret to switch out FAA/CFA for EBC,MD if weapon energy dries up..

A modified Missle Defense mk2 that does these things (and ignores M6 or larger targets if fighters/missles/drones are available to target) is the sort of Point Defense script I'm looking for.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”