Undertale script viewer

← back to main script listing

gml_Object_obj_creditboss_Step_0

(view raw script w/o annotations or w/e)
1
if (active == 1)
2
{
3
    timer += 1;
4
    if (truetype == 0 || truetype == 1)
5
    {
6
        if (timer == 50)
7
        {
8
            for (i = 0; i < 5; i += 1)
9
            {
10
                with (cb_a[i])
11
                {
12
                    speed = 0;
13
                    direction = 0;
14
                }
15
            }
16
        }
17
        if (timer >= 50 && timer <= 70)
18
        {
19
            for (i = 0; i < 5; i += 1)
20
            {
21
                with (cb_a[i])
22
                {
23
                    image_angle = direction;
24
                    curdir = direction;
25
                    idealdir = point_direction(x, y, obj_creditsheart.x + 8, obj_creditsheart.y + 8);
26
                    facingMinusTarget = curdir - idealdir;
27
                    angleDiff = facingMinusTarget;
28
                    if (abs(facingMinusTarget) > 180)
29
                    {
30
                        if (curdir > idealdir)
31
                            angleDiff = -1 * ((360 - curdir) + idealdir);
32
                        else
33
                            angleDiff = (360 - idealdir) + curdir;
34
                    }
35
                    leastAccurateAim = 3;
36
                    if (abs(angleDiff) > leastAccurateAim)
37
                    {
38
                        dirspeed = 1;
39
                        angleDiff2 = abs(angleDiff);
40
                        if (angleDiff2 > 10)
41
                            dirspeed = 2;
42
                        if (angleDiff2 > 20)
43
                            dirspeed = 5;
44
                        if (angleDiff2 > 30)
45
                            dirspeed = 15;
46
                        if (angleDiff2 > 40)
47
                            dirspeed = 16;
48
                        if (angleDiff2 > 50)
49
                            dirspeed = 17;
50
                        if (angleDiff2 > 60)
51
                            dirspeed = 18;
52
                        if (angleDiff2 > 70)
53
                            dirspeed = 20;
54
                        if (angleDiff2 > 80)
55
                            dirspeed = 22;
56
                        if (angleDiff2 > 90)
57
                            dirspeed = 24;
58
                        if (angleDiff2 > 100)
59
                            dirspeed = 25;
60
                        if (angleDiff < 0)
61
                            dirspeed = -dirspeed;
62
                        direction -= dirspeed;
63
                    }
64
                }
65
            }
66
        }
67
        if (timer == 75)
68
        {
69
            for (i = 0; i < 5; i += 1)
70
            {
71
                with (cb_a[i])
72
                {
73
                    speed = 3;
74
                    friction = -0.5;
75
                    action = 0;
76
                }
77
            }
78
        }
79
        if (timer == 85)
80
            instance_destroy();
81
    }
82
    if (truetype == 2)
83
    {
84
        if (timer > 50 && timer < 70)
85
            x += 4;
86
        if (timer > 80 && timer < 100)
87
            x -= 4;
88
        if (timer > 130 && timer < 150)
89
            x -= 4;
90
        if (timer > 160 && timer < 180)
91
            x += 4;
92
        if (timer > 210 && timer < 230)
93
            x += 4;
94
        if (timer > 230 && timer < 250)
95
            x -= 4;
96
        if (timer == 250)
97
        {
98
            siner = 0;
99
            sf = 5;
100
        }
101
        if (timer > 250 && timer < 420)
102
        {
103
            siner += 1;
104
            x += (sin(siner / 7) * sf);
105
            sf += 0.02;
106
        }
107
        if (timer == 420)
108
            instance_destroy();
109
    }
110
    if (truetype == 3)
111
    {
112
        for (i = 0; i < 10; i += 1)
113
        {
114
            if (hspeed > 0)
115
            {
116
                with (cb_a[i])
117
                    hspeed = 0.1;
118
            }
119
            if (hspeed < 0)
120
            {
121
                with (cb_a[i])
122
                    hspeed = -0.1;
123
            }
124
            if (instance_exists(cb_a[i]))
125
            {
126
                cb_a[i].x = x;
127
                cb_a[i].y = y;
128
            }
129
            with (cb_a[i])
130
            {
131
                if (abs(aa) < 1.7)
132
                    aa *= 1.02;
133
                x += lengthdir_x(85, image_angle);
134
                y += lengthdir_y(85, image_angle);
135
            }
136
        }
137
        if (x > 1000 || x < -400)
138
            instance_destroy();
139
    }
140
}