Step event order in a collision

Axl Trauts

Member
Hi,

I have a Boss object, which when hit, starts to flash (like a Megaman boss) and while it's flashing is immune to damage. The immune flag state is "boss_inmune = 1".

All weapon ammunition objects check collisions on the Step event using a script. That script check if the "Enemy" objects have the "boss_inmune" flag and if its set to 0, to deal damage, or 1 to exit the script.

The thing is I want the flash animation to run for 1 second before losing the immune state and receive damage again. The problem happens here:

Boss object Step event when receiving damage and setting immunity
GML:
var inst = instance_place(x,y,par_arma); // collision with weapon parent objects.
if(inst != noone && sprite_index != spr_boss4_tanque_blanco) //if collision happens and the sprite is not the white (blanco) flashing sprite
{    sprite_index = spr_boss4_tanque_blanco; //sets the sprite to the flashing sprite
    alarma_inmune += 1;  //starts the 30 second immunity alarm
    //boss_inmune = 1;    //sets immunity state to 1
}
That immunity state runs before the weapon Step event, or before the damage script inside the weapon Step event. As this flashing is specific to this boss, I wouldn't like to put it on the weapon Step event. Do you have any idea how to set it correctly?

P.S.: Maybe I'll drop the flashing alarm and check for sprite animation instead.
 
Last edited:

Axl Trauts

Member
Just in case, for more information:

Weapon (arma) ammunition Step event:
GML:
scr_arma_dmg("TODO"); // TODO means this weapon deals All types of damage. It's a thing on my game.
Script scr_arma_dmg
Code:
/// colisión del Enemigo u Obstaculo con PARENT_ARMA
tenemigo=argument0;

instancia = instance_place(x, y, par_Enemigo) // check with boss object, which is an enemy.
var inmune = variable_instance_exists(instancia, "boss_inmune");    //check if the enemy is a boss and has the variable within created
if (instancia !=noone)
{    if(tenemigo==instancia.tipo_enemigo || instancia.tipo_enemigo="TODO" || tenemigo == "TODO") // the weapon type immunity I told you about
    {   if inmune == 1
        {    if(instancia.boss_inmune == 0)                              // if boss is not immune
            {    instancia.salud = instancia.salud - dmg;            // deal damage
            }
        }
        else
        {    instancia.salud = instancia.salud - dmg;
        }
        if destruible == 1                                                   // destroy the weapon ammo
        {    instance_destroy();
        }
    }
}
 

Axl Trauts

Member
Update: Well I put it on the weapon's script:

if inmune == 1
{ if(instancia.boss_inmune == 0) // if boss is not immune
{ instancia.salud = instancia.salud - dmg; // deal damage
instancia.boss_inmune = 1;
}
}

Still don't like it, because the flashing thins is very specific to one boss. The immunity state is to check when you first meet the boss (on the same visible portion of the view and you wait for some animation or transition to happen before the boss is active (Like, the boss presentation in Megaman).
 

Axl Trauts

Member
Another update: I tried checking it on the boss' Collision Event, so the first to check are the Step events on both colliding objects. Same problem, the "boss_inmune" flag is set to 1 before the damage script on the weapon ammo object.
 

Axl Trauts

Member
Another update: Adding the last IF works, but I'm still not sure is the best way. I'll skip the alarm later and check if the image_index is > 0. Still it doesn't feel right.

var inst = instance_place(x,y,par_arma);
if(inst != noone && sprite_index != spr_boss4_tanque_blanco)
{ sprite_index = spr_boss4_tanque_blanco;
alarma_inmune += 1;
//boss_inmune = 1;
}

if(alarma_inmune > 1 && alarma_inmune < 30)
{ boss_inmune = 1;
}
 
Top