Barotrauma

Barotrauma

View Stats:
Solodric Oct 16, 2024 @ 12:32pm
Flood-Control System circuit design
As discussed in my other topic (https://steamcommunity.com/app/602960/discussions/0/4696783122978278217/), I've been working on rewiring the vanilla submarines using entirely in-game rewiring (no sub editor) to see just how powerful they can become. If I ever finish these, I intend to publish them as the 'Veteran' series (such as 'Barsuk Veteran', 'Orca Veteran', and so on), with the idea being to push these subs to the absolute peak they can achieve through in-game rewiring alone. I've decided to share my first major overhaul independently of the rest of the systems, as I think many people will find it very useful, and perhaps someone has an idea for a way to improve it!

Alright, preamble out of the way, let me explain what the Flood Control System (FCS) actually is. At its core, the FCS is an autodoor circuit, but there's actually a lot more going on here. You need to rewire every single door on the submarine (thankfully using reusable circuitbox designs - if you haven't used the Blueprints mod for copy/pasting circuitboxes, I highly recommend it, and I intend to release my circuit designs in Blueprint form) as well as the ballasts to make this work properly.

Let's start with the ballast circuit, as this is the heart of any flood control onboard a submarine. You will note I am saying 'ballasts' rather than 'pumps' because non-ballast pumps already have the correct logic - they just drain water until the water is gone. Simple. The problem with ballasts is that when the submarine receives a 'full dive' order (max downward vector), the ballasts stop draining water almost entirely; after a few tests I estimate the ballasts end up draining water under these conditions at somewhere between 1/50-1/100 of their potential, which is definitely not good when you're trying to keep water out of important rooms like the reactor room, junction room, and so on. Just because you want to full dive doesn't mean you want the rest of the sub to fill with water!

I can't post images here (I'll likely make guides for this stuff later), but the basic logic for the ballast is the following:

