[Mod] Subsystem Targeting Orders

The place to discuss scripting and game modifications for X4: Foundations.

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

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

[Mod] Subsystem Targeting Orders

Post by Alkeena » Sat, 27. Mar 21, 11:22

Subsystem Targeting Orders:
============

By: Allectus

Contributors: Forleyor, Rovermicrover, runekn
Translation: Vali_Lutzifer (DE), TiomTang (CN)

Github: https://github.com/A11ectus/X4-Subsyste ... ing-Orders

Steam: https://steamcommunity.com/sharedfiles/ ... 2437198154

Nexus: https://www.nexusmods.com/x4foundations/mods/645

Mod effects:
============
Adds additional turret behaviours and several new orders to the holomap right-click menu that allows you to direct your owned ships to explicitly target ship and station subsystems.

Requirements:
=============
SirNukes' Mod Support API - https://www.nexusmods.com/x4foundations/mods/503
Required for right click menu integration

(Optional) My Wing Hotkeys mod - https://steamcommunity.com/sharedfiles/ ... 2484521478
If present will provide fleet and wing quick select options and hotkeys for the orders below

(Optional) Kuertee's UI Extensions and HUD - https://www.nexusmods.com/x4foundations/mods/552
If present with version of 2.06 or greater the mod will load in a high compatibility mode making it less likely (though not immune) to conflict with other UI mods

What the mod does:
==================

This mod adds several orders to the right click menu on the map that allow you to explicitly target subsystems on hostile capital ships and stations. The commands are context sensitive and will only appear if a salient target is available.

* AI order: Attack Engines -- destroy engines

* AI order: Attack Shields -- destroy shield generators of size L or XL, focussing on the active shield generators that provide the most maximum shield

* AI order: Attack Weps, Med Turrets -- destroy S & M sized turrets, focussing on weapons with the lowest max hp (correlates with anti-fighter weapons)

* AI order: Attack Weps, Hvy Turrets -- destroy L & XL sized turrets, focussing on weapons with the highest max hp (correlates with anti-capital weapons)

* AI order: Attack Weps, Missile Launchers -- destroy missile turrets, focusing on weapons with the highest max hp (correlates with anti-capital weapons)

* AI order: Attack Weps, Main Batteries -- destroy fixed weapons, focusing on weapons with the highest max hp (correlates with anti-capital weapons)

* AI order: Attack Subs, Disable All -- single command that proceeds through all of the above commands in order: engines -> missile launchers -> hvy turrets -> med turrets -> shields -> batteries

* AI order: Attack Station Docks -- Attack station dock modules, focussing on the closest matching target

* AI order: Attack Station Storage -- Attack station storage modules, focussing on the closest matching target

* AI order: Attack Station Production -- Attack station production modules, focussing on the closest matching target

* AI order: Attack Station Def. Platforms -- Attack station defense platforms, focussing on the closest matching target

* AI order: Attack Station Shipyard Platforms -- Attack station shipbuilding and outfitting modules, focussing on the closest matching target

* AI order: Clear Turret Subsystem Target -- Clears turret subsystem targeting priority (see below) for all selected ships

This mod further modifies turret targeting behaviour to allow for secondary targets and subsystem targeting:

* Defend: No change

* Attack All Enemies: attack subsystem target (if set) -> attack all enemies

* Attack Capital Ships: No change

* Attack Fighters: attack fighters -> attack incoming missiles -> attack subsystem target (if set) -> attack all enemies

* Mining: No change

* Missile defence: attack incoming missiles -> attack fighters (as of X4 4.0HF3 the underlying vanilla missile defence routine is broken and will not attack targets under most circumstances; this is a vanilla bug and not a result of this mod)

* Attack My Target: No change (hardcoded by Egosoft/cannot be changed)

Some Notes:

* Once the subsystems covered by a given order have been destroyed the order concludes and wing may be tasked elsewhere. This allows you to string together the commands as you see fit. I recommend basically always knocking engines out first as it much easier to hit the other targets.

* Turret targeting behaviour is set/cleared for all turrets via the 'all turrets' drop down menu in the turret interface. Turrets with a set subsystem target will prioritize subsystems on your selected target. If a subsystem targeting order is given to the ship a matching subsystem turret target priority will also be set. If the order subsequently concludes normally the turret subsystem targeting will be reset to the state it was in prior to the order being issued--if the order is forcefully cancelled this reset will not occur and the turret target will persist.

