Level system stops at level 6 [Solved sort of]

M

Magic-4e

Guest
Hi I have a little game here with a level system where you level up by shooting enemies and with each level the enemies spawn faster and the max enemies becomes more.
But at level 6 the enemies stop spawning for some reason.
I hope someone can tell me how to fix this.

The object I use to level up is the enemy spawner and this is what it contains:
upload_2017-12-5_9-44-21.png
upload_2017-12-5_9-44-47.png
upload_2017-12-6_15-35-26.png
Code of Execute code function:
Code:
Create = Enemy_multiply;
while (Create > 0)
{
    instance_create(x, y, Enemy_obj);
    Create --;
}
upload_2017-12-5_9-45-50.png
Code of Execute code function:
Code:
Max_enemys = 1 + global.Level;
upload_2017-12-5_9-46-9.png

The enemies countain a global create variable that sets global.EnemyC relative to 1
The also contain a the global code to set global.Enemy Kill relative to 1 when they get destroyed.

The oject info is:
Code:
Information about object: Enemy_spawner_obj
Sprite: Enemy_spawner_spr
Solid: false
Visible: false
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable global.EnemyC to 0
set variable Time to 60
set variable Spawn to 0
set variable global.Level to 0
set variable global.Enemy_kill to 0
set variable Enemy_multiply to 0
set Alarm 0 to 0
Alarm Event for alarm 0:
if Time is greater than 1
     set variable Spawn to 0
Step Event:
if global.Game_End is equal to 0
     if global.EnemyC is less than Max_enemys
           if Spawn is equal to 0
                 create instance of object Enemy_obj at relative position (0,0)
                 if Time is greater than 1
                       set Alarm 0 to Time
                       set variable Spawn to 1
                 else
                       set variable Time to 1
                       if Time is equal to 1
                             set variable Enemy_multiply relative to 1
                             execute code:

Create = Enemy_multiply;
while (Create > 0)
{
   instance_create(x, y, Enemy_obj);
   Create --;
}

                             set variable Spawn to 1
Begin Step Event:
execute code:

Max_enemys = 1 + global.Level;

End Step Event:
if global.Enemy_kill is greater than 4
     set variable global.Level relative to 1
     set variable global.Enemy_kill to 0
     set variable Time relative to -10
If you need more info than let me know. :)
 
Last edited by a moderator:
M

Magic-4e

Guest
See where it says Show Information? Click that button and copy-paste everything in the window that pops up.
If figured somthing out but thanks. :)

I still need some help with my code/drag & drop.
 
Last edited by a moderator:
M

Magic-4e

Guest
Can someone please help me? This stupit bug is really bugging me.
 
Last edited by a moderator:
B

Badger

Guest
Can someone please help me this stupit bug is really bugging me.
You should follow these instructions:
See where it says Show Information? Click that button and copy-paste everything in the window that pops up.
Doing this will make it easier for people to give you a hand. The "Show Information" button is located on the bottom left corner of the object properties window.
 
M

Magic-4e

Guest
You should follow these instructions:


Doing this will make it easier for people to give you a hand. The "Show Information" button is located on the bottom left corner of the object properties window.
Ow I thought he was talking about my pictures.
I will look into it.
 
B

Badger

Guest
Check out the bottom left corner of your pictures. The button is there.
 
M

Magic-4e

Guest
Check out the bottom left corner of your pictures. The button is there.
Code:
Information about object: Enemy_spawner_obj
Sprite: Enemy_spawner_spr
Solid: false
Visible: false
Depth: 0
Persistent: false
Parent: 
Children: 
Mask: 
No Physics Object
Create Event:
set variable global.EnemyC to 0
set variable Time to 60
set variable Spawn to 0
set variable global.Level to 0
set variable global.Enemy_kill to 0
set variable Enemy_multiply to 0
set Alarm 0 to 0
Alarm Event for alarm 0:
if Time is greater than 1
     set variable Spawn to 0
