Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_mike_hand_Step_0

(view raw script w/o annotations or w/e)
1
with (obj_mike_controller)
2
{
3
    if (!__usable)
4
        exit;
5
    with (obj_juggle_collision)
6
    {
7
        var angle = point_direction(other.mx, other.my, obj_mike_controller.x, obj_mike_controller.y);
8
        x = other.mx + lengthdir_x(20, angle + 180);
9
        y = other.my + lengthdir_y(20, angle + 180);
10
    }
11
    if (!battle_active)
12
        other.depth = 200;
13
    else
14
        other.depth = -6;
15
    if (global.interact > 0 && !battle_active)
16
    {
17
        if (scr_mouse_leftrelease())
18
            obj_mike_hand.buffered_release = true;
19
        else if (scr_mouse_leftclick())
20
            obj_mike_hand.buffered_release = false;
21
    }
22
    if (global.interact == 2)
23
        exit;
24
    if (!battle_active && instance_number(obj_micmenu) == 0 && !i_ex(obj_dialoguer))
25
    {
26
        var ob = -1;
27
        var ob2 = -1;
28
        if (i_ex(obj_mouse_drawer) && mx > obj_mouse_drawer.bbox_left && mx < obj_mouse_drawer.bbox_right && my > obj_mouse_drawer.bbox_top && my < obj_mouse_drawer.bbox_bottom && obj_mouse_drawer.act < 3)
29
            ob2 = 651;
30
        if (i_ex(obj_mouse_hat))
31
        {
32
            var _li = ds_list_create();
33
            ob = -4;
34
            collision_rectangle_list(mx - 10, my - 30, mx + 10, my + 10, obj_mouse_hat, false, true, _li, false);
35
            for (var i = 0; i < ds_list_size(_li); i++)
36
            {
37
                if (ds_list_find_value(_li, i).pickable && (ob == -4 || ob.depth > ds_list_find_value(_li, i).depth))
38
                    ob = ds_list_find_value(_li, i);
39
            }
40
            ds_list_destroy(_li);
41
            if (i_ex(ob))
42
            {
43
                with (ob)
44
                {
45
                    if (!can_hat)
46
                    {
47
                        var _check = 0;
48
                        switch (sprite_index)
49
                        {
50
                            case spr_mike_s:
51
                                _check = 1;
52
                                break;
53
                            case spr_mike_l:
54
                                _check = 2;
55
                                break;
56
                            case spr_mike_m:
57
                                _check = 3;
58
                                break;
59
                        }
60
                        with (obj_mike_minigame_tv)
61
                        {
62
                            lastmike = _check;
63
                            minigame = _check;
64
                        }
65
                    }
66
                }
67
            }
68
        }
69
        with (obj_treasure_room)
70
        {
71
            if (image_index == 1 && global.interact == 0)
72
            {
73
                var _o = instance_create(x, y, obj_mouse_hat);
74
                with (_o)
75
                {
76
                    linked_char = -1;
77
                    speed = 0;
78
                    gravity = 0;
79
                    sprite_index = other.sprite_index;
80
                    image_index = 1;
81
                    
scr_depth
scr_depth

function
scr_depth(arg0 = id, arg1 = 0)
{ with (arg0) depth = 100000 - ((y * 10) + (sprite_height * 10) + (arg1 * 10)); }
();
82
                }
83
                instance_destroy();
84
            }
85
        }
86
        if (ob && global.interact == 0)
87
        {
88
            if (!scr_mouse_left() && !scr_mouse_leftclick())
89
            {
90
                if (my > (ob.y + 30 + ob.yoff))
91
                    hand_type = 6;
92
                else
93
                    hand_type = 6;
94
            }
95
            else
96
            {
97
                hand_type = 2;
98
            }
99
            if (scr_mouse_leftclick())
100
            {
101
                with (ob)
102
                    ob = unstack_hat(ob);
103
                with (ob)
104
                {
105
                    act = 1;
106
                    linked_char = -1;
107
                    speed = 0;
108
                    gravity = 0;
109
                }
110
                hand_type = 2;
111
                hand_target = ob;
112
            }
113
        }
114
        else if (ob2 && global.interact == 0)
115
        {
116
            if (my < (ob2.y + (20 + ob2.yy)) && my > ((ob2.y + ob2.yy) - 20))
117
            {
118
                if (ob2.act == 2)
119
                {
120
                    with (obj_mike_controller)
121
                    {
122
                        if (scr_mouse_left())
123
                            hand_type = 6;
124
                        else
125
                            hand_type = 6;
126
                    }
127
                }
128
                else if (ob2.act < 2)
129
                {
130
                    hand_type = 1;
131
                }
132
                if (scr_mouse_leftclick())
133
                {
134
                    with (ob2)
135
                    {
136
                        if (act == 2)
137
                        {
138
                            act = 3;
139
                            snd_play(snd_item);
140
                            var bighat = instance_create(obj_mike_controller.mx, obj_mike_controller.my, obj_mouse_hat);
141
                            with (bighat)
142
                            {
143
                                type = 0;
144
                                scale = 1;
145
                                act = 1;
146
                                image_index = 5;
147
                            }
148
                            with (obj_mike_controller)
149
                            {
150
                                hand_type = 2;
151
                                hand_target = bighat;
152
                            }
153
                        }
154
                    }
155
                }
156
            }
157
            else if (ob2.act < 2 && my < (ob2.y + (100 + ob2.yy)) && my > (ob2.y + (50 + ob2.yy)))
158
            {
159
                if (hand_type != 2)
160
                {
161
                    if (ob2.act == 0)
162
                        hand_type = 1;
163
                }
164
                if ((hand_type != 2 || hand_target == ob2) && (scr_mouse_left() || obj_mike_hand.buffered_release))
165
                {
166
                    with (ob2)
167
                    {
168
                        act = 1;
169
                        other.hand_type = 2;
170
                    }
171
                }
172
            }
173
            else
174
            {
175
                ob2 = false;
176
            }
177
        }
178
        if (!ob && !ob2)
179
        {
180
            if ((room == room_dw_castle_tv_zone_3 && obj_mouse_drawer.act != 1) || room != room_dw_castle_tv_zone_3)
181
            {
182
                if (hand_type == 1 || hand_type == 6)
183
                    hand_type = 0;
184
            }
185
        }
186
        with (obj_mouse_hat)
187
        {
188
            if (act == 1)
189
            {
190
                depth = obj_mike_hand.depth + 1;
191
                x = other.mx - (10 * image_xscale);
192
                y = other.my;
193
            }
194
        }
195
        if ((scr_mouse_leftrelease() || obj_mike_hand.buffered_release) && global.interact == 0)
196
        {
197
            obj_mike_hand.buffered_release = false;
198
            with (obj_mouse_drawer)
199
            {
200
                if (act == 1)
201
                    act = 0;
202
            }
203
            with (obj_mouse_hat)
204
            {
205
                ob = -4;
206
                if (act == 1)
207
                {
208
                    with (obj_caterpillarchara)
209
                    {
210
                        var yy = 0;
211
                        with (obj_mouse_hat)
212
                        {
213
                            if (linked_char == other.id)
214
                                yy = 20 * array_length(spritestack);
215
                        }
216
                        if (collision_rectangle(bbox_left, y - yy, bbox_right, bbox_bottom, other, 0, 0))
217
                        {
218
                            if (ob == -4 || ob.depth > depth)
219
                                ob = id;
220
                        }
221
                    }
222
                    with (obj_mainchara)
223
                    {
224
                        var yy = 0;
225
                        with (obj_mouse_hat)
226
                        {
227
                            if (linked_char == other.id)
228
                                yy = 20 * array_length(spritestack);
229
                        }
230
                        if (collision_rectangle(bbox_left, y - yy, bbox_right, bbox_bottom, other, 0, 0))
231
                        {
232
                            if (ob == -4 || ob.depth > depth)
233
                                ob = id;
234
                        }
235
                    }
236
                    if (can_hat)
237
                    {
238
                        if (ob)
239
                        {
240
                            snd_play(snd_item);
241
                            with (other)
242
                                hand_type = 2;
243
                            with (obj_mouse_hat)
244
                            {
245
                                if (linked_char == ob)
246
                                {
247
                                    stack_hat(other.sprite_index, other.image_index);
248
                                    with (other)
249
                                        instance_destroy();
250
                                    exit;
251
                                }
252
                            }
253
                            act = 2;
254
                            linked_char = ob;
255
                        }
256
                        else
257
                        {
258
                            event_user(5);
259
                        }
260
                    }
261
                    else
262
                    {
263
                        var xpad = 10;
264
                        var ypad = 10;
265
                        ob = collision_rectangle(bbox_left + xoff + xpad, bbox_top + yoff + ypad, (bbox_right + xoff) - xpad, (bbox_bottom + yoff) - ypad, obj_mike_slot, 1, 0);
266
                        if (ob && ob.act == 0)
267
                        {
268
                            act = 3;
269
                            global.interact = 2;
270
                            x = (ob.x + 80) - (sprite_width / 2);
271
                            y = (ob.y - sprite_height) + 3;
272
                            ob.act = 1;
273
                            alarm[0]
 = 15;
gml_Object_obj_mike_hand_Alarm_0.gml

var _sfx = snd_play(snd_wing); snd_volume(_sfx, 0.5, 0); snd_pitch(_sfx, random_range(0.9, 1.1));
274
                            switch (sprite_index)
275
                            {
276
                                case spr_mike_l:
277
                                    ob.col = 255;
278
                                    break;
279
                                case spr_mike_m:
280
                                    ob.col = 127999;
281
                                    break;
282
                                case spr_mike_s:
283
                                    ob.col = 13217535;
284
                                    break;
285
                            }
286
                            
scr_depth
scr_depth

function
scr_depth(arg0 = id, arg1 = 0)
{ with (arg0) depth = 100000 - ((y * 10) + (sprite_height * 10) + (arg1 * 10)); }
(undefined, 34);
287
                            
scr_shakescreen
scr_shakescreen

function
scr_shakescreen(arg0 = 4, arg1 = 4)
{ var shaker = instance_create(x, y, obj_shake); if (i_ex(shaker)) { shaker.shakex = arg0; shaker.shakey = arg1; } }
(2, 6);
288
                            snd_play(snd_equip);
289
                            with (obj_mike_slot)
290
                            {
291
                                repeat (16)
292
                                    instance_create(x + (random_range(10, 70) * 2), y + 30, obj_mike_smoke_small);
293
                            }
294
                        }
295
                        else
296
                        {
297
                            event_user(5);
298
                        }
299
                    }
300
                }
301
            }
302
        }
303
    }
304
}