Space Engineers

Space Engineers

765 ratings
TCES | Turret Controller Enhancement Script
28
6
7
5
2
2
3
3
2
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
642.447 KB
14 Feb, 2022 @ 12:01pm
1 Jan @ 5:42am
29 Change Notes ( view )

Subscribe to download
TCES | Turret Controller Enhancement Script

In 1 collection by Whiplash141
Whip's Scripts
22 items
Description
TCES | Turret Controller Enhancement Script


  Description
Howdy!

TCES enhances the functionality of the Custom Turret Controller block (CTC) in a few ways:
  • NEW! Enables mouse aimed turret stabilization when manually aimed! TCES will try to automatically cancel the effect that ship rotation has on your aim so that rough terrain or evasive maneuvers don't mess up your gunner's aim.
  • Automatically configures Custom Turret Controller blocks using block groups. This helps fix a very annoying bug[support.keenswh.com] and means you don't need to manually configure the Custom Turret Controller.
  • Allows you to use more than two rotors/hinges for each CTC. This means you could have turrets with multiple elevation rotors for example.
  • Rest angle support. Turrets will automatically return to configured rest angles after a set amount of idle time.

Additionally, you only need one script to manage all of your custom turret controllers.





  Instructions
Script Setup
  1. Group each Custom Turret Controller block with all the blocks that it will control with a group named TCES <Unique Name Tag> (See below section for more info).
  2. Open a programmable block and load this script from the "Edit" menu.
  3. Configure rotor/hinge custom data if you want rest angles.
  4. Run TCES with the argument setup to process any new groups or custom data changes.

TCES Groups
TCES groups should be named like the following:
TCES <Unique Name>
where <Unique Name> is... well... a unique name.

Each Custom Turret Controller should have its own, unique group with all of the blocks that it controls (including itself!). You need one TCES group per custom turret.

TCES will automatically configure the custom turret controller in each group with:
  • A Rotor/hinge named "Azimuth" will be used as the azimuth rotor
  • A Rotors/hinge named "Elevation" will be used as the elevation rotor
  • Cameras, weapons, and tools in the group
  • Any extra rotors are automatically controlled by TCES. This allows you to create custom turrets with multiple elevation rotors for example. (See the "Extra Rotors" section below for more details)

At minimum, a TCES group should have the following blocks:
  • The custom turret controller that it should manage.
  • At least one rotor with name tag "Azimuth" OR one rotor with name tag "Elevation".
    • You do not need both an azimuth and an elevation, you only need one
  • At least one camera, weapon, or tool.

Extra Rotors
If you want TCES to control extra rotors/hinges in addition to your Azimuth and/or Elevation, the following conditions must be met.
  1. A camera, weapon, or tool must reside on the same grid as the rotor/hinge head of the Azimuth or the Elevation
  2. Each extra rotor must have a camera, weapon, or tool on the same grid as it's rotor/hinge head.

If these two constraints are satisfied, the extra rotors will point their cameras/weapons/tools in the same direction as the Azimuth and Elevation are pointing theirs. The script will also synchronize weapon firing and tool activation across these extra rotors.

Note: Due to limitations of the API, in order for you to be able to manually fire the weapons/tools on extra rotors, you need at least one weapon or tool (a camera alone is not enough) for constraint (1) above. This is because the script tries to read the state of weapons on the main rotors and sync them across the extra rotors. Cameras do not change state when the turret is manually fired, but weapons and tools (like drills/welders) do.

SYNC Groups
SYNC groups allow you to synchronize the aiming of a custom rotor turret to a particular custom turret controller. The custom turret controller does not need to be in a TCES group, but if it is, the SYNC group will inherit the configured turret stabilization, rest angles, and weapon deadzones from the TCES group.

SYNC groups should be named like the following:
SYNC <Unique Name>
The <Unique Name> does not need to correspond to a TCES name to function.

A SYNC group should have the following blocks:
  • The custom turret controller that it should synchronize to.
  • At least one rotor (name does not matter)
  • At least one camera, weapon, or tool.

This script will attempt to aim the SYNC turret in the same direction as the grouped custom turret controller and it will also synchronize weapon/tool firing state.

Rotor Configuration
To configure rotor/hinge rest angles and stabilization, you must first have the rotors in a valid TCES group. Then, once the group is recognized by the script, you should see the following in the rotor's custom data:
[TCES - Rotor] Rest angle (deg)=none Enable stabilization=False
Configure these to your desired values, then run the argument setup to process this custom data change.

