Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_werewerewire_laserbullet_v_Step_0

(view raw script w/o annotations or w/e)
1
if (init == 0)
2
{
3
    active = 1;
4
    init = 1;
5
    if (attackdirection == 1)
6
    {
7
        targetx = obj_growtangle.x + random_range(-70, 70);
8
        if (targetx == x)
9
            finalpoint = 2;
10
        direction = 90;
11
    }
12
    else
13
    {
14
        targetx = obj_growtangle.x + (100 * (attackdirection - 1));
15
        direction = (attackdirection == 0) ? 180 : 0;
16
    }
17
    image_angle = direction;
18
}
19
var laserdistance = point_distance(x, y, tailx, taily);
20
if (lasertimer > 0 || laserdistance >= 100)
21
{
22
    tailx = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); }
(tailx, x, laserspeed);
23
    taily = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); }
(taily, y, laserspeed);
24
    lasertimer--;
25
    if (lasertimer <= 0 && laserdistance <= laserspeed)
26
    {
27
        if (finalpoint == 1)
28
            targety = cameray() + 560;
29
        nextpoint++;
30
        if (attackdirection == 1)
31
        {
32
            if (nextpoint == finalpoint)
33
                targety = cameray() + 560;
34
            else if (nextpoint == 2)
35
                targety = obj_growtangle.y - 100;
36
        }
37
    }
38
}
39
if (lasertimer <= 0)
40
{
41
    if (nextpoint == 2 && attackdirection != 1)
42
    {
43
        if ((y + laserspeed) >= (obj_heart.y + 8))
44
        {
45
            y = obj_heart.y + 8;
46
            targety = y;
47
            if (attackdirection == 2)
48
                targetx = camerax() - 80;
49
            else
50
                targetx = camerax() + 700;
51
            lasertimer = 15;
52
        }
53
        else
54
        {
55
            y += laserspeed;
56
        }
57
    }
58
    else if (lasertimer <= 0)
59
    {
60
        x = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); }
(x, targetx, laserspeed);
61
        y = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); }
(y, targety, laserspeed);
62
        if (point_distance(x, y, targetx, targety) <= 0)
63
            lasertimer = (attackdirection == 1) ? 15 : 5;
64
    }
65
}
66
if (grazed == 1)
67
{
68
    if (grazetimer == 0)
69
    {
70
        grazetimer = 5;
71
    }
72
    else
73
    {
74
        grazetimer--;
75
        if (grazetimer == 0)
76
            grazed = 0;
77
    }
78
}