Turret Scripts are stupid.
They gleefully fire a 30 sec salvo on an M5 when the proverbial snow ball in hell would have a higher chance of hitting.
This was too depressing to watch so I set forth on my personal crusade to create the perfect turret script. (YMMV =)
One that only fires on those targets that it can hit.
If you're just window shopping:
subaluigi created a video (6:41, 84 MB) of XTM capital ships using MARS. >> DOWNLOAD VIDEO <<
MARS consists of 6 systems:
- Fire Control (Turrets)
- Goblins (your obedient minions)
- Remote Guided Flak Missile
- Automatic cargo collection
- Satellite deployment
- AL Plugin, that makes MARS available for AI capital ships (optional =)
Hotkeys: - Launch goblin
- Deploy Satellites
- Launch Flak Missile
- Cease fire / Ignore target
- Required equipment:
Motion Analysis Relay System (sold in nearly all equipment docks)
X3 v2.5 recommended, not required. - Available for: M6 and bigger ships.
- MARS Light available for: anything smaller
- no weapon switching
- no automatic launch of goblins.
Note that MARS uses more CPU time than a simple turret script so running it on your 50 M3 might be noticable. - MARS does not use area weapons (PSG and ION) if neutral/friendly ships are within 4 km.
It also watches for cargo unless the MARS ship has < 20 % shield strength. - MARS uses all weapons it can find in the cargo hold.
- It is normal that only 1 laser is installed when there is nothing to shoot at.
These lasers are available for other turrets when not needed. - MARS only fires on targets that it can hit.
If the target does the usual dodge and weave routine, MARS would switch to another ship that does a nice and straight attack run.
Or maybe a bigger and/or slower ship entered the firing arc... - Weapon choice.
Hitting a target is not enough. MARS shoots to kill.
If it calculates a 50 % hit with AHEPT and a 40 % hit with BPPC it will use BPPC because those 40 % would do 6-7 times the damage...
Hitting the target is the primary consideration. If a laser is too slow to possibly hit it will not be considered. - Attack my target
Even though MARS works independantly of any other script it takes the ship's mission and the player's intention into account.
Therefore some ships get a bonus to their "value" as a target.
Attack target of the MARS ship: +20 %
Attack target of the wing leader: +25 %
Player's target: +30 %
The ship's mission target is... suggested... as a target but MARS will engage other enemies if it can not possibly hit this target.
If the player targets an M5 but MARS also has a firing solution on the M2 behind it - those 30 % will not make the M5 look like an interesting target. - Automatic Firepower Management
MARS continuously adapts the rate of fire of every laser to optimally match your current FPS. - Capture Mode
We brake for... ships! Not for long mind you - MARS is a bloodthirsty god.
(Settings editable in t\xx7047.xml) - Neutral stations are relatively save from MARS turrets.
Cap ships with very long range weaponry may have trouble operating close to stations.
(Settings editable in t\xx7047.xml) - MARS considers the weapon damage when selecting lasers.
It would not bother firing A IRE at an M2 or Ions at a ship without shields... - Saving ammo is not it's job.
If there are mass drivers aboard and they were selected as "best weapon" then MARS will fire without hesitating until it runs out of ammo.
Of course it will then switch to regular lasers. - MARS works best in a target rich environment.
Only if there are several targets available, MARS can pick the one that's easiest to hit. - The chance of a particular turret hitting it's target can not be increased.
What MARS does is rate and select targets and eliminate a huge number of guaranteed misfires. - When your ship's turrets start tracking / turning towards an enemy, the board computer will say "Target locked on".
This message is reset after 5 minutes of inactivity. - When a ship goes OOS or undocks OOS it automatically loads the highest damage weapons it has.
- MARS can be adapted to modded weapons easily.
All the data it needs is found in Textfile xx7047.xml. - Very little is hardcoded:
Ions: flagged as an area weapon. - Automatic detection and use of [MOD] Heavy Capital Ship Lasers
- Several settings editable in tesxtfile t\xx7047.xml
Safety range for area weapon use and such... - Hotkey: Cease fire / Ignore target
If an enemy is targeted this ship will permanently be ignored by every MARS system until you cancel the order the same way.
The turrets and goblins can still "clear the trash" for you while you try to cap that elusive Pirate Nova Raider...
If no enemy is targeted then a cease fire is transmitted to all MARS ships in the sector.
It will last 60 seconds (editable in the config file) or until you cancel it the same way.
Turrets will continue to track targets so they can resume firing without any delay.
- Instead of counting the damage the lasers can do to the missile, MARS uses the damage that the missile would do on impact.
If this damage is greater than 1/4 of the remaining shield strength this missile receives a priority bonus.
For missile defense MARS uses PSG or the laser with the shortest range.
This "1/4" threshold can be altered in the config file t\xx7047.xml
Missiles are still "only targets". If an M2 is firing GPPC at a target it would ignore a Silkworm but would switch to a Thunderbolt or Firestorm.
If the same M2 is currently firing BPAC at an M5 it would switch to the Silkworm.
An M5 is far less interesting than a guaranteed hit for 25k. - Missiles incoming to the Playership are a target for all MARS turrets in the sector.
All other ships treat them as if they were the missile's target instead.
- Only hostile ships are attacked.
- MARS Defense is primarily a defense system.
Enemies are only attacked if they are going after a friendly unit or a neutral ship, that the MARS ship is protecting.
The HUD target of the player and the attack target of the MARS ship are always valid targets, provided they are hostile.
This can also be a station.
MARS protects all assets and attacks the ship's mission target but does not take the initiative and pick fights on it's own. - MARS Offense is the equivalent to Kill All Enemies.
Now MARS is actively looking for trouble.
Enemy stations are considered secondary targets - after any kind of ship.
Offensive mode also enlarges the area controlled by the ship. It uses Goblins to intercept and/or delay all enemies within a 16-30km radius.
Alas this can only work In Sector. - MARS Defense and MARS Offense can not be mixed on the same ship.
This setting controls which targets the central MARS unit relays to the turrets.
Setting one MARS turret to Defense sets all on Defense.
Using Fighter Drones to defend freighters is not a novel idea.
Goblins, however, do much more for you. They are your obedient minions that distract your enemies, collect loot and deserted ships in the sector, and if launched as a pack even bring down the wayward M5 that your M2 can't catch.
- Manual launch of Goblins available for: all ships with MARS installed.
- Automatic launch of Goblins available for: (big) ships with active MARS turrets.
- MARS automatically uses Fighter Drones in the cargo bay, loads them with new software and launches them as Goblins.
- There is an AL Plugin switch to prevent all your ships from automatically launching goblins for combat missions.
- The main difference to regular drones is the software.
Fighter drones attack or protect until they are destroyed.
Goblins are cowardly backstabbers. They do not want to get destroyed.
They attack when the enemy has not noticed them, yet, but when attacked they flee at top speed on a zigzag course towards a spot behind their mothership.
As a result they are survivors. They tie up enemy ships far longer than regular drones. - Goblins can only be controlled through MARS and it's hotkeys.
X3 has hotkeys and commands for like "all Fighter Drones in sector, Protect me"
...Goblins simply ignore these.
The means that the functionality of regular drones is not hurt at all.
Feel free to also deploy regular drones and use their classic commands and hotkeys to order them around.
Goblin and fighter drone orders do not interfere with each other in any way. - MARS preferrably uses Goblins against the most dangerous enemy ships.
- Goblins rarely fight but they are tuned for a slightly higher top speed.
- There is a Hotkey for the playership to lauch Goblins at an enemy.
Using the hotkey you can launch up to 2x as many as MARS would launch automatically.
They all count towards the same cap so if you launch all manually, MARS has to wait until some of them return home.
They can be used to get the attention of ships and lure them towards the MARS ship.
Also very useful to pull ships away from a neutral station without turning the station hostile.
Goblin operational range is roughly 120 km. - (X3 v2.5 required)
Using the hotkey if you have a cargo container or abandoned ship targeted will send a goblin to leash and retrieve it. Sending several to one item will cause them to spread out and seek out containers independantly.
Goblins that have returned with cargo request a cargo pickup from the mothership. If a Transporter Device is installed, the cargo will be beamed aboard.
This can be disabled for several ship classes in t\xx7047.xml if you would prefer that only transports pick up cargo while still leaving Mx class ships the option to "recover" valuables to a safer location.
Their engines are weak so don't expect them to be very fast when hauling a heavy ship back to you.
Still - beats flying halfway across the sector with your personal M1. =)
If Goblins automatically (see Cargo Collection below) bring abandoned ships back to the mothership, they drop them in the general vicinity.
If they do that on a manually given order (abandoned ship targeted) they bring them all to a spot in front of the mothership.
With all ships bunched up in front of you, you don't have to do any fancy flying with your 4km ship.
Just fly next to them and capture them using the SOS software.
(On capital ships, the SOS has an enormous range, too.) - Pandora and other special crates (BBS missions) are ignored by the automatic cargo collection and can only be retrieved through an explicit order from the playership.
- If you target a friendly ship (such as a TS) and press the hotkey, this ship will send out goblins to retrieve valuables in the sector.
Obviously your second ship requires MARS and it's own drones.
This can greatly speed up cargo collection and a TS called in to collect dropped cargo can stay well away from the ongoing battle while only endangering the much cheaper and faster goblins. - If you have an own stationary ship targeted (Satellite, Lasertower, SQUASH) targeted then you can send goblins to collect this exact type of object.
This only works for all stationary objects on your personal ship.
The global commands from the sector map are for advanced satellites only. - Droit de Seigneur
If you order a goblin from your ship to collect a specific cargo container or ship then this takes precedence over all other collecting ships in the sector, even if another goblin is already enroute to or towing this target.
If your ship does not have any free goblins at the moment, this only chases away the other goblin that may be enroute to this target.
So if you decide that you want this crate of mosquitos instead of your cargo collecting TS you just go MINE! and send a goblin to grab it. - Activating the hotkey without a target selected issues a Return To Base command to all goblins in the sector.
MARS will also not launch additional ones for 10 minutes.
Activating the hotkey with a goblin targeted will send an RTB order to that particular goblin only. - Especially when a goblin has to tow a heavy load, it's range is quite limited.
When the fuel is getting low it will return to the mothership while a colleague launches to take over. - MARS starts 1 Goblin per enemy ship. The direct hotkey command is not bound by this so you can launch several against a far out M5 or the likes.
- Every MARS system has a control limit. Huge ships can control 6 goblins, all others 4.
- Goblins attempt to return to the mothership before their battery runs out.
A goblin can be operational for about 9 minutes, leaving a fuel reserve for 1 minute. - All Goblins are automatically collected if they are within 5km of their mothership when it leaves the sector.
- If a goblin has to return to base for whatever reason it will return to it's mothership. If that is not present it will return to the closest MARS ship in the sector. If even that fails it will detach from the MARS system and operate as a regular fighter drone.
Sometimes a scout ship or two just isn't enough.
If you've arrived with your battle fleet... you need intel!
- Hotkey : Deploy Satellites
From the cockpit you have more direct control while on the sector map, all your ships work together to execute the command.
If you use this hotkey in the cockpit:- the command is only given to one of your ships if you have one targeted
- if not, it's given to your own ship only
- the command is potentially executed by all ships in the sector
- They do not waste any effort but instead try to do the job in the most efficient manner.
- If a ship with satellites in the cargo bay is closer to the far gate of the sector, this one will deploy the satellite destined for that gate and all ships' goblins will work together to tow the satellites into place.
If your TS that brought the satellites only has one drone aboard that is not going to delay matters since all other MARS ships in the sector will assist.
- Only Advanced Satellites are used.
- An AL Plugin allows you to set how many satellites should be deployed with the default 1x Hotkey function.
- Hotkey 1x: Deploy default
as set with the AL Plugin. - Hotkey 2x: Collect all Adv Satellites
The ship(s) with the most free cargo space will collect as many satellites as it can with one swarm of goblins.
A regular ship like a TS can collect 8 sats at once, a capital ship 12.
If you give the order from a sector map and the ship runs out cargo space, free goblins, or is simply out of range to get all satellites, other ships will assist.
From the cockpit you can order one specific ship to do the collection. - There are 3 extra modes to override the preset deployment pattern of the AL Plugin
- Hotkey 3x:
Deploy 1 sat per jump gate - Hotkey 4x:
Deploy 1 sat per jump gate
+ 8 in box formation - Hotkey 5x:
Deploy 1 sat per jump gate
+ 8 in box formation
+ light up all trade lanes between all jump gates - If a deploy order is interrupted / unfinished for any reason then MARS ships in the sector will attempt to complete it.
After 1 hour the order is forgotten and has to be reissued manually.
(running such a script indefinitely is uhh... bad =) - A deploy command can be aborted and resumed at any time using the hotkeys.
For instance, you may have given a global RTB command to all goblins.
If you give another deployment order from the sector map, all ships in range will launch goblins to finish towing the satellites into formation. - A satellite stays part of the formation until a goblin starts towing it away.
You will see this from the name change.
The RGW is used in one X3 story mission. Now it has gotten a new purpose.
- Hotkey : Launch Remote Guided Warhead
- This missile is only used on the playership and has to be guided to the target manually.
- Unlike regular missiles, the RGW creates a cloud of super heated plasma.
It has a total diameter of about 3 km but cools down quickly while expanding so it's most effective in the center.
Massive capital ships won't be impressed with a little temperature shock but a small M5 just can't take the heat...
This missile is only really effective against fighters so it's also known as a Flak missile. - RGW are launched with the hotkey. This also targets the missile so you can see the target data it displays:
Distance to closest enemy / Closing speed
You can change your target anytime.
A second press of the hotkey re-targets an active missile. - If the RGW is targeted it can be detonated remotely with the same hotkey.
- Proximity Fuse:
If an enemy ship enters close range to the warhead (Distance red), the fuse is armed.
Unlike a dumb fuse the RGW still attempts to get even closer but detonates immediately when it has reached the point of closest proximity and is in danger of overshooting the target.
If you get those anywhere close to the target, they never just fly past it and start circling...
If the distance is shown in yellow an enemy ship is within damage range but there will be no automatic detonation. - If the missile is shot down it does not detonate.
- Remote controls:
Mouse, Joystick - anything.
The missile flies to whereever you point your cockpit's crosshairs. - Acquisition / Ammo:
There are 2 factories in split space that produce these missiles. - If you target one of your own missile factories, the hotkey refits them to produce Flak missiles so you can build your own.
The previously produced missile must have cost at least 10000 Cr so a cheap Mosquito factory will not suffice.
This does work with regular "vanilla" factories but users reported problems with Ashley's Fabs. The reason is that Ashley's "Fixer" keeps fixing the fab back and that can not work.
- There is an additional ship command "Collect Cargo"
- X3 v2.5 required.
- All ships with MARS and fighter drones can use it although it is intended for freighters.
- If an area 7000m around the ship is clear of enemies it starts collecting cargo containers.
- If the ship is a carrier it will also collect abandoned ships.
They are all towed back to the carrier but not claimed. Alas this task is too complicated for a mere goblin.
Still - doing that is not very hard since they are all arranged around the carrier for your convenience. - TS have the annoying habit of launching lots of Fighter Drones when under attack.
If MARS Cargo Collection is active on a ship (not only TS!) then the number of regular fighter drones allowed to Follow/Protect this ship is limited to Missile Fire Probability / 5.
(You can set this value in 5 % increments)
So if you set MFProbability to 10%, all but 2 regular fighter drones will automatically be recovered when the Egosoft script launched 10...
If the ship's attacker is destroyed or no longer in the same sector, all drones are recovered.
This can also be useful to transfer drones all across a sector.
The donor ship merely ejects all 50 drones into space.
You order all drones to protect the receiving ship.
If the receiving ship has the cargo collect script active it will recover most or all (Missile % setting) of these drones when they get there.
(And drones are considerably faster than a freighter =) - Pandora and other special crates (BBS missions) are ignored by the automatic cargo collection and can only be retrieved through an explicit order from the playership.
- Ships fill their cargo bay to almost 100 %. On a freighter this will not be noticable.
- Automatic detection and use of [MOD] Racial Laser Variants
A TS collecting heavy lasers that an enemy ship dropped will automatically change them to regular lasers so they can be used and traded normally.
- MARS is a completely self contained script and should not be incompatible with anything.
(Provided you update it's base data if you install a weapon mod =) - The AL Plugin shows the currently installed version. (updated after the next reload)
- The installation of MARS is delayed for maximum compatibility and easier troubleshooting.
After "installation" it takes 2 minutes and 1 save/reload of X3 for MARS to completely activate.
For the time being there won't be an SPK version. There is still the occasional bugfix or tweaking...
Maybe one day when it's in a "wrap up and forget" state.
Resources used:
Textfile: 7046
Textfile: 7047 (Laser data for mod-adaption)
Task IDs: all task IDs end with ...7046
Command slot: COMMAND_TYPE_TURRET_46 (Defense)
Command slot: COMMAND_TYPE_TURRET_47 (Standby)
Command slot: COMMAND_TYPE_TURRET_48 (Offense)
Command slot: COMMAND_TYPE_SHIP_51 (Collect cargo)
Library: lib.ut.pos.from.2.grades.and.rad