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

76 lines
No EOL
1.8 KiB
Text

if alert = 0 and distance_to_object(obSpaceship) > 256 and alarm[0]=-1
{
alarm[0] = irandom_range(room_speed * 5, room_speed * 10);
}
else if distance_to_object(obSpaceship) <= 256 and !obSpaceship.inMenu
{
alert = 1;
}
if alert = 1
{
if distance_to_object(obSpaceship) > 1024
{
alert = 0;
alarm[0] = 1;
}
shipSpeed = shipMaxSpeed;
if shipHealth > 5
{
if abs(angle_difference(destAngle, direction)) <= 10 and alarm[2] = -1
{
lat = point_direction(x, y, obCursor.x, obCursor.y);
lenX = lengthdir_x(rocketLen, lat + rocketDir);
lenY = lengthdir_y(rocketLen, lat + rocketDir);
laser = instance_create_layer(x + lenX, y + lenY, "Instances", obLaser);
laser.direction = direction;
laser.owner = id;
alarm[2] = room_speed/5;
}
if distance_to_object(obSpaceship) >= 128
{
destAngle = point_direction(x, y, obSpaceship.x, obSpaceship.y);
}
else
{
destAngle += 1;
}
}
}
image_angle = direction;
speed = shipSpeed;
if direction != destAngle
{
if angle_difference(destAngle, direction)<0
{
direction -= shipTurnRate/room_speed;
}
else
{
direction += shipTurnRate/room_speed;
}
}
if (x < 0 or x > room_width or y < 0 or y > room_height)
{
destAngle = point_direction(x, y, obSpacestation.x, obSpacestation.y);
shipSpeed = shipMaxSpeed;
}
if place_meeting(x, y, obSpacestation)
{
x = xprevious - lengthdir_x(16, point_direction(x, y, obSpacestation.x, obSpacestation.y));
y = yprevious - lengthdir_y(16, point_direction(x, y, obSpacestation.x, obSpacestation.y));
alarm[1] = 1;
alarm[0] = 1;
}
if shipHealth <= 0
{
instance_create_layer(random(room_width), random(room_height), "Instances", obEnemy);
bounty = instance_create_layer(x, y, "Instances", obBounty);
bounty.amount = irandom_range(10, 25);
instance_destroy();
}