Making the same object appear somewhere else in the room after you lose it?

My player doesn't die in my game. Instead, if they come into contact with an enemy - the enemy will steal the potion bottles they pick up throughout the level, and the player loses some energy from their magic bar on the pause screen. That means that the object. The goal is to collect ten bottles and destroy all the enemies in the level, and if you do that - a warp appears and takes you to the boss.

Not at the last part yet because my enemy that I'm testing with (which hopefully will become my archetype that I can parent) will only steal one time and if I go through a second pass my potion bar doesn't drop.

I've got this in my persistent CONTROLLER create object:

GML:
global.player_reality = 0;
in my ENEMY create there's

GML:
bottle_take=false;
ENEMY collision

GML:
bottle_take=false;
if bottle_take == false
{
    global.player_reality -= 1;
    bottle_take=true;
    alarm[1]=30
    };
Enemy Alarm [1]

GML:
if bottle_take == false{
randomize();
{
    // guess starting position
    var ranx = random(room_width);
    var rany = random(room_height);
 
    // check collisions with wall object in the game
    with (ob_wall) {
        while (point_distance(x, y, ranx, rany) < 40) {
            ranx = random(room_width);
            rany = random(room_height);
        }
    }
 
    // spawn bottles
   if global.reality_tracker < 10 //bottle counter
{
 
        instance_create_layer(random(room_width), random(room_height), "lyr_objects", ob_bottle);
   
   
   
   
}
}
}

Which doesn't throw up any errors, and it sort of works the first time when I go, as in I lose a bottle and sometimes another bottle spawns elsewhere in the room, but as I go through a second pass by the enemy - I lose a bottle to them but it definitely doesn't spawn a new one. I don't know why.

Can anyone help me out.? Much appreciated. Thanks.
 

woods

Member
you are not setting bottle_take back to false so your spawn code doesn't fire except the one time(it is false in the create event and then changed to true)

if bottle_take == false{
// spawn bottles
 
Top