Step Event:
if global.Game_End is equal to 0
     if global.EnemyC is less than Max_enemys
           if Spawn is equal to 0
                 create instance of object Enemy_obj at relative position (0,0)
                 if Time is greater than 1
                       set Alarm 0 to Time
                       set variable Spawn to 1
                 else
                       set variable Time to 1
                       if Time is equal to 1
                             set variable Enemy_multiply relative to 1
                             execute code:

Create = Enemy_multiply;
while (Create > 0)
{
   instance_create(x, y, Enemy_obj);
   Create --;
}

                             set variable Spawn to 1
Begin Step Event:
execute code:

Max_enemys = 1 + global.Level;

End Step Event:
if global.Enemy_kill is greater than 4
     set variable global.Level relative to 1
     set variable global.Enemy_kill to 0
     set variable Time relative to -10
Is this good?
 
Last edited by a moderator:
M

Magic-4e

Guest
Is that relative?
If not, that would reset the level whenever you've killed 4 enemies.
It is relative, the level go's up every 4 enemys.
But when it reaches level 6 the enemies stop spawning even when I managed to kill 4 enemies in that wave and it reaches level 7.
 
Last edited by a moderator:

Simon Gust

Member
It is relative, the level go's up every 4 enemys.
But when it reaches level 6 the enemies stop spawning even when I managed to kill 4 enemies in that wave and it reaches level 7.
Make sure you have an alarm[1] event. I don't see it in the events list.
 
M

Magic-4e

Guest
Make sure you have an alarm[1] event. I don't see it in the events list.
O oops that is an old alarm.
I will remove that, I don't need it anymore.

I realy wonder what is causing this bug.
I can't see what I did wrong.
 
Last edited by a moderator:
M

Magic-4e

Guest
I am looking and looking and thinking and thinking but I can't discover why it's not working.
Can someone with more wisdom and experience please help me?
 

ParodyKnaveBob

The Laughing Rogue
Is this good?
I hate to say "no," but...
You silently changed things between the screenshots and the copy/paste. Also, the indentation (important for reading the If statements) is thrown out.

To fix the first, I don't know what to tell you. Your Create Event set a Max_enemies variable, and then it wasn't there. Your Alarm 0 Event set Spawn unconditionally, and then you made it conditional to Time. Half your Step Event is missing, and neither your Begin Step Event nor End Step Event show at all. I faintly remember some nuance with copy/pasting the Show Information stuff, but I'm about to crash from sleepiness right now.

To fix the second, try using [code][/code] instead of [quote][/quote].

I do hope this helps,
Bob
 
M

Magic-4e

Guest
I hate to say "no," but...
You silently changed things between the screenshots and the copy/paste. Also, the indentation (important for reading the If statements) is thrown out.

To fix the first, I don't know what to tell you. Your Create Event set a Max_enemies variable, and then it wasn't there. Your Alarm 0 Event set Spawn unconditionally, and then you made it conditional to Time. Half your Step Event is missing, and neither your Begin Step Event nor End Step Event show at all. I faintly remember some nuance with copy/pasting the Show Information stuff, but I'm about to crash from sleepiness right now.

To fix the second, try using [code][/code] instead of [quote][/quote].

I do hope this helps,
Bob
Thanks for the correction.
Say do you know how you can post pc screenshots properly?
 
M

Magic-4e

Guest
I hope I soon will get a comment that will help me fix my game instead of criticizing my ability of using these forums.
 

ParodyKnaveBob

The Laughing Rogue
Easiest way to post screenshots (from Windows) is Print Screen (or Alt+Print Screen for just the window), then literally paste right into the rich text editor here on the forum.

I hope I soon will get a comment that will help me fix my game instead of criticizing my ability of using these forums.
You silently changed things between the screenshots and the copy/paste. [...]

To fix the first, I don't know what to tell you. Your Create Event set a Max_enemies variable, and then it wasn't there. Your Alarm 0 Event set Spawn unconditionally, and then you made it conditional to Time. Half your Step Event is missing, and neither your Begin Step Event nor End Step Event show at all. I faintly remember some nuance with copy/pasting the Show Information stuff, but I'm about to crash from sleepiness right now.
That wasn't a criticism on using the forum. That was saying, "you showed us stuff about the game, and then you showed us changed (and missing) stuff about the game. (This makes it more difficult to help.)"

