cosmic-gms/objects/oblaser/Step_0.gml
2024-10-31 17:39:35 +03:00

37 lines
No EOL
919 B
Text

lenX = lengthdir_x(8, direction);
lenY = lengthdir_y(8, direction);
x1 = x + lenX;
x2 = x - lenX;
y1 = y + lenY;
y2 = y - lenY;
if collision_line(x1, y1, x2, y2, obSpacestation, true, false)
{
instance_destroy();
}
if collision_line(x1, y1, x2, y2, obEnemy, true, false)
{
instance_nearest(x, y, obEnemy).shipHealth -= damage;
instance_destroy();
}
if collision_line(x1, y1, x2, y2, obSpaceship, true, false)
{
if obSpaceship.shipShield >= damage
{
obSpaceship.shipShield -= damage;
obSpaceship.alarm[5] = obSpaceship.shield.shieldDelay * room_speed;
}
else if obSpaceship.shipShield < damage and obSpaceship.shield > 0
{
damage -= obSpaceship.shipShield;
obSpaceship.shipShield = 0;
obSpaceship.alarm[5] = obSpaceship.shield.shieldDelay * room_speed;
obSpaceship.shipHealth -= damage;
}
else
{
obSpaceship.shipHealth -= damage;
}
instance_destroy();
}