Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_holemouse_Step_0

(view raw script w/o annotations or w/e)
1
bouncethisframe = 0;
2
if (initas == 0)
3
{
4
    image_alpha = 0;
5
    turnfreeze = 0;
6
    initas = 1;
7
    turndir = "right";
8
    drawx = x;
9
    drawy = y;
10
    moved = 0;
11
}
12
if (blockedstart == false)
13
{
14
    if (con == 0)
15
    {
16
        image_alpha += 0.25;
17
        y += 4;
18
        if (image_alpha >= 1.5)
19
        {
20
            image_alpha = 1;
21
            con = 1;
22
            y = ystart + 40;
23
        }
24
    }
25
    if (con == 1)
26
    {
27
        timer++;
28
        if (timer >= 2)
29
        {
30
            moved = 1;
31
            breakcount = 0;
32
            remdir = direction;
33
            while (breakcount < 4)
34
            {
35
                mx = lengthdir_x(40, direction);
36
                my = lengthdir_y(40, direction);
37
                blockcheck = instance_place(x + mx, y + my, obj_holemouse_block_counterclockwise);
38
                if (blockcheck == -4)
39
                    blockcheck = instance_place(x + mx, y + my, obj_holemouse_invis_clockwise);
40
                if (blockcheck == -4)
41
                    blockcheck = instance_place(x + mx, y + my, obj_holemouse_block_clockwise_moveable);
42
                if (blockcheck != -4)
43
                {
44
                    blockcheck.flash = 1;
45
                    blockcheck.flashtimer = 0;
46
                    if (blockcheck.orientation == "left")
47
                    {
48
                        direction += 90;
49
                        turndir = "left";
50
                    }
51
                    if (blockcheck.orientation == "right")
52
                    {
53
                        direction -= 90;
54
                        turndir = "right";
55
                    }
56
                    if (direction >= 360)
57
                        direction -= 360;
58
                    if (direction < 0)
59
                        direction += 360;
60
                    breakcount++;
61
                    if (direction == (remdir - 180) || direction == (remdir + 180))
62
                        direction += 90;
63
                    if (breakcount == 4)
64
                    {
65
                        direction = remdir + 180;
66
                        if (direction > 360)
67
                            direction -= 360;
68
                        mx = lengthdir_x(40, direction);
69
                        my = lengthdir_y(40, direction);
70
                    }
71
                    turnfx = scr_afterimage
scr_afterimage

function scr_afterimage() { afterimage = instance_create(x, y, obj_afterimage); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
();
72
                    turnfx.image_angle = direction;
73
                    turnfx.sprite_index = spr_holemouse_turnrightfx;
74
                    turnfx.image_index = 0;
75
                    turnfx.x += 20;
76
                    turnfx.y += 20;
77
                    if (turndir == "right")
78
                        turnfx.image_index = 1;
79
                }
80
                else
81
                {
82
                    breakcount = 4;
83
                }
84
            }
85
            if (remdir != direction && turnfreeze <= 0)
86
                turnfreeze = 2;
87
            turnfreeze--;
88
            if (turnfreeze <= 0)
89
            {
90
                x += mx;
91
                y += my;
92
            }
93
            timer = 0;
94
        }
95
    }
96
    if (con == 2)
97
    {
98
        depth += 1;
99
        y -= 4;
100
        image_alpha -= 0.25;
101
        deathtimer++;
102
        if (deathtimer >= 3)
103
            instance_destroy();
104
    }
105
    if (x > (room_width + 40) || x < -40 || y > (room_height + 40) || y < -40)
106
        instance_destroy();
107
}
108
if (blockedstart == true)
109
{
110
    timer++;
111
    if (timer == 10)
112
        instance_destroy();
113
}
114
if (con == 1)
115
{
116
    lifespan--;
117
    if (lifespan < 1)
118
    {
119
        image_alpha *= 0.9;
120
        if (image_alpha < 0.05)
121
            instance_destroy();
122
    }
123
}
124
if (x < camerax() || x > (camerax() + 640) || y < cameray() || y > (cameray() + 480) || x < (0 - (sprite_width * 2)) || x > (room_width + (sprite_width * 2)) || y > (room_height + (sprite_height * 2)) || y < (0 - (sprite_height * 2)))
125
    instance_destroy();
126
if (con == 5)
127
{
128
    if (bouncecon == 0)
129
    {
130
        depth = 5000;
131
        if (room == room_dw_city_mice)
132
        {
133
            if (obj_controller_dw_city_mice.noelleScared <= 0)
134
            {
135
                bounceTargetX = 320;
136
                bounceTargetY = 320;
137
                bounceTargetDir = 180;
138
            }
139
            else
140
            {
141
                bounceTargetX = 485;
142
                bounceTargetY = 320;
143
                bounceTargetDir = 90;
144
            }
145
        }
146
        if (room == room_dw_city_mice2)
147
        {
148
            bounceTargetX = 400;
149
            bounceTargetY = 222;
150
            bounceTargetDir = 180;
151
        }
152
        customSprite = spr_holemouse_exit;
153
        bouncelength = 15;
154
        snd_play(snd_jump);
155
        fakeYSpeed = -bouncelength;
156
        scr_move_to_point_over_time
scr_move_to_point_over_time

function scr_move_to_point_over_time(arg0, arg1, arg2) { _mmm = instance_create(x, y, obj_move_to_point); _mmm.target = id; _mmm.movex = arg0; _mmm.movey = arg1; _mmm.movemax = arg2; return _mmm; }
(bounceTargetX, bounceTargetY, bouncelength);
157
        bouncetimer = 0;
158
        bouncecon = 1;
159
    }
160
    if (bouncecon == 1)
161
    {
162
        fakeY += fakeYSpeed;
163
        fakeYSpeed += 2;
164
        bouncetimer++;
165
        if ((bouncetimer % 2) == 0)
166
        {
167
            hafterimage = scr_afterimage
scr_afterimage

function scr_afterimage() { afterimage = instance_create(x, y, obj_afterimage); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
();
168
            hafterimage.sprite_index = spr_heartsmall;
169
            hafterimage.vspeed = -4 - random(2);
170
            hafterimage.hspeed = 4 - random(8);
171
            hafterimage.image_xscale = 1;
172
            hafterimage.image_yscale = 1;
173
            hafterimage.friction = 0.5;
174
            hafterimage.x += 10 + random(20);
175
            hafterimage.y += 10 + random(20) + fakeY;
176
        }
177
        if (bouncetimer >= (bouncelength + 1))
178
        {
179
            x = bounceTargetX;
180
            y = bounceTargetY;
181
            fakeY = 1;
182
            fakeYSpeed = 0;
183
            bouncecon = 2;
184
            bouncetimer = 0;
185
            depth = 900000;
186
        }
187
    }
188
    if (bouncecon == 2)
189
    {
190
        bouncetimer++;
191
        depth++;
192
        direction = bounceTargetDir;
193
        if (direction != 90)
194
            customSprite = spr_holemouse;
195
        if (bouncetimer >= 2)
196
        {
197
            x += lengthdir_x(4, direction);
198
            y += lengthdir_y(4, direction);
199
        }
200
        if (bouncetimer >= 6)
201
        {
202
            y = bounceTargetY;
203
            x = bounceTargetX;
204
            con = 1;
205
            if (room == room_dw_city_mice)
206
                nointeract = false;
207
            direction = bounceTargetDir;
208
        }
209
    }
210
}