Space Engineers

Space Engineers

779 ratings
TCES | Turret Controller Enhancement Script
29
6
7
3
5
2
3
3
2
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
642.447 KB
Feb 14, 2022 @ 12:01pm
Jan 1 @ 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)
177
Jul 31 @ 11:29am
PINNED: Help/Questions - TCES
Whiplash141
4
Dec 10, 2024 @ 7:55pm
Can Camera Sync With Turret?
DangerNoodle13
527 Comments
DoubleRation 1 hour ago 
Hello, sorry for my silly question but how can I invert the controls of the rotor and the hinge?
Souls Sep 16 @ 10:45pm 
fair enough, thank you!
Whiplash141  [author] Sep 16 @ 9:39pm 
not for this script, no. But that is not an impossible task, it just has quite a few quirks
Souls Sep 16 @ 9:24pm 
Is there a good way (or any way) to set this up to handle elevation on hinges/rotors, but azimuth via main grid gyro? i.e. grid itself fully rotates for azimuth. The "Hold Alt" system isn't ideal as I generally use Digi's camera panning mod..
Liquighost Sep 16 @ 3:29pm 
that would be awesome if you could :D
Whiplash141  [author] Sep 16 @ 3:25pm 
hmm there isnt an ability to turn that functionality off, but i can look into adding it
Liquighost Sep 15 @ 2:51pm 
I'm making an IFV with an autocannon and rocket launcher one 2 separate rotors and I want them to sync together but I don't want both weapons to fire at the same time as each other is it possible to unsync the weapon firing?
Darth Porgus Sep 8 @ 5:43pm 
Does this Script also have all functionality that your turret slaving script has? Do I have to install both on 2 seperate programmable blocks if I want to have multiple turrets follow my targetting and shoot at one spot?
Cona6789 Aug 18 @ 3:04am 
I was using the chain cannon from extra cannons, no weapon core it yucky, as soon as i swapped it out for vanilla gatling guns it worked flawlessly
Whiplash141  [author] Aug 17 @ 10:50pm 
Idk what weapon mods you are using, but if they are weapon core based, they are incompatible with this script since WC fucks with the turret controller last time I checked. Also weapon core weapons don't show up as weapons to the script API so that is another fun wrinkle.