* Turret targeting is a bit sticky by design and will not rapidly switch if new targets appear. This is the reason I have not added attack all enemies to the stack for fighters/missile defence--they'll frequently get locked on to capitals and not do their primary job effectively.

* When attacking with capital ships (L/XL) they will only see as valid targets subsystems that are within line of sight at order initiation (or order recycling if the initial target is destroyed). If you see an available subsystem targeting order in the right click menu (indicating active subsystems) but your capital ships cancel the order immediately after it's issued it's because they don't have line of sight to the remaining active subsystems in that category. This is to prevent excessive capital ship maneuvering to try and get shots on subsystems on the far side of the target. This requirement is not enforced when targeting station modules. Carriers are exempted from this requirement, so that they may appropriately send their subordinates to attack subsystems.

* Attack Weps, Main Batteries -- This targeting behaviour was originally rolled into the Attack Weps options but it turns out that the armoured cowling around, for example, the Behemoth's main batteries is actually pretty effective at protecting them and player ships can have a hard time finding a good attack vector without some manual help on initial positioning (in fact it's not clear that the logic is picking up on the batteries being obstructed by the hull and I haven't yet found a fix for it). This often resulted in the target dying before any weapons were disabled if ships didn't have a good initial vector. Use wisely, commander.

* Attack Subs, Disable All-- While convenient, note that this substantially amounts to an order to kill the target, but to do it much slower than if you'd just given a standard attack command since few ships are able to survive the sustained fire it takes to completely strip them while it still takes longer than necessary to apply that fire as your ships maneuver on target. Note also that the turret version of this command does note enforce any subsystem priority and will instead attack any available subsystem. Use wisely, commander.

Recommended patterns:

* Attack engines (repeat on new target) : to get control of the battlespace

* Attack engines -> attack missiles -> attack med turrets -> normal attack command : is my standard pattern to use bees to kill something dangerous.

* Attack engines -> attack missiles -> attack hvy turrets : to disable something for destroyers to mop up

* Attack engines -> attack shields (repeat on new target) : if you have shield piercing weapons to rapidly remove hostile defences.

* Attack station storage (repeat on new target) : to cripple a hostile economy quickly and efficiently

See here for a demonstration: https://youtu.be/lxINgqgoo7U

1.1 update video here w/ fixed icon: https://www.youtube.com/watch?v=XuIgBJZ86S4

2.0 update video here: https://youtu.be/FqfZG0Jiw-Q

2.1 update video here: https://youtu.be/7WC-eeMZ7EY

3.0 update video here: https://youtu.be/f5ppEomVwYQ

3.2 update video here: https://youtu.be/fpB0R7qzkwk

Install:
========
-Unzip to 'X4 Foundations/extensions/al_subsystem_targeting_orders'.

-Make sure the sub-folders and files are in 'X4 Foundations/extensions/al_subsystem_targeting_orders' and not in 'X4 Foundations/extensions/al_subsystem_targeting_orders'.

-Installation is savegame safe

Uninstall:
==========
-Delete the mod folder / unsubscribe on steam.

