Generators, wiring, power cables and grid-powered tools - a power system draft

[size=14pt]1. Rationale[/size]

Presently, a big issue in Cataclysm is electrical power - the lack of access to electricity has lead the game into an awkward situation, where everything is either battery-, or vehicle-powered, resulting in over-abundance of vehicle-mounted and often ridiculous equipment, while fueling non-vehicular tools remains extremely difficult, with the problem being only solvable by a vehicle-mounted recharging station. The resulting situation is one where vehicles fulfill every single role possible, and often are the only thing that does, making the game extremely vehicle-centric if the player does not want to completely incapacitate themselves.

[size=14pt]2. Overview[/size]

What I propose is a relatively simple(use-wise, though coding it should be by all means doable, as far as I gather) system that allows extra-vehicular power generation and consumption, including:

[ul][li]Standalone generators, placeable anywhere as a piece of furniture, with a modest mechanics skill requirement[/li]
[li]Power cords that allow connecting elements of electrical installations to each other[/li]
[li]Expanding on cords, a system where they are visible on the ground, and can’t go through walls(have to be laid down manually)[/li]
[li]A new wiring map layer, that represents wires, outlets, breakers, etc. installed in the terrain, be it walls or the floor[/li]
[li]New tool properties - ability to connect to outlets, and cable length, extensible with extension cords[/li]
[li]Proper functionality for existing furniture such as ovens, refrigerators, etc.[/li]
[li]Charing cord car component, for charging car batteries, installed on most electric cars[/li][/ul]

[size=14pt]3. Technical details and proposed changes[/size]

While I am a coder, I don’t know much about Cataclysm, beyond what I gathered from people on IRC, so I don’t know details of a hypothetical implementation of this system, other than that it should be possible, with the biggest challenges being a new map layer, the cord system, and range - what if one part of an installation goes out of map range? Additionally, Z-level-spanning electrical installations seem like an intuitive and desirable thing, but as of right now, I believe that would be hard, if not impossible.

Another challenge is that the construction menu, as of right now, is very simple, and a power system would need a way to interact with the electric installation - laying cables manually is easy enough, but what about the ones in the floor and walls? You would need a way to view, remove, install them. This is most certainly a big endeavor to implement. It would be possible to hack something together, such as a tool that shows an electric cord overlay when active, but ideally, a new interface is in order.

Additionally, I propose the following changes and modifications to the game:

[ul][li]Move most electric tools away from using batteries, with smaller, battery-powered variants available[/li]
[li]Implement mods, that allow converting between battery- and cord-powered, at a penalty to power consumption, leaving for example welders impractical to run on batteries. For most tools, this should remove the other functionality(battery/cord)[/li]
[li]Place generators in some basements occasionally, small ones in electric ones, bigger in survivor ones, also found in refuge camps and military outposts[/li]
[li]Add wiring to buildings, and power grid cables on the map that are unusable for all player purposes, for initial simplification, just don’t connect them to any power plants[/li]
[li]For diesel and gasoline cars, replace the batteries with lower capacity versions, reduce alternator’s power output, making powering multiple onboard power-consuming installations impossible without an additional onboard generator, or connecting to an external power source[/li]
[li]Remove certain vehicle stations, such as the vehicle welding rig, and make others more rare, since currently they exist for the sole reason of not being powerable by anything else[/li]
[li]Allow installing generators on cars, separately from engines, incurs a severe efficiency penalty when used for running an electric motor[/li][/ul]

Thanks for reading, all (constructive) feedback is welcome. I’ll try to keep up with editing the post as people post better solutions or further ideas/thoughts on important aspects.

I think it would be cool.
some thoughts/ideas:
Generator construction: 1 Alternator (to Generate the Power)
1 Engine (maybe a 1 cylinder from a lawnmower), would be used to run the Alternator
Small gas tank or some kind of container to hold gas for running the engine
Battery or Outlet for power to go to
Frame to put everything on

