[SOLVED] How to make enemies stop re-spawning?

K

Krono

Guest
I want it so that if i go into another room and go back into the same room as before, the enemies won't re-spawn again and i have tried to set the enemies to both persistent and not persistent and my rooms are persistent but they still re-spawn.

If you want any pieces of my code to see if i have went wrong somewhere please ask and i will gladly show you.

Thanks in advance.
 

The-any-Key

Member
When creating the enemies in a room give them a fixed id:
In Create event:
Code:
id_track=global.tracked_id;
// Count up
global.tracked_id++;
Then save the tracked id in an ds list.
And when all the enemies are created save the list in a ds map with the room name as key.

When a enemy is "dead" you remove it from the ds list.

When you then enter the room again reset global.tracked_id=0 and check if the room name exists in the map (This means the room has been loaded before).
Then in the create event check if the id_track exists in the list. If it exists keep it, if not destroy it.
 
K

Krono

Guest
I'm pretty new to game maker so if you could explain what a ds map is and how it works i would be grateful
 
K

Krono

Guest
Currently I am just placing the enemies into the map as objects
 
B

Becon

Guest
You could also make a controller object that spawns the enemies in the room where they need to go and keeps track of if they are living or dead to respawn.
Just add a variable into the control object like Enemy1isDead = False
If Enemy1isDead = False
spawn it in room.
else
DONT spawn him you stupid controller....he's dead.

It could also keep other info per character too like the enemies health so if you got a few hits on one but didn't kill him...when you go back in the room and the controller spawns him...he can spawn with the same amount of health he had before you left the room. Or in the case your player dies...respawn the enemies with full health because it would be like starting over.
 
K

Krono

Guest
Ah there was a line in my code which set the rooms persistence = false which messed me sorry guys!
 
Top