Power (Fnaf Style) converted into Gdevelop

Im not sure how to do this,

I want the player to lose X power every (5 - Y) seconds.
btw I also want it so it actually subtracts Y from 5.

formula thingy
usage = 0, set both X and Y to 0

If usage = 1, set X to 1 and Y to 20%

If usage = 2, set X to 1 and Y to 40%

If usage = 3, set X to 1 and Y to 60%

If usage = 4, set X to 1 and Y to 80%

Basically, i want the power drain system from Five Nights at Freddy’s

27 views no help :< pls Forums i neeed this. My game is kinda powerless

Never played fanf or whatever
I don’t understand what you are talking about

But from your formulas i understand 20% increments

Imagine you have Variable called Power
And another called MaxPower is lets say 100

If you want to decrease it 20% of power
Then
Change variable Power set to max(Power - (MaxPower * 0.2))

And now you just repeat it every second
For example you can use condition called compare two numbers
And now
mod(TimeFromStart , 5 )
Is less than
1

Trigger once

I guess a better way to put it is, that there are actions you can perform, such as using security cameras, having doors closed, fan on and ect. Each action Increase the usage bar by one with a max usage bar of 4 and a minimum of 0. The max power is 100% and will go down as the night goes on. Bar usage influences the amount of seconds it takes for power to go down, not the amount of power that goes down.

Bar usage of 0: power drains by 0% every 5 seconds.
Bar usage of 1: power drains by 1% every (5 - 20%) seconds.
Bar usage of 2: power drains by 1% every (5 - 40%) seconds.
Bar usage of 3: power drains by 1% every (5 - 60%) seconds.
Bar usage of 4: power drains by 1% every (5 - 80%) seconds.

Ahh
You want
With each device enabled
It drains power FASTER?

THEN
For each object you can enable make BOOLEAN global variable
For example imagine you have
TV
Lights
Camera
PC
So 4 objects
NOW make another global NUMBER variable call it PowerDrain
And you set PowerDrain to TV + Lights + Camera + PC
Boolean variables can be used as numbers
So as soon as you set boolean variable to true it will = 1
Where false = 0

NOW
You can go with timer and just start it
Then check if timer value is greater than 1 - (1 / 5 * PowerDrain)
And just subtract power
Then reset timer

I will try this! Thank you so much!

1 Like

You could try using variables to turn on a timer that when reach’s a certain number will drain some of the power. That’s what i did


(Ignore cam power drain that’s activated in the cameras group cause you can only have one camera open)