as for skills:
Mechanics skill of 3 (unless installing Alternator requires higher skill? never seen it listed in the parts list on wiki unless it’s classified as a Electric Motor)

also, I think if the grid is still hooked up to a substation, just hack some Generators into the grid @Substation to restore power to the buildings on the grid, you would just have to manage fuel use, or instead of using fuel generators, maybe hooking up a bunch of Solar Panels would be a option with a battery system to hold spare power for at night or when the sun isn’t shining (Thunder storms for example)?

Fabrication skill of 1 or 0? to make a Frame (Light wooden frame would be easiest)

It’s been considered before. Generally fails thanks to reality-bubble issues. You might point google at the forum and read up the previous threads on the topic.

[quote=“Llamageddon, post:1, topic:8285”]-snip-
[size=14pt]2. Overview[/size]

What I propose is a relatively simple(use-wise, though coding it should be by all means doable, as far as I gather) system that allows extra-vehicular power generation and consumption, including:

[ul][li]Standalone generators, placeable anywhere as a piece of furniture, with a modest mechanics skill requirement[/li]
[li]Power cords that allow connecting elements of electrical installations to each other[/li]
[li]Expanding on cords, a system where they are visible on the ground, and can’t go through walls(have to be laid down manually)[/li]
[li]A new wiring map layer, that represents wires, outlets, breakers, etc. installed in the terrain, be it walls or the floor[/li]
[li]New tool properties - ability to connect to outlets, and cable length, extensible with extension cords[/li]
[li]Proper functionality for existing furniture such as ovens, refrigerators, etc.[/li]
[li]Charing cord car component, for charging car batteries, installed on most electric cars[/li][/ul]

-snip-[/quote]

Are the wiring map layer and the visible cords absolutely necessary though? If you were to make the grid by building different types of nodes and then connecting them to each other, you wouldn’t need to bring the power lines in to the game as actual items. All you’d need to have for an electric drill to work as a tool in crafting or construction is to to have an outlet in range that is connected to a series of nodes that are eventually connected to a powered generator. Since the grid is always either powered or unpowered, all the game would need to worry about is if a connection between two nodes had been made and that only when new nodes are connected or a node is destroyed. If the generator pool is turned on or off, all the nodes is the grid are flagged powered or unpowered.

If you want to simulate breaking wires/cables due to damage, I suppose you can add a flags for a map tile, which tell the game that it has a power lines connecting two nodes to each other running through it. And when that tile is damaged, there is a chance the connection is broken. Extension cords can function as a item that extends the range of the tiles searched for an outlet when a tool is used.

[quote=“Llamageddon, post:1, topic:8285”][ul][li]Standalone generators, placeable anywhere as a piece of furniture, with a modest mechanics skill requirement[/li]
[li]Power cords that allow connecting elements of electrical installations to each other[/li]
[li]Expanding on cords, a system where they are visible on the ground, and can’t go through walls(have to be laid down manually)[/li]
[li]A new wiring map layer, that represents wires, outlets, breakers, etc. installed in the terrain, be it walls or the floor[/li]
[li]New tool properties - ability to connect to outlets, and cable length, extensible with extension cords[/li]
[li]Proper functionality for existing furniture such as ovens, refrigerators, etc.[/li]
[li]Charing cord car component, for charging car batteries, installed on most electric cars[/li][/ul][/quote]
We talked about this a bit on IRC, but to reiterate here.
All of these are viable within the exiting vehicle-based system, except the ones that are actually implementation details rather than features (map wiring layer). You simply set an “I’m really furniture” flag on the vehicle definition, and update the various pieces of code to respect that flag. The reason a map-based electrical grid is such a pain is that the map itself isn’t composed of distinct entities, it’s made up of independent cells of data that only relate to each other because they were initialized in a particular pattern. Shuch an environment is quite hostile to interconnectedness. Vehicles on the other hand act as distinct entities within the game and provide a place to store metadata like coordinates of connected grid nodes.
In particular I don’t know why you want the wires to be visible, it seems like it would cause a lot of visual clutter, and you normally aren’t going to be interested.

