Space Engineers

Space Engineers

805 ratings
TCES | Turret Controller Enhancement Script
29
7
6
5
3
3
3
2
2
2
69
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
642.447 KB
Feb 14, 2022 @ 12:01pm
Jan 1, 2025 @ 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)
183
Apr 8 @ 11:13am
PINNED: Help/Questions - TCES
Whiplash141
4
Dec 10, 2024 @ 7:55pm
Can Camera Sync With Turret?
DangerNoodle13
567 Comments
Whiplash141  [author] Apr 11 @ 12:28pm 
My weapon salvo script does that. I prefer to make specialized, performant scripts that focus on a task. Monolith scripts are awful to use and maintain.
CappedPluto Apr 11 @ 4:23am 
it would be cool if there was a configuration to stagger fire the other barrels from the multi rotor thingy. Other than that, this thign is awesome
pfg Apr 4 @ 12:03am 
Thanks much - straight forward enough to figure out - now have to decide how close to the max to take it. three pirates down so far - awesome script
Whiplash141  [author] Apr 3 @ 10:37pm 
I misremembered, the deadzones are in the CTC custom data, change the "Weapon deadzone count" to something non-zero, run setup, then configure to your heart's content. Deadzones will prevent weapon firing when both the azimuth rotor angle and the elevation rotor angle fall within any of the deadzones that you specify.

Each deadzone is a combo of an elevation range and azimuth range, so yes they are related.
pfg Apr 3 @ 10:29pm 
ok but how ? like what exactly do i put in there ? and can they be related - like can the elevation dead zone be related to the actual azimuth value
Whiplash141  [author] Apr 3 @ 9:58pm 
@Yameson24
happy to hear it

@pfg
Ahh, you define those in the azimuth/elevation rotor custom data
pfg Apr 3 @ 9:06pm 
Having fun with this but one thing I'm stuck on. how, and where, do we define dead zones ?
Yameson24 Mar 7 @ 4:44pm 
Figured it out, I was using the tool function instead of setting it on the hotbar!
Whiplash141  [author] Mar 6 @ 11:50pm 
Two separate turrets? If so, yes. You can create a TCES group with one of the turrets and a SYNC group with the other rotor turret.
Yameson24 Mar 6 @ 10:52am 
Hey Whip, I'm very new to Space Engineers and am trying to utilize your script on the blue mining rover as a tester. the blueprint uses 2 separate subgrids with a rotor, piston, and drill for each. Am I able to control both at the same time? Thanks in advance!