Author Topic: How do Generators work?  (Read 704 times)

p0ki

  • Full Member
  • ***
  • Posts: 112
    • View Profile
How do Generators work?
« on: August 28, 2015, 12:04:34 pm »
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 :)
Playing on:
[EU][kG]kunix.org

Lurler

  • AtomicTorch Founder
  • Hero Member
  • *****
  • Posts: 988
    • View Profile
Re: How do Generators work?
« Reply #1 on: September 02, 2015, 10:52:02 pm »
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

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: How do Generators work?
« Reply #2 on: September 03, 2015, 06:25:27 am »
Hmm... within Core\data\scripts\CalculateShip.js I found this line:
Code: [Select]
<?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:
Code: [Select]
<?php // I write php to colour the text
var fuel_consumption ship.GetFinalCacheValue(ship_id"fuel_consumption_generator")
Snippet from generator_dark_energy.xml
Code: [Select]
<?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?
Playing on:
[EU][kG]kunix.org