Barotrauma

Barotrauma

37 ratings
Auto Operate Toggle Turrets
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
2.334 MB
12 Apr, 2023 @ 9:42pm
19 Apr, 2023 @ 6:12pm
3 Change Notes ( view )

Subscribe to download
Auto Operate Toggle Turrets

Description
AUTHOR'S NOTE: As of 1.5.7, this mod is basically outmoded - all functionality below should now be available in the vanilla game. Thank you for your prior support.


Basics
This mod replaces ALL subeditor and in-game turrets with versions that have two extra wiring pins: set_state and state_out. The set_state pin allows Auto Operate to be toggled on and off for each turret. state_out simply gives back whatever has been given to set_state. Even though this affects both pre-existing and new turrets in the subeditor and normal sessions, Auto Operate for a given turret will always be off by default and will not turn on until given an appropriate signal via wire or manual editing.


Auto Operate
Auto Operate is a dev-controlled feature, introduced in 1.0, being the devs' version of auto turrets. While Auto Operate is active on a turret, it will track and fire at targets by itself; however, it will still need power and ammo supplied as normal. Without this mod, the only way to activate Auto Operate on a turret is through the subeditor. This means that Auto Operate can only be used in-game on custom subs with turrets that have already had AO activated (and then it can't be turned off!). This mod allows Auto Operate to be toggled on and off at will with a simple lever and wire, manual input, or other, more complex setups.

In case the above didn't make it clear, let this be a more direct disclaimer: I have no control over how exactly Auto Operate works; that is controlled completely by the devs. This mod is ONLY for turning AO on and off as-is for individual, in-game turrets.


How to Use
In vanilla Barotrauma, Auto Operate for a given turret can be turned on and off only through the subeditor. Other values relevant to Auto Operate can also be adjusted here. Under a turret's options you will find a section that looks like this:




This mod adds the ability to toggle Auto Operate on any turret via a new wiring pin, set_state.

ORIGINAL TURRET WIRING PANEL:




MODDED TURRET WIRING PANEL:




As long as the turret's "state" is set to '1', Auto Operate will be on/active. If "state" is '0', Auto Operate will be off. state_out puts out whatever value was last given to set_state.
The simplest way to set this up is to wire a lever or switch to set_state, but more complex setups are certainly possible.

Alternatively, interacting with a turret's wiring panel in-game will also bring up the edit panel; setting Value to 0 or 1 manually will have the exact same effect as if it had been transmitted via wire to set_state. However, this method will generally require you to be outside the sub, where the turret is.




Technical Notes

  • The turret's "state" will only accept values 0 or 1. If you try to set it to anything else like '13' or 'text', the turret will simply continue to use the last valid input. In other words, if AO is on and you give "state" an invalid input, AO will stay on.

  • Internally, what I've actually done is given every turret a Memory Component. Thus, the set_state pin will take pretty much anything you give it, but, once again, the modded code only does something with a 0 or 1. This is also why the turret shows a Value box alongside the wiring panel and lighting color options in-game.

  • Overall, the extra code for this mod is incredibly simple, but it does in fact override/replace the base code for each turret. Feel free to contact me over Steam or Discord (agentdelta.13) for help integrating this into other mods you might have if this doesn't work as-is.

  • This mod also overrides/replaces normal and large turret hardpoints, meaning any wiring you put in place on the two new pins, set_state and state_out, will stay in place even if you remove or install a new turret at an outpost. Wiring will also "stick" when you swap out a turret for a different one.

  • This mod can safely be added to any in-progress (vanilla, no guarantees otherwise) campaign or session. It alters ALL in-game turrets, but "state" will always be 0 by default, so Auto Operate will never be activated for any turret unless you manually turn it on. Furthermore, it should not mess up any wiring already present on pre-existing turrets; it's only adding two new pins. If you remove this mod from a campaign or session already using this mod, the two modded pins will simply disappear and any wires connected to them will be left hanging loose as though manually disconnected. (Any turrets that had AO active at the time you removed the mod will likely still have it on with no way of turning it off; I have not tested this edge case.)

  • Even if you turn Auto Operate on for a turret in the subeditor, this mod will always override that particular setting, first turning it off by default, then taking any values given to set_state or the Value prompt beside the wiring panel.

  • As previously shown, Auto Operate has other options and settings that can be changed via the subeditor. If you apply this mod and then alter the extra Auto Operate options for a turret, those settings will persist and this mod will not alter them. If you use this mod without changing any of those settings or add it to an in-progress campaign or session, Auto Operate will simply use its default parameters. There is currently no way to change these extra settings once in-game. Furthermore, these extra settings will NOT persist if you swap the edited turret for a new one or a hardpoint. This is another "feature" that is controlled by the devs; they may or may not change this soon.



Huge thanks to WorkingJoe over on the Barotrauma Discord for providing the base code for this mod.

Any and all constructive criticism, questions, and requests are welcome and appreciated.
40 Comments
obsidianz 4 Jun @ 9:31am 
And it doesn't work, and not for your reason, it's broken in the vanilla version of the game too) HDD

They can't fix their own patch)HD
Agent Delta  [author] 4 Jun @ 8:20am 
I'm honestly not sure anymore, so much has changed now and I haven't updated this in a long time.
obsidianz 3 Jun @ 1:04am 
Does this mod still work?
I connect something, a turret, check the values ​​and it doesn't react to targets....
Agent Delta  [author] 15 Jul, 2024 @ 1:33pm 
Cool
Check out my Delta Maverick sub, if you like. It's a heavily-modified Barsuk with various added features specifically for solo pilots. Read the description and crack it open in the subeditor to see if there's any ideas you haven't already implemented or thought of.
The Seraph of Tomorrow 14 Jul, 2024 @ 11:15pm 
Who knows, maybe it's just user error on my end for not figuring it out. Though there sure isn't a guide on how so, that's on them either way.

Appricate the mob by the way, was able to use it as part of a person project to make a A.I. copilot, basically based on the Golden Age mods concept as the base. Can chat, Toggle auto-locks, Play music throughout the sub, turn on and off auto turrets (thanks to this mod), and maybe some other features once I learn how to do more with sub editing.
Agent Delta  [author] 14 Jul, 2024 @ 11:07pm 
...wow. I really thought they just implemented my idea practically verbatim.
Guess this mod will still see use for a while.
The Seraph of Tomorrow 14 Jul, 2024 @ 10:37pm 
Basically no, they added a toggle state pin to relays though not to turrets.

So in the base game I have no clue how to toggle the AO even though there are options saying it is suppose to be wire-able. So i got this mod instead that you made because it does add a pin I can just wire up to a wifi and call it a day,
Agent Delta  [author] 14 Jul, 2024 @ 10:18pm 
They originally weren't going to add it, but they ended up developing most of it and decided "sure I guess we'll add it", without putting too much effort into accessibility. They never really intended to fully incorporate AO into the main game but were ultimately persuaded by player interest.

In any case, do the vanilla turrets not just have a simple ON/OFF wiring pin for AO now? Is it still more complicated than that?
The Seraph of Tomorrow 14 Jul, 2024 @ 9:57am 
I am tempted to use this mod, as nothing in the game explains how to actually use the games built-in auto-operate toggle functionality. Idk why the devs add features without having any sort of site or guide to explain how the features work.
Agent Delta  [author] 18 Jun, 2024 @ 8:31am 
Yup, saw that that was coming out; thanks all for your support in this mod, glad to see the devs finally putting it to use themselves.