I’m not sold on an elaborate eletrical grid UI being necessary or desireable. You have a “cable” item of some kind, you attach it to either a source or sink of power, then you walk over to the opposing type of unit and attach it. Alternately e.g. a stand lamp might have a permanently attached cable, which you grab by 'e’xamining the lamp, then walk over to a generator or outlet and attach it there.

[quote=“Llamageddon, post:1, topic:8285”]Additionally, I propose the following changes and modifications to the game:

[ul][li]Move most electric tools away from using batteries, with smaller, battery-powered variants available[/li][/ul][/quote]
I don’t think “most” fits very well, there are a number of hand tools that would more reaalistically be depectid as being corded, but it’s well less than half of the tools,

No problem there.

Feel free to work on it if you like, but the reason we’ve been putting off adding generator type infrastructure is that without having a down side of attracting hordes, generators are all benefits with no drawbacks.

Unusable? I assume you mean usable. Regardless, while harvesting wiring makes sense, powering anything above the scale of a house does not.

Once all the other features are in place this would be a reasonable thing to do.

no, they don’t, and that’s not happening.

That’s nonsensical, you’d just tune the power consumption to be appropriate, there’s no reason to tie them together.

Overall pretty reasonable, but some of the details are a bit shaky.

I tried implementing a corded tool battery mod.

It worked well for items that are used, but crafting reads item charges directly instead of using the “getter” function. I dropped the idea because of that - I’d either have to rework a large number of crafting functions or use ugly unmaintainable hacks.

https://github.com/Coolthulhu/Cataclysm-DDA/compare/vehpower_mod
It’s more than 1000 revisions behind current one, relatively simple and uses jumper cables rather than dedicated cords, but the basic idea is the same.

Okay, this took me a good while to research, consult, and rethink, so I apologize for the delay. Honestly, what I have in mind now is essentially matter for a different topic. I should update the original post, but meh, another time.

Alright, so, what do I begin from? Maybe a bit about how electricity works in reality, very, very roughly.

First off, batteries, cars, and other appliances are not interoperable due to different voltage of their systems. For example, AA batteries are 1.5V, alternators output 12V, with some 24V ones existing. Car batteries and other “bigger batteries” are more or less always 12V, with 24V and higher voltage ones consisting of multiple 12V subbatteries. On the other hand, the voltage that you find in an outlet is usually something like 110/120/230/240 or so. Specifics don’t matter for Cataclysm, because we’re essentially free to pick whatever with the excuse of “power technology changed enough to leave little artifacts from the past” - if it’s more advanced, conversion between different voltages is not hard anyway, it just incurs some losses.

Second property relevant to Cataclysm is amperage, which is essentially the maximum amount of power that a device can output/consume. Important to note is that it’s directly related to voltage - a 4V battery that outputs 2A, converted into 8V will only output 1A(actually less due to losses). You would need roughly two of them to output 2A at 8V.

Power transmission is relatively simple, and is a both-ways process, although the lower the voltage, the greater the losses will be, which is why transmission lines usually have voltage on the order of hundreds of kV(kilovolts). Power conversion is likewise simple, although it entails losses. There is a huge amount of different types of transformers/voltage converters, but, for the most part, we can ignore that and have just one - future tech, right? Most of them are inside electronic appliances anyway - we can just implement “universal transformers” of different sizes - small, normal, big, huge(power substations), since size is essentially all that is important - too small of a transformer will overheat, and so will cables.

Also, there’s alternating and direct current, but conversion between those isn’t extremely hard, and can be completely abstracted for the sake of simplicity - it would already be possible nowadays, and Cataclysm has future tech that is magic.

