Stop endless subtraction?

Hello! This is my first time messing around with Gdevelop and something went a bit wrong in my event system, and I’m really not sure how or why >-<

I’m trying to make a simple idle game, where a set of three units attack at specific intervals (designated by their speed). i.e, one attack every x seconds, damaging the enemy for whatever their attack value is.
However, something? went wrong? Genuinely not sure why it’s happening, but per attacking block i have one line to subtract the attack value from the enemy’s hp value, expecting it to only subtract it one time, but for some reason it just doesn’t stop subtracting? I’m fairly certain it has nothing to do with the attack or speed values, as when I messed with those the attack value just changed how quickly it drained and speed just added a delay in the endless subtraction void…
Honestly I’m at a loss. Am I just blind and missing something? Any suggestions/help appreciated!!

Event Code [!!first three blocks are essentially the same- theres one for each unit. The last is how I handle when the enemy dies, which is working fine…]

additional notes that may or may not matter at all-
attack value for all three is set at 1
enemy hp/maxhp is set at 500
speed does not affect the speed of the drainage
at these stats it takes approx 2 seconds for the 500hp to be completely gone (guessing its -1hp per eighth of a second ish? (not what i want) (i want -1hp per 4 seconds ish)

The wait is a little poorly named. It waits but only for the actions/conditions below it inside the event and any subevent.(indented events) The other events continue to be executed including the events before the wait which can add another wait

If you haven’t already, I’d read up on timers. You can use 3 timers and check for different elapsed times.

Edit: in this example. Only the purple part would be delayed. When the next frame is processed it would run until the the wait where it would add anotherwait unless the variable was changed.


Thank you! I’m getting closer, (its not draining as fast) but it is still draining one hp/s, no matter what i set the speed to. (i.e, 1hp/s would be a speed of 1, 1hp per five seconds would be a speed of 5 etc, but no matter what it’s set to it still only delays the inital attack…)
My guess is the timer doesn’t seem to be resetting? Normally I’d deal with this problem by setting a mod, like
if(timer % atkvalue) == 1{
|do thing
so that I dont have to worry about it going over, but the only options for the timer are greater/less thans…

Here is what it looks like now

[removing the unpause/pause lines have no effect]

I very much appreciate your help! I hope you are having a good week~

The pause, unpause isn’t needed. I don’t think it does anything.

If anything, it’s probably the variable. Is that an object variable? What is the value of the object variable(s). Do the objects have different values? In the current setup, I believe it’s triggering as long as the elapsed time is greater than any of the instance variables.

1 Like

Ah- I am a goober, it was just a variable issue :,) Thank you for pointing that out, I mustve gotten tunnel vision on the timer haha!
Thank you so much for your help!

1 Like