Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_thrash_laserbullet_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
        finalpoint = 2;
8
        targetx = obj_growtangle.x + 100;
9
    }
10
    else
11
    {
12
        targety = obj_growtangle.y + (100 * (attackdirection - 1));
13
        direction = (attackdirection == 0) ? 90 : 270;
14
        image_angle = direction;
15
    }
16
}
17
var laserdistance = point_distance(x, y, tailx, taily);
18
if (lasertimer > 0 || laserdistance >= 100)
19
{
20
    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);
21
    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);
22
    lasertimer--;
23
    if (lasertimer <= 0 && laserdistance <= laserspeed)
24
    {
25
        if (attackdirection == 1)
26
            targetx = __view_get(e__VW.XView, 0) - 80;
27
        nextpoint++;
28
    }
29
}
30
if (lasertimer <= 0)
31
{
32
    if (nextpoint == 2 && attackdirection != 1)
33
    {
34
        if ((x - laserspeed) <= (obj_heart.x + 10))
35
        {
36
            x = obj_heart.x + 10;
37
            targetx = x;
38
            if (attackdirection == 2)
39
                targety = __view_get(e__VW.YView, 0) - 80;
40
            else
41
                targety = __view_get(e__VW.YView, 0) + 500;
42
            lasertimer = 15;
43
        }
44
        else
45
        {
46
            x -= laserspeed;
47
        }
48
    }
49
    else if (lasertimer <= 0)
50
    {
51
        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);
52
        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);
53
        if (point_distance(x, y, targetx, targety) <= 0)
54
            lasertimer = (attackdirection == 1) ? 15 : 5;
55
    }
56
}
57
if (grazed == 1)
58
{
59
    if (grazetimer == 0)
60
    {
61
        grazetimer = 5;
62
    }
63
    else
64
    {
65
        grazetimer--;
66
        if (grazetimer == 0)
67
            grazed = 0;
68
    }
69
}
70
71
enum e__VW
72
{
73
    XView,
74
    YView,
75
    WView,
76
    HView,
77
    Angle,
78
    HBorder,
79
    VBorder,
80
    HSpeed,
81
    VSpeed,
82
    Object,
83
    Visible,
84
    XPort,
85
    YPort,
86
    WPort,
87
    HPort,
88
    Camera,
89
    SurfaceID
90
}