Advertisement

Getting energy to where it's needed

Started by March 17, 2005 09:17 PM
8 comments, last by krez 19 years, 10 months ago
I'm working on a spaceship-combat game. My spaceships consist of modules, which may either produce energy (engines) or consume it (weapons, drives, shields - everything that's not an engine.) The player can set the priority for the various kinds of systems, as in "All power to shields!" My original idea for distributing the energy was thus : Every time the priorities change : - Sort the modules by priority. - Starting with the highest-priority module, each module : - Traces a path to the closest engine; if it can't find one, it's out of luck. - If it can find one, it sets its own energyReceived variable, decrements the Engine's energyAvailable variable by the same amount, and each module in the path has its energyFlow variable incremented by the same amount. If a module's energyFlow variable reaches maxFlow, that module is no longer considered valid for drawing paths. Unhappily, when I began implementing this, I ran into trouble. What if a module needs more energy than one engine can supply? It will have to draw from two engines, or more. The book-keeping gets extremely complex. What if so many modules are damaged that there's a surplus of energy? Then there's the sheer performance cost of running A* on up to a hundred modules every time the player changes a priority. In short, I'm looking for a KISS alternative. Ideas? I would like to maintain the feeling of an energy budget, that - especially as the ship is damaged - you have to prioritise tasks.
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
Tally up the energyAvailable for the entire ship, and subtract energy from that? Unless you're graphically displaying the flow of energy through the ship, players wont know the difference. If an engine is damaged or destroyed, you simply recalculate the value, which is just a simple set of additions. If a component is destroyed or damaged, stop subtracting energy from the energyAvailable. If a component needs more than the output of a single engine, there's no problem, as it's drawing from a pool of all the energy. If more energy is needed than is available, low priority items won't get any energy. If there's a surplus of energy... well, you'll need to put in something to handle that (or don't, you could just leave it there... reserves for if damage is taken perhaps?).

Just one simple method, which may or may not suit your idea.

- Jason Astle-Adams

Advertisement
I'd also recommend allowing energy-consuming modules to work (albeit less effectively) when insufficient energy is available. That way the player won't get stranded if one of his reactors gets knocked out right after he bought the Gargantuan Turbodrive (runs on copious quantities of antimatter and chicken soup).
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
Wow, quick response! Indeed, that's what I'm implementing now as a stopgap. However, I'd like to have the possibility of boarding parties or battle damage cutting off parts of the ship from receiving energy.

Suppose I make a type of module called a Node, which can draw energy from anywhere in the ship; but other kinds of modules need to have a functioning Node within two, three, or n steps of them? Then a boarding party can seize a Node and instantly chop off half the broadside. It doesn't quite fit with my image of damage-control parties heroically laying cable to get the cut-off batteries firing again, though. Hmm.
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
Quote:
Original post by King of Men
It doesn't quite fit with my image of damage-control parties heroically laying cable to get the cut-off batteries firing again, though. Hmm.


Perhaps you could add an additional node in this situation?

- Jason Astle-Adams

Set up temporary nodes in each individual module? That does have possibilities, although if that's possible, why not have them there permanently? Maybe the efficiency of a node scales with size, or they're very expensive and even warships can't afford one per module. They might also have a prodigious energy expenditure themselves, and make the detection profile of the ship go up. OK, now we're getting somewhere!
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
Advertisement
Temporary nodes could also possibly waste more energy than permanent ones, so that they're only something you would want to use in an emergency to get some critical systems back online.

- Jason Astle-Adams

Very good, I think I'll be doing that. Thanks for your help!
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
Well it depends on what kind of game you want it to be?

For example, some ships can have a single reactor, while other ships can have no reactor, but nodes...?

If I were you I wouldn't give energy surplus any type of bonus, ie all the systems are down on the ship but the weapons, so the weapons get all the power.

Instead it should be based off percentages. If this weapon needs 5gw's of power, it will run at 100 percent (damage, recharging, fire rate)

However, if you only allocate 4gw's it's now running at 80 percent... (This can be 80% to damge, recharge etc,, or reduce other atributes more or less)

Also if the nodes get damaged or reactor gets damage, and isn't producing enough energy, it has to figure out which systems to affect. It might be best to have it affect all systems, and equally try to supply the power needed to all units.

For example if weapons need 100 power, and sensors need 10, and you loose 10% of your reactor to damage, then take 10 from weapons, 1 from sensors (10%)

Try to stay even across the board.

Certain systems, might need a certain amount of power to function. Ie, if weapons are optimal at 100 power, minimum can be 75 power, or they will not function, while sensors only need 10 power, minimum they will still function is 5... etc things like that
Black Sky A Star Control 2/Elite like game
Quote:
Original post by Derakon
I'd also recommend allowing energy-consuming modules to work (albeit less effectively) when insufficient energy is available. That way the player won't get stranded if one of his reactors gets knocked out right after he bought the Gargantuan Turbodrive (runs on copious quantities of antimatter and chicken soup).

i think it'd be neat if each module worked based on the percent of power it is receiving (maybe with a "failed completely" cutoff at 25% or something). then you could also ramp up the power to 200%, the effect of which varies by module type:

* lasers are overpowered / very damaging, but will most likely overheat or explode the module soon enough
* shields can take a larger impact, but if no impact occurs within a time limit they will diminish to 50% functionality
* engines will allow for faster travel, but have a chance of creating a black hole
* life support will generate much more oxygen, making your crew "high" and much less upset about being killed by the boarding space monkeys

over/underpowered modules could also incur damage that needs to be repaired, based on how long they had too much or too little power.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

This topic is closed to new replies.

Advertisement