If no one else pops up, I'll see if I can at least help on the Show Information copy/paste nuance-iirc several hours from now. Gtg now, though!
 
M

Magic-4e

Guest
Easiest way to post screenshots (from Windows) is Print Screen (or Alt+Print Screen for just the window), then literally paste right into the rich text editor here on the forum.





That wasn't a criticism on using the forum. That was saying, "you showed us stuff about the game, and then you showed us changed (and missing) stuff about the game. (This makes it more difficult to help.)"

If no one else pops up, I'll see if I can at least help on the Show Information copy/paste nuance-iirc several hours from now. Gtg now, though!
I tried the copy paste it but it only worked when i made the trend. Now it does nothing i can't place my print screens in my edits.

edit: O wait I think I get it. I had too many files uploaded. Now thats fixed I should have writen down everything correctly. I also included the object info. I hope that's good enouge. :)
Thanks for your coment.
 
Last edited by a moderator:

ParodyKnaveBob

The Laughing Rogue
You're welcome. $:^ J

Do you ever set the variable Time to anything besides 60 in the spawner's Create Event, 1 in its Step Event, or Time-10 in its End Step Event? Whether you do or not, I suspect the problem lies somewhere around the fact that Alarm 0 gets set to Time (which took me some charting out to figure out it's a cooldown for the spawner -- let me advise you to use true and false instead of 1 and 0 when you intend for something to only ever be set to true or false $;^ J ) and relies upon Time's value in order to then set the Spawn back to 0. But, let's see/hear where else you handle Time before concluding anything. Also, I assume upon enemies dying, they also set EnemyC relative to -1 since you said the code works at first at least? (It seems that stands for "enemy count" but that's just a guess.)

I hope this helps,
Bob
 
M

Magic-4e

Guest
You're welcome. $:^ J

Do you ever set the variable Time to anything besides 60 in the spawner's Create Event, 1 in its Step Event, or Time-10 in its End Step Event? Whether you do or not, I suspect the problem lies somewhere around the fact that Alarm 0 gets set to Time (which took me some charting out to figure out it's a cooldown for the spawner -- let me advise you to use true and false instead of 1 and 0 when you intend for something to only ever be set to true or false $;^ J ) and relies upon Time's value in order to then set the Spawn back to 0. But, let's see/hear where else you handle Time before concluding anything. Also, I assume upon enemies dying, they also set EnemyC relative to -1 since you said the code works at first at least? (It seems that stands for "enemy count" but that's just a guess.)

I hope this helps,
Bob
Yeah you are right. That time thing is a cool down, EnemyC stands for Enemy Count and I paid attention to if the right things where relative or not.
Sorry if i don't explain every single detail through text; I thought it would be easier to just show pictures of everything because It would be a lot to write down.
I think I'll keep using 1 and 0 instead of true and false. I don't want to change it all.
The cooldown becomes shorter each level. I can increase/decrease the start time if I want to change the gameplay.

I hope you can make somthing of this info.
 
Your cooldown timer starts at 60. You take 10 from it every time you kill 4 enemies. That means after 6 waves you've reduced the cooldown to 0, so it will never trigger again.

EDIT: What you could do is set a lower limit for the cooldown timer. You would do this by checking if the cooldown timer is below the limit and if it is, setting it to the limit. I'd place this after you minus the 10 from it personally, but there's other places you could put it.
 
Last edited:
M

Magic-4e

Guest
Your cooldown timer starts at 60. You take 10 from it every time you kill 4 enemies. That means after 6 waves you've reduced the cooldown to 0, so it will never trigger again.

EDIT: What you could do is set a lower limit for the cooldown timer. You would do this by checking if the cooldown timer is below the limit and if it is, setting it to the limit. I'd place this after you minus the 10 from it personally, but there's other places you could put it.
Yes I tryed that and it simply still stops. I dont understand why.
 
M

Magic-4e

Guest
Do you ever set the variable Time to anything besides 60 in the spawner's Create Event, 1 in its Step Event, or Time-10 in its End Step Event?
I set it relative to -10 each time I kill 4 enemies; that is when the level goes up.
 
M

Magic-4e

Guest
I am starting to think it has somthing to do with the execution script in the step event line 20.
What do you Guy's think?
 

Bingdom

Googledom
I set it relative to -10 each time I kill 4 enemies; that is when the level goes up.
Well, that's the problem. It mathematically makes sense.
You start with 60, Each new level takes away 10.
When you reach level 6 (assuming you start at 0), you are effectively setting alarm[0] = 0, making it never to trigger.
Just what the previous poster said.
Using show_debug_message or draw_text can really help debug your variables.

For a bit of an explanation;
When the alarm is greater than 0, it counts down.
When an alarm == 0 while incrementing, it triggers
The alarm will reach to -1, meaning it's off.

When things don't trigger, it's usually the case with alarms.

If you still don't get it, there's a topic in the old forums (I don't have a link on me) showing all sorts of examples with alarms which also goes into more depth than me. If it's hard to find, I'm sure there's plenty of resources online to help you.
 
M

Magic-4e

Guest
Well, that's the problem. It mathematically makes sense.
You start with 60, Each new level takes away 10.
When you reach level 6 (assuming you start at 0), you are effectively setting alarm[0] = 0, making it never to trigger.
Just what the previous poster said.
Using show_debug_message or draw_text can really help debug your variables.

For a bit of an explanation;
When the alarm is greater than 0, it counts down.
When an alarm == 0 while incrementing, it triggers
The alarm will reach to -1, meaning it's off.

When things don't trigger, it's usually the case with alarms.

If you still don't get it, there's a topic in the old forums (I don't have a link on me) showing all sorts of examples with alarms which also goes into more depth than me. If it's hard to find, I'm sure there's plenty of resources online to help you.
But I have an if statement that takes over the work of alarm 0 if Time is not greater than 1 so the enemies spawn each step.
Shouldent that just work?
 

Bingdom

Googledom
But I have an if statement that takes over the work of alarm 0 if Time is not greater than 1 so the enemies spawn each step.
Shouldent that just work?
Yes, that should work. Have you not tried it?

Edit: Oh, just looked at your code.
 
Last edited:
M

Magic-4e

Guest
Yes, that should work. Have you not tried it?

Edit: Oh, just looked at your code.
Yeh. I was thinking it had somthing to do with the execution code in the step event.
Do you see anything wrong with it?
 

Bingdom

Googledom
Have you tried drawing all the variables like I mentioned earlier?

I'm having a bit of trouble following on with your code. It might just be my lack of sleep.

I would suggest making a system like this (I think this is what you're trying to do).
Wave start, spawn enemies (alarm[0]=1 in the create event).
All enemies are dead, add level and start alarm.
Spawn new wave when the alarm runs out (alarm triggers).

You can put spawn code inside the alarm (which makes more sense).

You can use instance_number to get the number of instances in the room.
 
Last edited:
M

Magic-4e

Guest
Have you tried drawing all the variables like I mentioned earlier?

I'm having a bit of trouble following on with your code. It might just be my lack of sleep.

I would suggest making a system like this (I think this is what you're trying to do).
Wave start, spawn enemies (alarm[0]=1 in the create event).
All enemies are dead, add level and start alarm.
Spawn new wave when the alarm runs out (alarm triggers).

You can put spawn code inside the alarm (which makes more sense).
You know that is actually a very good Idea.
But this is just a school project and I don't want to make every wave myself so I just automate it into infinity.
I think I stick with this.
 
M

Magic-4e

Guest
What do you mean? The method I told you still can be infinite.
O sorry I think I brain farted.
Yes your way is nice by making waves of enemies instead of just keep spawning them, but I was a bit lazy and didn't want to change that.
Now I think I will implant that.
Maybe this change will also fix the bug at the same time.
 
Last edited by a moderator:
M

Magic-4e

Guest
Thanks everyone I made the game work. No more glitches.
Although I didn't really fixed the problem, but by redesigning the level system into a wave system I made the glitch disappear.
So I gues it's fixed.
Thanks everyone for helping me. :)
 
Top