Next up, batteries - in reality, it wouldn’t be the power grid that would die - power plants would most likely remain operable once you reboot and maintain them a bit. Particularly higher generation nuclear power plants have virtually no chance of breaking down fully. The thing that would die is storage devices - the 0-100% of any battery that we can find is in reality something like 75-100% of its actual capacity - the problem is that voltage falls as the charge falls, and even more importantly - the battery degrades. Within few months of an apocalypse, batteries would be rendered unusable forever, and that goes for ALL of them. That said, we probably for sure don’t want that, because that would mean that cars are no longer operable, and honestly - neither is anything else electricity-powered because without power storage, nothing runs, and even to kickstart an engine/generator, you need power. Not to mention the fact that batteries are not easy to make.

Speaking of generators - an alternator generates extremely little power, relative to how much house appliances or welders consume. A car battery can output high amperage, but it can’t output it forever - you could power a welder off a car battery for… I don’t actually know the figures, but not for a long time. The point is that an engine sporting an alternator would take many, many times more time to charge that battery up. A proper power generator converts maximum possible amount of engine’s energy into electricity, whereas an alternator converts little enough that you could attach 10 of them without a problem - it’s a negligible amount compared to the actual output of an engine.

Also, some more info: Some voltage converters are two-way, but they’re bulkier than most used nowadays(although, at the same time, they don’t scale up nearly as well as toroidal transformers), so let’s just have huge two-way toroidal transformers in power substations, and universal differently-sized ones elsewhere. Which means that compatibility between different devices is a matter of interface(i.e. battery slot vs power plug/outlet vs car cables). That said, said converters would be most likely embedded in the devices(or rather, their cables, but we can just abstract that), and would not matter for any practical purposes.

That last paragraph carries a huge significance for powering houses - if you just connected a generator in a house, the generated power would simply dissipate through the grid, powering nothing.

Also, carrying information through electricity cables is perfectly viable, and if we just assume that futuretech rebuilt the power grid, that will let us get away with a lot of stuff further down the line. E.g. a generator will be able to adjust its power output depending on what it has to power without a problem.

Alright, I’m somewhat poor at writing, so just like this, I will poorly transition into talking about my renewed proposal. First off, I propose the following standard voltages for different objects, with conversion being relatively simple: 4V DC batteries, 12V AC car power, 120V house power, 120kV transmission. Next off, cables. I propose three - small for battery-powered devices and primarily for use in crafting recipes, normal for cars and house - let’s just assume everything has built-in converters, and huge cables for transmission. Thirdly, differently sized universal converters that can support up to N amps, used as parts of electrical recipes. Fourthly, power consumption adjustment - for example, a welder would burn through hundreds of batteries in the matter of seconds, and as such I propose converting such devices to grid-powered once the infrastructure is in place, and most likely gasoline-powered before that. However that works.

Well, truth be told, I’m feeling somewhat shitty at the moment, so I can hardly be arsed to elaborate on that more, I’ll just continue writing my research and thoughts, someone else feel free to comment on it and format it up. Also, from this point on, draw your own conclusions. Depression, apathy, and all that stuff.

So, let’s assume that future tech has vastly improved batteries, so let’s say they don’t break down, that they have much(~3-4x?) greater capacity, perhaps 2x the amperage(maximum power output at a given point), and are recharged much faster but not instantly. This means, cord mods for battery-powered tools - lower throughput variant for charging, higher output one for replacing battery systems. Power outlets installable both on cars and walls/floor. Cables similar to current jumper cables, but with in/out ends(tools would only have cords with an in end), except I’d like them to not phase through walls, and be visible during laying them down. As Kevin said, electrical furniture/objects can just be vehicles secretly, perhaps ones that can be put inside inventory sneakily. Since vehicles are reality-bubble independent, particularly the electrical connection graph, some hack could probably be devised to generate noise and lay cables through Z levels. Also, some way to put cables inside walls. Perhaps some sort of flow simulation. Oh, and yeah, since we have information over wire, have a stat screen on generators, how much power is needed, how much is generated, how much can be generated, etc. Also, breakers to disconnect from the grid.

Oh yeah. If you convert from 12V to 13V on a battery, you can drain it dry in favor of another battery. So I guess I propose craftable siphon cables.