My Thanks:
============
-Forleyor, the maker of the wonderful Info Center mod ( http://www.nexusmods.com/x4foundations/mods/268 ) went to great pains to help me with the icon issue and was instrumental in resolving it. He was also provided a large fraction of the turret UI code

-SirNukes for the Mod Support API ( http://www.nexusmods.com/x4foundations/mods/503 )that made the right click integration possible

-Rovermicrover, the maker of several Improved * mods ( https://github.com/rovermicrover ) for some tips on how to better identify turret types and improve script performance

-runekn, the maker of the reactive docking mod (https://www.nexusmods.com/x4foundations/mods/676) for some lua simplification assistance

-Egosoft for making such a great game and supporting the mod community

History:
========
* 1.0, 2021-03-27: Initial release

* 1.1, 2021-03-27: Substantial refactor to address "question mark" icon issue. Thanks to Forleyor for helping figure it out.

* 1.2, 2021-03-28: Added German translation; modified heaviest weapon targeting routine to allow multiple instances of the order to select different targets from the list of heaviest available weapons instead of always selecting the same target (avoids massive overkill for torp runs, but will make standard gun runs a little less effective--though more cinematic!).

* 1.3, 2021-03-29: Improved target handling for wings. Wingmates with the "attack" assignment should now properly follow the targeting priorities of their wing leader.

* 2.0, 2021-04-02: Major feature release to support station targeting, provide generic disable command, and provide finer control over weapon targeting

* 2.1, 2021-04-03: Changed capital ship aggressor requirement when targeting subsystems other than station modules to require line of sight to the target subsystem on order initiation. Should reduce the number of destroyers trying to (ineffectually) fly around targets to gen a firing solution on targeted subsystems.

* 3.0, 2021-04-10: Added additional targeting priorities/commands for turrets

* 3.1, 2021-04-11: Fixed Steam version being unable to load UI.

* 3.2, 2021-04-14: Added clear turrets command and CN translation; Also improved xpath specificity to improve mod compatibility

* 3.2.1, 2021-04-15: Corrected CN translation file to remove invalid ampersand

* 3.3, 2021-04-16: Added optional check against Kuertee's UI Extension to allow for high compatibility mode to be triggered if present.

* 3.4, 2021-05-11: Added support for Wing Hotkeys Mod; Altered disable all targeting priority to target heavy turrets before light turrets. Altered the Line of Sight requirement for capital ships to NOT apply to carriers, so they may send their subordinates appropriately. Added attack all enemies as lowest priority targeting option for attack fighters turret commands. Lua refactored to unify library functions (thanks to runekn)

* 3.5, 2021-05-13: Significantly improved (fixed, really...) out of sector targeting performance. S/M ships and Carriers will now properly target appropriate subsystems in low attention mode. Other L/XL ships will instantly fail the line of sight check in low attention and cancel subsystem (but not station module) related orders--this seemed more reasonable then having destroyers instantly strip all subsystems without LOS or accuracy concerns.

* 3.5.1, 2021-05-22: Corrected menu display error in German translation.
Last edited by Alkeena on Sat, 22. May 21, 08:29, edited 15 times in total.

User avatar
Dj_FRedy
Posts: 229
Joined: Mon, 27. Jun 11, 05:58
x4

Re: New Mod: Subsystem Targeting Orders

Post by Dj_FRedy » Sat, 27. Mar 21, 17:18

Alkeena wrote:
Sat, 27. Mar 21, 11:22
Known Issues:
==================

The order icon presents as a giant questionmark. This is purely cosmetic and does not affect the functioning of the Mod. Any advice on how to fix this issue would be appreciated.
Hi @Alkeena,
Add the prefix 'order_' together with the order id, like this: <icon name="order_order_attack_engines"

Greetings
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.

User avatar
jocan2003
Posts: 629
Joined: Tue, 6. Mar 07, 17:48
x4

Re: New Mod: Subsystem Targeting Orders

Post by jocan2003 » Sat, 27. Mar 21, 22:05

Great work! Any chance to have the same for turret groups? I have tsome very turret for taking out subsystem in general but they never choose or almost never shoot them...

User avatar
Tanvaras
Posts: 170
Joined: Thu, 27. Nov 03, 10:45
x4

Re: New Mod: Subsystem Targeting Orders

Post by Tanvaras » Sat, 27. Mar 21, 23:01

This is a must have mod imo. These should of been base game commands, thanks to you that are now available. Well done!
“We don't make mistakes, just happy little accidents.”
“Talent is a pursued interest"
“Let's get crazy.”
“There's nothing wrong with having a tree as a friend.”

Bob Ross, 29 October 1942 - 4 July 1995

Scoob
Posts: 9921
Joined: Thu, 27. Feb 03, 22:28
x4

Re: New Mod: Subsystem Targeting Orders

Post by Scoob » Sun, 28. Mar 21, 01:26

This looks great, I'll be adding it to my Mod list for sure. Hopefully Dj_FRedy's advice allows you to fix that irksome giant question mark icon issue. I assume it's there as the game doesn't know what Icon it's supposed to use, I know there were issues in vanilla that showed this when Egosoft were adding new commands (IIRC), so you've encountered the same thing the Devs themselves did I expect.

Scoob.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: New Mod: Subsystem Targeting Orders

Post by Alkeena » Sun, 28. Mar 21, 03:57

Version 1.1 has been released, and the icon issue is no more!

https://www.youtube.com/watch?v=XuIgBJZ86S4

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: New Mod: Subsystem Targeting Orders

Post by Alkeena » Sun, 28. Mar 21, 14:31

Updated with German translation, thanks to Vali_Lutzifer!

(Also adjusted heave weapon targeting logic a bit)

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: Subsystem Targeting Orders

Post by Alkeena » Mon, 29. Mar 21, 08:38

Updated to 1.3: Improved target handling for wings. Wingmates with the "attack" assignment should now properly follow the targeting priorities of their wing leader.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: Subsystem Targeting Orders

Post by Alkeena » Sat, 3. Apr 21, 05:29

Updated to 2.0:

Demo video here: https://www.youtube.com/watch?v=FqfZG0Jiw-Q

* Added filters to better control which orders appear in the right click menu
* Player will only see subsystem targeting orders if target is not owned by the player
* Each subsystem targeting order will only appear if a relevant active/destroyable subsystem is present on the target

* Modified existing commands
* Attack Shields will now only target shield generators larger than M size. This is based off of the module tags, so if a modder has added subsystems that do not respect Egosoft's tagging pradigm the subsystem may not be targeted.
* Attack Weps, Lightest First has become Attack Weps, Med Turrets -- will only target M size or smaller turrets. This is based off of the module tags, so if a modder has added subsystems that do not respect Egosoft's tagging pradigm the subsystem may not be targeted.
* Attack Weps, Heaviest First has become Attack Weps, Hvy Turrets -- will only target turrets larger than M size. This is based off of the module tags, so if a modder has added subsystems that do not respect Egosoft's tagging pradigm the subsystem may not be targeted.

* Added new commands
* Attack Weps, Main Batteries -- Will attack fixed weapons (not turrets) on the ship. This targeting behaviour was originally rolled into the Attack Weps options but it turns out that the armoured cowling around, for example, the Behemoth's main batteries is actually pretty effective at protecting them and player ships can have a hard time finding a good attack vector without some manual help on initial positioning (in fact it's not clear that the logic is picking up on the batteries being obstructed by the hull and I haven't yet found a fix for it). This often resulted in the target dying before the weapons were disabled if ships didn't have a good initial vector. Use wisely, commander.
* Attack Subs, Disable All-- Single command that attacks all of the designated target's subsystems in the following order engines -> missile launchers -> med turrets -> hvy turrets -> shields -> batteries. Note that this substantially amounts to an order to kill the target, but to do it much slower than if you'd just given a standard attack command since few ships are able to survive the sustained fire it takes to completely strip them while it still taking longer than necessary to apply that fire as your ships maneuver on target. Use wisely, commander.
* Attack Station Docks -- Attack the designated station's dock modules
* Attack Station Storage -- Attack the designated station's storage modules
* Attack Station Production -- Attack the designated station's production modules
* Attack Station Def. Platforms -- Attack the designated station's defense platforms (including Admin towers)
* Attack Station Shipyard Platforms -- Attack the designated station's ship construction/maintenance platforms

* Modified targeting logic
* Station module targeting orders will select the matching station module that is closest to the ship at the time the order is initiated (or recycled, if multiple matching modules are present and the first target is destroyed). This will generally focus fire, but positioning of your fleet at order initiation is important and your fleet could be split up if they spread out. Also note that these commands are functionally no different from the standard Egosoft attack commands--they just set the target. Your ships may still wander into fire, as per vanilla behaviour.
* Other orders will select target priorities based upon ancillary stats: M turrets order selects for the lowest max hull values; L turrets/battery/missiles selects for the highest max hull value; shields selects for the highest max shield value. The target will be randomly selected from the 3 highest scoring targets within the subsystem group.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [Mod] Subsystem Targeting Orders

Post by Alkeena » Sun, 4. Apr 21, 04:52

Update to 2.1 to alter capital ship aggressor targeting behavior to require line of sight at initiation. I could be convinced to revert if folks really preferred the prior behavior but I think this just generally performs a bit better.

Demonstration video here: https://www.youtube.com/watch?v=7WC-eeMZ7EY

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [Mod] Subsystem Targeting Orders

Post by Alkeena » Sat, 10. Apr 21, 21:55

Updated to 3.0 with turret commands and secondary targets.

User avatar
Tanvaras
Posts: 170
Joined: Thu, 27. Nov 03, 10:45
x4

Re: [Mod] Subsystem Targeting Orders

Post by Tanvaras » Sun, 11. Apr 21, 00:17

Alkeena wrote:
Sat, 10. Apr 21, 21:55
Updated to 3.0 with turret commands and secondary targets.
/Monty Burns Voice on

"Excellent!"

/Monty Burns Voice off.
“We don't make mistakes, just happy little accidents.”
“Talent is a pursued interest"
“Let's get crazy.”
“There's nothing wrong with having a tree as a friend.”

Bob Ross, 29 October 1942 - 4 July 1995

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [Mod] Subsystem Targeting Orders

Post by Alkeena » Sun, 11. Apr 21, 16:17

Updated to v3.1 to address UI not loading on Steam distribution

For any modders that might find this comment down the line I'll explain a bit more fully since it was really unintuitive considering the normal X4 mod paradigms...The situation:

* Steam workshop distribution toolset packs the files prior to distribution, but leaves the author with the loose version.
* The LUA loader can't look into packed files...
* Steam WILL distribute txt files in the root directory (readme/license, etc), however...

Solution: distribute lua files as .txt files and adjust relevant paths to point to your root level extensions directory instead of extension/ui. Feels very dirty, but works. Wish I could just distribute the loose files instead, but here we are.

boogieman335
Posts: 222
Joined: Tue, 4. Sep 07, 22:32
x4

Re: [Mod] Subsystem Targeting Orders

Post by boogieman335 » Mon, 12. Apr 21, 03:47

Excellent mod. This should already be part of the game. The Dev's should take note.

monish_05m
Posts: 21
Joined: Wed, 10. Aug 05, 15:57
x3tc

Re: [Mod] Subsystem Targeting Orders

Post by monish_05m » Mon, 12. Apr 21, 08:14

Hello,
1). Is there a way to set priorities for multiple ships?
2). Do ships in fleet follow commanders behaviour?

Also, 1 request could you add just a basic target XL ship, target L and above, Target M and target M and below command as well.
Since ego turret behaviour is crap, I just want my ships to prioritize ships based on classes first and switch from high threat to low threat if no class is found.

Thanks for the mod.

runekn
Posts: 29
Joined: Sun, 21. Mar 21, 19:24
x4

Re: [Mod] Subsystem Targeting Orders

Post by runekn » Mon, 12. Apr 21, 14:20

Can diff selection paths be improved? Trying to add elements to a script, but it breaks yours since it relies on indices.

For example this selection breaks if I add a <do_if> to <init>

Code: Select all

//aiscript/init/do_if[5]/set_value[@name='$squadorder']

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [Mod] Subsystem Targeting Orders

Post by Alkeena » Mon, 12. Apr 21, 16:49

runekn wrote:
Mon, 12. Apr 21, 14:20
Can diff selection paths be improved? Trying to add elements to a script, but it breaks yours since it relies on indices.

For example this selection breaks if I add a <do_if> to <init>

Code: Select all

//aiscript/init/do_if[5]/set_value[@name='$squadorder']
I can try to take a look at this, probably in a few days though as finding the time during the week can be a bit rough.

My recollection is that I had some difficulty identifying the appropriate xpath because the conditionals rely on string comparisons, which in turn means I would require three layers of quotation to reference it for a diff. Do you know how to escape quotes that works with Ego's parser? I tried simple \ escaping but it didn't do the trick.

runekn
Posts: 29
Joined: Sun, 21. Mar 21, 19:24
x4

Re: [Mod] Subsystem Targeting Orders

Post by runekn » Mon, 12. Apr 21, 17:17

Alkeena wrote:
Mon, 12. Apr 21, 16:49
Do you know how to escape quotes that works with Ego's parser? I tried simple \ escaping but it didn't do the trick.
Unfortuantly not. Only recently started modding myself.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [Mod] Subsystem Targeting Orders

Post by Alkeena » Mon, 12. Apr 21, 17:35

runekn wrote:
Mon, 12. Apr 21, 17:17
Alkeena wrote:
Mon, 12. Apr 21, 16:49
Do you know how to escape quotes that works with Ego's parser? I tried simple \ escaping but it didn't do the trick.
Unfortuantly not. Only recently started modding myself.
Fair enough. Don't want to leave you in a lurch, and I really am being a bit of a bad citizen by referencing by index like that. I'll try to find the time tonight after work, but can't promise I'll be able to get it done.

runekn
Posts: 29
Joined: Sun, 21. Mar 21, 19:24
x4

Re: [Mod] Subsystem Targeting Orders

Post by runekn » Mon, 12. Apr 21, 19:19

Alkeena wrote:
Mon, 12. Apr 21, 17:35
runekn wrote:
Mon, 12. Apr 21, 17:17
Alkeena wrote:
Mon, 12. Apr 21, 16:49
Do you know how to escape quotes that works with Ego's parser? I tried simple \ escaping but it didn't do the trick.
Unfortuantly not. Only recently started modding myself.
Fair enough. Don't want to leave you in a lurch, and I really am being a bit of a bad citizen by referencing by index like that. I'll try to find the time tonight after work, but can't promise I'll be able to get it done.
Don't need to rush anything just for me :)
I can work around it.

Post Reply

Return to “X4: Foundations - Scripts and Modding”