How do Generators work?

Started by p0ki, August 28, 2015, 12:04:34 PM

p0ki

I can't really explain to myself how the generatos and the numbers whithin are going.
Dark Energy for example uses 150 fuel and brings 55 energy.

But within the game standing perfectly still I have 650/750 energy.
For the generator to replenish this 100 Energy he uses 6 fuel. So ... yeah...

Kindly direkt me to the file which calculates or directs this numbers. Thank you :)

Lurler

To be quite honest I don't remember myself how exactly it is calculated, haha :)
But IIRC this calculation is available in the scripts and not directly hardcoded in the engine, so if you are curious you can open the original code and see the logic for the fuel consumption.

p0ki

Hmm... within Core\data\scripts\CalculateShip.js I found this line:
<?php // I write php to colour the text
var fuel_consumption ship.GetFinalCacheValue(ship_id"fuel_consumption_generator") / 60.0 timeMultiplier coef;
            if (
fuel_consumption 0.0001)
            {
                
ship.SetCurrentValueDelta(ship_id"fuel", -fuel_consumption);
            }

"timeMultiplier" only gets into the equasion to recalculate frames,
"coef" only gets into the equasion if there is more energy generated then can be used,
so we are going to ignore those two.

I understand that this calculation is called every frame (which are 60 per second), to get to our desired fuel_consumption per second we just need to multiply by 60. Clearing all that from the equasion we get this:
<?php // I write php to colour the text
var fuel_consumption ship.GetFinalCacheValue(ship_id"fuel_consumption_generator")

Snippet from generator_dark_energy.xml
<?php // I write php to colour the text
<effect>
<effect_type>fuel_consumption_generator_value</effect_type>
<effect_base>150</effect_base>
</effect>

So fuel_consumption should be 150 per second. (Seems much doesn't it?)
Going with these numbers the dimensional fueltank can last 16,6 seconds.

Clearly I made a mistake or the "SetCurrentValueDelta" function holds a secret I cannot unravel.
Could you help me with this one more time, please?