General Configuration
To configure general TCES parameters, open the custom data of the programmable block and edit the settings to your liking. The custom data should look like the following:
[TCES - General] Group name tag=TCES Azimuth rotor name tag=Azimuth Elevation rotor name tag=Elevation Should auto return to rest angle=true Auto return to rest angle delay (s)=2 Draw title screen=true
After you are done making changes, run the argument setup to process any custom data changes.


  Arguments
TCES supports the following arguments:
Argument
Description
rest
Sends all inactive turrets to their rest angles.
setup
Refetches all blocks, block groups, and reprocesses custom data.


  Author's Notes
I plan to add more features to this script as the CTC API becomes more complete like:
  • Done! Mouse aimed turret stabilization
  • Better friendly fire avoidance
  • Done! Automatic return to rest angle

Also, I made the sprites for the title screen using the SESpriteBuilder tool that I developed: https://gitlab.com/whiplash141/spritebuilder/-/wikis/home. It may be of use to scripters trying to visualize and design sprites :)

I'll probably do more polish passes, but I'm pretty sure this should work for most uses. Enjoy and let me know if y'all have any issues.

Oh, and the acronym is pronounced like "tea-sis" :)

The VTOL in the first GIF is a modified version of Consty's Blackwolf that uses TCES instead of MART.

- Whiplash141
Popular Discussions View All (2)
174
20 Jun @ 10:08am
PINNED: Help/Questions - TCES
Whiplash141
4
10 Dec, 2024 @ 7:55pm
Can Camera Sync With Turret?
DangerNoodle13
512 Comments
Vomsay 6 May @ 3:26pm 
Anyone having problems with the latest Keen update?
My custom turrets with TCES are completely bugged :(
WardenWolf 2 May @ 4:08pm 
I know it's a little outside the scope, but there's literally nothing out there that does this automatically. I (and I'm sure others) would absolutely love if there was an option to automatically reset the orientation on our vanilla turrets as well. Or an option to trigger a timer block so we can tie actions to end of combat.
spiro9 | peef 30 Apr @ 3:51pm 
Does this script work for grouping single-block turrets? I'd like to have synchronized simultaneous control of groups of turrets for the sake of barrage and broadside style attack sequences.
Whiplash141  [author] 6 Apr @ 12:21pm 
The automatic deviation angle computes the maximum allowed aim deviation angle by taking into account the radius and distance to your target.

For example: if your target is 1000m away and has a radius of 50m, the script would compute the max deviation angle as atan(50/1000) or roughly 2.9 deg. If your guns are not firing with that setting on it is because the guns are not aiming within 1 target radius of the target. (they are likely not tracking precisely enough)

You can of course turn this off, but you will likely be wasting ammo as a result.
xxmanofmemesxx 5 Apr @ 9:20am 
I was doing some testing of SPAA/PD vehicles and noticed some would track but not engage missiles launched by the test aircraft. Turning off the angle deviation calculation allowed the vehicles to engage.

I'm now interested in what the angle deviation calculator does and where it is best applied for future builds. What benefits does it have over static deviation values and what weapons or situations does it best work for?
DazeyDream 2 Apr @ 9:35am 
TCES v1.14.2. I have MART running too, but the MART prog block is turned off while TCES and custom turret are turned on (toolbar toggle to swap between auto aim and manual aim while driving)

I've uploaded the tank. If you fire the cannons with the toolbar it will fire the right side cannons a second time after reload. Doesn't look like it does this if it's the ctc firing.

https://sp.zhabite.com/sharedfiles/filedetails/?id=3456773193
Whiplash141  [author] 1 Apr @ 10:05pm 
@DazeyDream:
Any other scripts running? Also what version of TCES?
DazeyDream 1 Apr @ 5:55pm 
Having an issue where if one elevation guns fire, the other elevation will also fire in sync, but will fire a second time after the assault cannons reload.
wtdtd 22 Feb @ 12:21pm 
If it is not too much work, make it an option so people can choose between server preformance and the accuracy of the rest position.
Whiplash141  [author] 22 Feb @ 12:59am 
Its a performance consideration I built in. Once it gets decently close to the rest angle, it puts the turret control loop to sleep to save on some processing power. I could probably make the cutoff a bit tighter tbh.