Also, Kevin mentioned on IRC that items will get IDs, so hopefully that will lead to differentiating multiple batteries for example, and then we could have an alternate charge/ammo system, where for example multiple bullet types can be loaded, or where an empty battery can be retrieved from a flashlight. Then we could have slightly bigger utilities powered by 2 or 4 batteries.

Also, wireless electricity is already possible, it just has huge losses over range. A pair of vehicle components/machine mods could be created, for receiver and sender, and then it would also have some basic information transfer that would make it work and whatever. Either way, that wouldn’t be a lot of work above the previous challenges. You probably know more about them than I do.

So eh, what else is there. You need a proper electric generator to make an actual generator, an alternator doesn’t have nearly enough power output. Those are makeable manually, but rather complex. Let’s just say you could somehow transmute N alternators into one.

Also, thinking about it, it would make some sense if you could build appliances in a similar way to the one in which you can build vehicles, just not identical. Say, attach heating/freezing elements to (a) container(s), and a temperature regulator, build a fridge/oven, attach a large LCD display to electronics and some CPUs, make a laptop. Also, if you add item IDs, you could make flash drives/devices with actual storage, that would mean you could put lots of stuff. Honestly I’m just saying whatever at this point so I will finish writing and all that. Meh.

I won’t write how I’ve read everything on this topic, but I’ll try and pitch in a little bit; all of you seem to excel, but it ‘smells’ rather complicated.

Right now there’s a bottlecap system to all things mundane, those that actually work in CataDDA. Even the trendiest of code shifting enables but a modest battery recharging via nextgen solar cells, but to a point. Since the cutoff from the power grid mainline, just before the game starts, players are unable to find unlimited source of juice for their toys. And yet, you’ve got (seemingly) simple examples of power production / consuption in games with SimCity and its clones. Face it, wiring a neighbourhood isn’t that complicated if there are substations, where consuption is calculated through household count; businesses may count from 1 to 5 on that scale, but that’s it if you consider powerlines redundant - if it coincides with your lore comprehension , that is.

Going over your head with the issue(s) of broken poles, busted circuits etc won’t nudge the community to think that some NPC quest for bringing 80 miles of power cord back to the camp is worthwhile. What I’m thinking is Forgive & Forget kinda thing, so important objects on the map could eventually have greater value than resource micromanagement (on a greater timescale, whereas the player adds kilotons of text-bonanza for the sake of some suburban power voltage).

My way of thinking when it comes to this aspect of Cataclysm is rather Fallout-ish:
“A busted console? Yet another broken power-related item? Moving on to the next one, because my character makes the difference…”

I did a post on this subject myself quite a while ago. When faced with a similar issue in some of the stuff I coded for muds back in the day there were two systems I ran upon to deal with this. Either a last updated timestamp or a keep me in memory flag.
Last Updated Timestamp would simply store the last time that device was updated, compare to current game time next time it’s interfaced with. Update itself as needed.
Keep Me In Memory Flag would probably be more complicated. Would involve creating a system to keep updating regularly things that would need to be. This should also include some basic checks to take things out of memory when they no longer need be updated (solar cars that have full batteries).
Hope this helps.

As far as I know from Kevin there already is some power graph infrastructure, and either way, implementing that would not be extremely hard.

Either way forgive me but I have huge mood swings and so far none of the times that I looked here I felt good enough to comment. Also, some things stress me. Like potential reactions of people. I know that what I wrote is a bunch of random stuff, but I have a pretty decent and gradual system in mind, starting from additional components/recipes, through some rebalancing and minor changes, all the way to a more complete system. If you want to actually talk to me about this, find me on IRC sometime, I am much better at realtime chat. At the same time, I am sorry for bringing my personal issues into a discussion forum, I’m sorry. I’m coding some other stuff for Cata which is so far going well, regardless of whether it will ever see the light of the day, so as I get familiar with it, I might go ahead and take the liberty of attempting some work on a power system. That said do not count on it. Eh whatever.

Most everyone who works on DDA either has issues or develops 'em. Take care of yourself, and no worries about the timing or the mood swings on this end. We’ll be here.