Deltarune (Chapter 2) script viewer

← back to main script listing

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