Multiply Velocity_Y by 1 and clamp it to 96 (not a typo: ninety-SIX). This will prevent the ballast from ever filling beyond 98% (again, not a typo: 96 target level = 98%. Look on the wiki for pumps if you're confused) with water. In this case, the multiplication is being solely used for its 'clamp' function - if anyone knows a better way of accomplishing this, please let me know.

Test the current water fill% (from the ballast's water detector) in a GreaterThan component against 98%; if the water level is above 98%, set the ballast's flow rate to -100. This will cause it to pump out water at max speed if the water level is over the maximum for any reason. Otherwise, push the (clamped) velocity_y to the targetlevel as normal.

Now, why 98% instead of 99% or 100%? Well, we can't use 100% because then we'd have no way to tell if the ballast is overfull. We want 98% instead of 99% so that there is wiggle-room to seal the ballast hatch in the event of a ballast breach; if the ballast is 99% full or more, the hatch will automatically try to close.

That brings us to the door circuit logic. Making the ballast drain water while full-diving is nice, but niche; what makes the flood-control system so powerful is how you manage the doors. Specifically, the logic we want is for the doors to remain OPEN unless there is a reason NOT to be open. This is the opposite of how most people wire their autodoors in Barotrauma, but defaulting to OPEN is much, much better than defaulting to closed.

First off, you can drain water dozens of times faster with open doors/hatches than closed. Second, having all of the doors open allows for maximum visibility and ease of movement around the submarine, as well as maximum sound propagation (at least I assume sound travels better through open doors). Third, if the doors default to OPEN, then seeing a CLOSED door immediately tells the crew that something is wrong, giving it some immediate conveyance value.

Now, under what circumstances should a door close? Well, the door circuit is a bit complex, so I won't try to break it down step-by-step. Instead, I'll just give a logic breakdown. Door remains open UNLESS::

- A hazard (living monster or fire) is detected on either side
- The drain-to room has (strictly! Not EQUAL!) HIGHER water than the drain-from room
- The drain-to room has over 20% water

Basically, you can think of this as 'door is open unless hazard', but 'water' is treated as a special-case hazard with unique rules. That being said, there is one additional bit of logic to the door controller circuit: The door is UNPOWERED under ALL CIRCUMSTANCES if CREW ARE DETECTED ADJACENT TO THE DOOR.

In other words, the door will not, under any circumstances, open/close if crew are near it. This is important, as it allows the crew to manually open/close the door while dealing with hazards. Otherwise, the door logic could easily get them killed. Also, if the door has sealed a hazard, someone needs to be able to open the door to get in there and deal with it.

There is different logic for hatches (vertical 'doors') compared to regular doors. Specifically, the hatch omits the checks for if the lower room (the drain-to room) has more water than the upper (drain-from) room; in fact, the only situation where the hatch closes due to water is if the drain-to room is over 20% flooded. Ballast hatches are identical except they only seal if the lower room (the ballast) is 99% flooded. Note that ductblocks should be treated like hatches, though I rarely discuss them in specific.

This door logic took a surprisingly long time to hammer out the specifics on. I'll definitely post a guide once I'm convinced the circuit is as efficient as it can be and I've made any other adjustments that come up as I finish the designs.


Okay, so now that I've covered what the circuitry does, here's how to actually use it. First, you need to designate drain-from and drain-to rooms. Generally, you want to draw a route between isolated rooms and the nearest ballast, and you want water to drain from ballast to ballast so that if any one of them is getting overwhelmed, the others can compensate. Due to the 20% flood-seal rule, water will generally distribute itself fairly evenly across the submarine on its way to the ballasts. In general it's fairly straightforward, but there may be special cases on submarines where you do need to put a little active thought into where to route water. Every room on the submarine should be part of this network, even if it's just to designate that room as a drain-from. Isolated rooms such as the gunnery compartments on the Herja benefit tremendously from this system, as they automatically close the door if there's more water in the drain-to room, but stay open otherwise so the gunners can see a bit of what's going on at a glance. With flood routes established, there are certain changes in submarine behavior that end up being very important - essentially many serious advantages.

First off, it will be extremely rare for any room in the submarine to have over 20% water unless that room is individually breached; as a result, a fixfoam detonator keyed to 40-50% water fill will almost never go off in an unbreached room, making automated repairs far more reliable than they are in a sub lacking a flood-control system. Likewise, fixfoam detonators will only be necessary in the most catastrophic breaches, as the sub will be able to trivially dispose of most floods (even full breaches) without actually filling with water (to the point that you can punch a full hole through the top hull of the Barsuk helm and fire a gun out into the open ocean without even wearing a diving mask, safely, without the helm ever flooding more than 20% or so). This means most breaches can be handled by crew with welding tools without needing to suit up or even wear diving masks, which is a huge boon to the sub's survivability.

Second, with the ballasts keyed to vent floodwater even when given a full-dive order, the helmsman no longer needs to manually give ascent orders during floods (assuming the helmsman was even aware of this problem to begin with; if not, the situation was even worse). This makes sub behavior under flood conditions much more reliable and allows the helmsman to focus on maneuver.

Third, because the doors are always open by default, most operations aboard the submarine will happen much faster than even with autodoors. There will be no delays waiting to open doors or running into them (or doors refusing to respond because multiple conflicting orders were given simultaneously), which makes tasks such as repairs, breach welding, fabrication, ammo carrying, etc., carry out much faster.

Fourth, because the doors only auto-close when a monster is near them, but auto-close otherwise, sometimes a funny situation will occur where a monster tries to charge someone on the other side of the door, the door closes, the monster backs off, and the door opens - allowing the crew to shoot a monster repeatedly without it ever getting to them. This is rare but amusing when it happens.

Fifth, because the doors automatically seal when there is a fire, the fire may run out of oxygen and burn out if no one manually opens the doors (presumably to go fight the fire anyway).

Sixth, because the doors automatically seal (living) monsters into rooms, it is possible to create an internal-security system with a flashbang detonator. By using an extra motion sensor to determine if crew are in the room, the following logic can be used:
If NO CREW are in the room AND a (living) monster is detected AND the doors are closed AND the doors have been closed for at least half a second, detonate flashbang. That last bit, about the doors needing to be closed for half a second, is because the flashbang can otherwise detonate while the door is mid-closure and stun crew on the other side.

Seventh, due to the flood-control logic, mudraptors are generally the only threat inside of a submarine (I haven't seen the mantis monsters yet, they may also be a problem). Most monsters on Europa are pretty weak on land, and with high-speed drainage they won't be able to force a room to flood unless they stay near the doors (thus keeping them closed). You can exaggerate this behavior by rigging a fixfoam detonator to go off if a (living) monster and high volume of water are detected simultaneously (almost certainly indicating a breach), near-guaranteeing the monster will have to fight on dry land. This helps crew fight monsters in a variety of ways: they don't have to rush to get diving suits or diving masks, most monsters are nearly immobile on land, and even mudraptors are both slower on dry land and have weaker attacks (their posture also exposes their less-armored underbelly).

Eighth, this flood-control logic makes it possible to rig up an automatic fire suppression system without risking significant submarine flooding, although doing so is tricky. Essentially, you need to hijack the flood-routing logic to deliberately let water into the sub and direct it to the room on fire. Compared to doing this normally, the big advantage here is that you won't cause undue flooding aboard the submarine that will take a long time to drain; once the fire is gone the water can drain near-instantly without any crew intervention.

Ninth, it's fairly straightforward to integrate ballast-flora countermeasures with this system without running the risk of making the submarine flood-vulnerable. As long as the sub has multiple ballasts, you can simply force one to drain and cut the power to the pump - by overriding the drain-to logic for the ballast, the hatch (and ductblocks) will automatically close when water is detected, so any floods will find their way to other ballasts while the flora is being addressed.

Tenth (yes, really) this system makes the submarine much more resistant to bottom-up floods, which are normally extremely difficult to handle. If a ballast is breached, it will be forced over 99% full, which will cause the ballast hatch to close (at least as long as no crew are nearby). You can even force a pulsed output to force the hatch closed even if crew are nearby, as long as the hatch goes to its unpowered state immediately afterwards (so crew can manually open it to deal with the breach). Ductblocks will likewise seal if a lower room is above 20% flooded (99% if ballast), meaning a room can't overflood and leak into upper rooms (a real problem with the default wiring). As in the case with ballast flora, having one sealed ballast just means the other ballasts will take on the job of dispersing floodwaters, and will generally not cause the submarine any real problems dealing with floods. Ballasts should generally have a 'high pressure' triggered fixfoam detonator in case of such breaches (in fact, every room should generally have a high-pressure fixfoam detonator, but it's especially important for ballasts).


Phew, well, that's done. I'm eager to hear the community's thoughts and suggestions on the flood-control system.
Last edited by Solodric; Oct 16, 2024 @ 12:36pm
< >
Showing 1-9 of 9 comments
Buggy Boy Oct 17, 2024 @ 1:53am 
Sorry, had to skip the last 3/4 as I have other things to do with my day, however what I read about ballast pumps being used for flood control during a full dive makes perfect sense, kudos for the concept!

On the other hand, the whole concept of an efficient flooding control system could unbalance the game somewhat, making it too easy. A big part of the game, especially multiplayer, is how to survive when things go wrong and the sub starts sinking downwards in an uncontrolled dive, that's when the crew either pulls together or all hell breaks loose!

In a 2-player game we modified the Orca 2 to have a ridiculously efficient flood control system (starting with a vanilla Orca 2, in-campaign wiring only), and with a few sub upgrades this quickly became rather OP in terms of surviving what would normally have seen us in an uncontrolled dive into the abyss, instead the sub barely moved in the vertical plane, dive control was never a problem even during the worst attacks.

Maybe your FCS would appeal to people who prefer their campaigns to run as if their sub had an impenetrable shield around it, and the enemies were just an annoyance that had to be dealt with, but personally I prefer the rag-tag struggle that the vanilla systems provide. Yes, maybe I will do a little bit of flood control (opening a hatch to let more water into the ballast instead of just one puny duct, etc), but I still want that sense of jeopardy and the need to avoid being smashed by large enemies, and that sense of achievement when surviving an onslaught and getting the sub ship-shape again after it's been beaten up and has been sitting on a shovel full of sand (see Das Boot).
Last edited by Buggy Boy; Oct 17, 2024 @ 1:56am
Solodric Oct 17, 2024 @ 2:48pm 
Originally posted by Buggy Boy:
Sorry, had to skip the last 3/4 as I have other things to do with my day, however what I read about ballast pumps being used for flood control during a full dive makes perfect sense, kudos for the concept!

Certainly understandable. It's quite a lengthy post, but I was writing it partially as a reference guide and will likely port a lot of it over to a Steam Guide later, so that's somewhat intentionally.


Originally posted by Buggy Boy:
On the other hand, the whole concept of an efficient flooding control system could unbalance the game somewhat, making it too easy. A big part of the game, especially multiplayer, is how to survive when things go wrong and the sub starts sinking downwards in an uncontrolled dive, that's when the crew either pulls together or all hell breaks loose!

In a 2-player game we modified the Orca 2 to have a ridiculously efficient flood control system (starting with a vanilla Orca 2, in-campaign wiring only), and with a few sub upgrades this quickly became rather OP in terms of surviving what would normally have seen us in an uncontrolled dive into the abyss, instead the sub barely moved in the vertical plane, dive control was never a problem even during the worst attacks.

The FCS I've designed absolutely makes the game a lot easier. It can allow submarines to punch way above their weight-class. Of course, you could say the same about any rewiring efforts whatsoever - all of them make the game easier, and it's your decision whether or not that's something you want in your game. You can beat the game with a Barsuk and a sufficiently-experienced crew, it's just very difficult. Barotrauma lets you set your own challenge level and how much burden you want to put on your crew, and there are plenty of mods that can push difficulty high enough to demand such efforts.

The Veteran series I'm working on is explicitly built around pushing vanilla submarines to their absolute peak performance. Find the limit so that we know what the limit IS. How easy can the game be if you rewire everything (in-game, not sub editor) to perfection? Just how much better can a dedicated engineer make a submarine if they do everything they can? The FCS is part of that series, and I've shared it because some people may find it useful. I think it's particularly good for folks running singleplayer games, where plenty can still go catastrophically wrong even with such strong flood-resistance.


Originally posted by Buggy Boy:
Maybe your FCS would appeal to people who prefer their campaigns to run as if their sub had an impenetrable shield around it, and the enemies were just an annoyance that had to be dealt with, but personally I prefer the rag-tag struggle that the vanilla systems provide. Yes, maybe I will do a little bit of flood control (opening a hatch to let more water into the ballast instead of just one puny duct, etc), but I still want that sense of jeopardy and the need to avoid being smashed by large enemies, and that sense of achievement when surviving an onslaught and getting the sub ship-shape again after it's been beaten up and has been sitting on a shovel full of sand (see Das Boot).

If someone wants an overpowered sub straight-up, there's little reason to go to the trouble of implementing my FCS. They could just go download any of the dozens of insanely OP subs on the workshop, and that's what most people so-inclined will do. It feels like you're characterizing an alternative playstyle as essentially cheating, though.

Barotrauma is a game where the challenge is split - at the player's discretion - between preparation and improvisation. Most problems can be pre-solved with good preparation, or you can just figure it out in the moment and adapt. What you've described is that you prefer to adapt in the moment, but I think it's a bit rude to characterize players who prefer to engage in iterative design and engineering to mitigate problems as preferring to run a challenge-free game. There is genuine challenge in taking a submarine, identifying its flaws, working to solve them, and iterating on each flaw with those implementations over time.

That said, it's not like I fully disagree with you. There are some wiring tricks I call 'the dark side of wiring' that I am deliberately avoiding even with my Veteran series, because they're outright exploits. The best example of this is that it's possible to remove junction boxes from the game entirely by abusing an oddity in the wiring logic with relays. I refuse to do that on the Veteran subs. Pre-Hoist the Sails ARCs were also too strong.

The FCS is kind of borderline when it comes to balance. You can't call it an exploit - it's a really straightforward use of vanilla wiring and systems - but it's so much stronger than the default setup that it definitely changes the vibe of the game substantially. That said, it's far from an auto-win, especially in singleplayer - remember, in singleplayer, there are no respawns and losing a single crewmate is often grounds to declare mission failure and retry. Even with a perfect FCS, there's tons of ways to lose crew when things get rough. In multiplayer, difficulty can be modulated with permadeath/iron man mode and similar.

EDIT: Edited for clarity/tone.

Second Edit/PS: It would be really helpful to have some experienced players try out the Veteran subs and make a judgement call on which systems are overpowered vs balanced for different playstyles, so I could produce a toned-down version of them for people who want to skip rewiring but still want proper challenge.
Last edited by Solodric; Oct 17, 2024 @ 2:50pm
DECAFBAD Oct 18, 2024 @ 11:59am 
The time it took you to type out these comments is more than I spent creating the assemblies below. Know that a well isolated sub that seals off flooded rooms is a death trap in its own, and where you were able to patch a hole before, you'll simply die without a suit.

https://steamcommunity.com/sharedfiles/filedetails/?id=2582199263

https://steamcommunity.com/sharedfiles/filedetails/?id=2863218300

My favourite:
https://steamcommunity.com/sharedfiles/filedetails/?id=2844599549
Buggy Boy Oct 20, 2024 @ 12:31am 
Originally posted by Solodric:
What you've described is that you prefer to adapt in the moment, but I think it's a bit rude to characterize players who prefer to engage in iterative design and engineering to mitigate problems as preferring to run a challenge-free game.

I was just thinking of one example in particular - a public server I joined where it seems their entire aim was to kill everything including the endworm (this was during Early Access before the official 'ending' was added) without the sub taking so much as a scratch, if that happened they immediately restarted the round to try again. They did have a massively OP setup, so that's the sort of player I was thinking about when I made my comments about having an impenetrable barrier around the sub. Nothing to do with using smart design and engineering skills, just people who love to play OP stuff and expect to win every time.
Reeves Oct 20, 2024 @ 2:07am 
Originally posted by Buggy Boy:
Originally posted by Solodric:
What you've described is that you prefer to adapt in the moment, but I think it's a bit rude to characterize players who prefer to engage in iterative design and engineering to mitigate problems as preferring to run a challenge-free game.

I was just thinking of one example in particular - a public server I joined where it seems their entire aim was to kill everything including the endworm (this was during Early Access before the official 'ending' was added) without the sub taking so much as a scratch, if that happened they immediately restarted the round to try again. They did have a massively OP setup, so that's the sort of player I was thinking about when I made my comments about having an impenetrable barrier around the sub. Nothing to do with using smart design and engineering skills, just people who love to play OP stuff and expect to win every time.
How do you jump from rewiring vanilla sub to do things smarter to creating and using op stuff in editor, where you can input any absurd number, man...
Buggy Boy Oct 20, 2024 @ 2:37am 
Originally posted by Reeves:
How do you jump from rewiring vanilla sub to do things smarter to creating and using op stuff in editor, where you can input any absurd number, man...

The method is unimportant, it's the fact that in that server they were intent on a 'perfect' run, that was just an example to clarify my point about how some people like to play OP subs, but for anyone else who happens to join that server expecting normal gameplay it may turn out rather boring.
Solodric Oct 20, 2024 @ 10:37am 
Originally posted by Buggy Boy:
I was just thinking of one example in particular - a public server I joined where it seems their entire aim was to kill everything including the endworm [...] without the sub taking so much as a scratch

Ah, fair enough. Sorry I misunderstood, then. It is true such people exist - in good enough numbers to drive the popularity of quite a few OP subs on the workshop, in fact - so I can see why you're leery of things that make the game easier, to be honest. I should have been more considerate of that.


Originally posted by Buggy Boy:
Originally posted by Reeves:
How do you jump from rewiring vanilla sub to do things smarter to creating and using op stuff in editor, where you can input any absurd number, man...

The method is unimportant, it's the fact that in that server they were intent on a 'perfect' run, that was just an example to clarify my point about how some people like to play OP subs, but for anyone else who happens to join that server expecting normal gameplay it may turn out rather boring.

It's true that the method is unimportant. Even if you stick to in-game rewiring, it's possible to make a sub that is far too powerful. There are certain tricks that I call 'the dark side of wiring' in Barotrauma where exploits can break the intended game balance. For instance, there is an exploit which can completely bypass junction boxes using relays and merging power grids, which removes most of the chance of fire and most of the repair work across the sub. Pre-Hoist the Sails ARCs were also overpowered.

These kinds of exploit-wiring are things I refuse to put on my Veteran sub series, as I much prefer to use developer-intended functionality to the limit rather than finding ways to outright break the game. To Reeves, basically the debate happening here is whether the FCS falls under the umbrella of 'stuff that's just too powerful and ruins the game balance' or 'acceptable rewiring advantage.'

To Buggy Boy, I'm honestly a little on-the-fence about it. The FCS is certainly strong, but by itself it mostly just allows the bots to reliably patch the sub before it floods over. It lets you get away with a slower submarine, worse helmsman/gunners and fewer leak-repairmen while taking bigger hits, but you still need to put the work in to survive. If you drive the sub full-speed into enemies, they will still tear open big portions of the sub and cause significant problems - those problems are just much less likely to get a member of the crew killed.

That being said, the Veteran Subs aren't intended to be balanced overall. While I refuse to use exploits on them, the stated goal is to 'take the vanilla submarines to their absolute peak using in-game rewiring.' Right now, no one really knows what the limit is, or how strong submarines can become if you put altogether too much work into every little aspect of the sub; I intend to find out. If the result is unplayably OP, at least we'll know for the future. One example is the internal flashbang security system I added; it ensures no crew are in the room and the doors are fully closed, then flashbangs any monsters in the room. This means even if you DO ram straight into a Mudraptor pack, the likelihood of them killing any crew is minimal. That might be overpowered when paired with FCS - I'm not sure (it costs enough in flashbangs I'd rather just keep them out of the sub with good piloting).
balls Oct 22, 2024 @ 2:18am 
Just give the command to go up. If the submarine is full of water, you're not anywhere but down anyway.
Solodric Oct 22, 2024 @ 11:29am 
Originally posted by hairy beaver:
Just give the command to go up. If the submarine is full of water, you're not anywhere but down anyway.

With this system you won't get full of water to begin with if you happen to catch a breach during a dive. I've seen it make a difference before. Plus, the fewer things distracting the captain, the better.
< >
Showing 1-9 of 9 comments
Per page: 1530 50

Date Posted: Oct 16, 2024 @ 12:32pm
Posts: 9