Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_cts_shufflers_puzzle

(view raw script w/o annotations or w/e)
1
function cts_shufflers_puzzle()
2
{
3
    scr_shuffle_controls_snowdin_13_yellow
scr_shuffle_controls_snowdin_13_yellow

function scr_shuffle_controls_snowdin_13_yellow() { var key_left = global.left_keyp; var key_right = global.right_keyp; var key_select = keyboard_multicheck_pressed(0); if (shufflers_select == true) { if (key_right) { audio_play_sound(snd_mainmenu_select, 20, 0); switch (current_shuffler) { case 0: current_shuffler = 1; break; case 1: current_shuffler = 2; break; case 2: current_shuffler = 0; break; } } if (key_left) { audio_play_sound(snd_mainmenu_select, 20, 0); switch (current_shuffler) { case 0: current_shuffler = 2; break; case 1: current_shuffler = 0; break; case 2: current_shuffler = 1; break; } } if (key_select) { audio_play_sound(snd_confirm, 20, 0); shufflers_select = false; timer += 1; } } }
();
4
    if (timer < 60)
5
    {
6
        if (timer >= 0)
7
        {
8
            with (obj_snowdin_13_swig)
9
            {
10
                if (sprite_index != spr_swig_flip_overworld_yellow)
11
                {
12
                    audio_play_sound(snd_shufflers_flip, 20, 0);
13
                    sprite_index = spr_swig_flip_overworld_yellow;
14
                    image_index = 0;
15
                    image_speed = 0.5;
16
                }
17
                else if (image_index == (image_number - 1) && image_alpha != 0)
18
                {
19
                    image_speed = 0;
20
                    image_index = image_number - 1;
21
                    image_alpha = 0;
22
                    instance_create(x, y, obj_snowdin_13_shuffler_overworld_yellow);
23
                }
24
            }
25
        }
26
        if (timer >= 15)
27
        {
28
            with (obj_snowdin_13_rephil)
29
            {
30
                if (sprite_index != spr_rephil_flip_overworld_yellow)
31
                {
32
                    audio_play_sound(snd_shufflers_flip, 20, 0);
33
                    sprite_index = spr_rephil_flip_overworld_yellow;
34
                    image_index = 0;
35
                    image_speed = 0.5;
36
                }
37
                else if (image_index == (image_number - 1) && image_alpha != 0)
38
                {
39
                    image_speed = 0;
40
                    image_index = image_number - 1;
41
                    image_alpha = 0;
42
                    instance_create(x, y, obj_snowdin_13_shuffler_overworld_yellow);
43
                }
44
            }
45
        }
46
        if (timer >= 30)
47
        {
48
            with (obj_snowdin_13_toast)
49
            {
50
                if (sprite_index != spr_toast_flip_overworld_yellow)
51
                {
52
                    audio_play_sound(snd_shufflers_flip, 20, 0);
53
                    sprite_index = spr_toast_flip_overworld_yellow;
54
                    image_index = 0;
55
                    image_speed = 0.5;
56
                }
57
                else if (image_index == (image_number - 1) && image_alpha != 0)
58
                {
59
                    image_speed = 0;
60
                    image_index = image_number - 1;
61
                    image_alpha = 0;
62
                    instance_create(x, y, obj_snowdin_13_shuffler_overworld_yellow);
63
                }
64
            }
65
        }
66
    }
67
    if (timer == 90)
68
    {
69
        scr_audio_fade
scr_audio_fade

function scr_audio_fade(arg0, arg1) { var snd = arg0; var fade_len = arg1; with (obj_radio) { audio_other_fade = true; audio_to_fade = snd; audio_fade_length = fade_len; } }
(156, 500);
70
        with (obj_snowdin_13_shuffler_overworld_yellow)
71
            has_ball = false;
72
        current_shuffler = irandom(2);
73
        shuffler[0] = instance_position(130, 200, obj_snowdin_13_shuffler_overworld_yellow);
74
        shuffler[1] = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow);
75
        shuffler[2] = instance_position(190, 200, obj_snowdin_13_shuffler_overworld_yellow);
76
    }
77
    if (timer >= 90 && timer < 140)
78
    {
79
        with (shuffler[current_shuffler])
80
        {
81
            has_ball = true;
82
            sprite_index = spr_shuffler_ball_overworld_yellow;
83
            if (image_index >= (image_number - 1))
84
                image_speed = 0;
85
            else
86
                image_speed = 0.2;
87
        }
88
    }
89
    if (timer >= 140 && timer < 190)
90
    {
91
        with (shuffler[current_shuffler])
92
        {
93
            sprite_index = spr_shuffler_ball_overworld_yellow;
94
            image_speed = -0.2;
95
            if (floor(image_index) <= 0)
96
            {
97
                image_speed = 0;
98
                image_index = 0;
99
            }
100
        }
101
    }
102
    if (timer == 189)
103
    {
104
        audio_stop_sound(shuffle_music);
105
        switch (shufflers_round)
106
        {
107
            case 1:
108
                timer = 200;
109
                shuffle_music = 159;
110
                break;
111
            case 2:
112
                timer = 610;
113
                shuffle_music = 158;
114
                break;
115
            case 3:
116
                timer = 750;
117
                shuffle_music = 157;
118
                break;
119
        }
120
        audio_play_sound(shuffle_music, 1, 1);
121
        audio_sound_gain(shuffle_music, 1, 0);
122
    }
123
    switch (timer)
124
    {
125
        case 210:
126
        case 225:
127
        case 240:
128
        case 255:
129
        case 270:
130
            current_shuffler = irandom(2);
131
            scr_shuffle_snowdin_13_yellow
scr_shuffle_snowdin_13_yellow

function scr_shuffle_snowdin_13_yellow() { var shuffle_direction = irandom(1); if (position_meeting(130, 200, shuffler[current_shuffler])) { with (shuffler[current_shuffler]) move_right = true; var shuff = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_left = true; } else if (position_meeting(160, 200, shuffler[current_shuffler])) { if (shuffle_direction == 0) { with (shuffler[current_shuffler]) move_right = true; var shuff = instance_position(190, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_left = true; } else if (shuffle_direction == 1) { with (shuffler[current_shuffler]) move_left = true; var shuff = instance_position(130, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_right = true; } } else if (position_meeting(190, 200, shuffler[current_shuffler])) { with (shuffler[current_shuffler]) move_left = true; var shuff = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_right = true; } }
();
132
            break;
133
        case 620:
134
        case 630:
135
        case 640:
136
        case 650:
137
        case 660:
138
        case 670:
139
        case 680:
140
        case 690:
141
        case 700:
142
        case 710:
143
        case 720:
144
        case 730:
145
            current_shuffler = irandom(2);
146
            scr_shuffle_snowdin_13_yellow
scr_shuffle_snowdin_13_yellow

function scr_shuffle_snowdin_13_yellow() { var shuffle_direction = irandom(1); if (position_meeting(130, 200, shuffler[current_shuffler])) { with (shuffler[current_shuffler]) move_right = true; var shuff = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_left = true; } else if (position_meeting(160, 200, shuffler[current_shuffler])) { if (shuffle_direction == 0) { with (shuffler[current_shuffler]) move_right = true; var shuff = instance_position(190, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_left = true; } else if (shuffle_direction == 1) { with (shuffler[current_shuffler]) move_left = true; var shuff = instance_position(130, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_right = true; } } else if (position_meeting(190, 200, shuffler[current_shuffler])) { with (shuffler[current_shuffler]) move_left = true; var shuff = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_right = true; } }
();
147
            break;
148
        case 760:
149
        case 767:
150
        case 774:
151
        case 781:
152
        case 788:
153
        case 795:
154
        case 802:
155
        case 809:
156
        case 816:
157
        case 823:
158
        case 830:
159
        case 837:
160
        case 844:
161
        case 851:
162
        case 858:
163
        case 864:
164
            current_shuffler = irandom(2);
165
            scr_shuffle_snowdin_13_yellow
scr_shuffle_snowdin_13_yellow

function scr_shuffle_snowdin_13_yellow() { var shuffle_direction = irandom(1); if (position_meeting(130, 200, shuffler[current_shuffler])) { with (shuffler[current_shuffler]) move_right = true; var shuff = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_left = true; } else if (position_meeting(160, 200, shuffler[current_shuffler])) { if (shuffle_direction == 0) { with (shuffler[current_shuffler]) move_right = true; var shuff = instance_position(190, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_left = true; } else if (shuffle_direction == 1) { with (shuffler[current_shuffler]) move_left = true; var shuff = instance_position(130, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_right = true; } } else if (position_meeting(190, 200, shuffler[current_shuffler])) { with (shuffler[current_shuffler]) move_left = true; var shuff = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow); with (shuff) move_right = true; } }
();
166
            break;
167
    }
168
    if (timer == 740 || timer == 847)
169
    {
170
        with (obj_snowdin_13_shuffler_overworld_yellow)
171
        {
172
            if (active == true)
173
                exit;
174
        }
175
        timer = 300;
176
    }
177
    if (timer == 300)
178
    {
179
        shufflers_select = true;
180
        current_shuffler = 1;
181
        shuffler[0] = instance_position(130, 200, obj_snowdin_13_shuffler_overworld_yellow);
182
        shuffler[1] = instance_position(160, 200, obj_snowdin_13_shuffler_overworld_yellow);
183
        shuffler[2] = instance_position(190, 200, obj_snowdin_13_shuffler_overworld_yellow);
184
    }
185
    if (timer > 302 && timer < 340)
186
    {
187
        with (shuffler[current_shuffler])
188
        {
189
            if (has_ball == true)
190
            {
191
                sprite_index = spr_shuffler_ball_overworld_yellow;
192
                other.victory = true;
193
            }
194
            else
195
            {
196
                sprite_index = spr_shuffler_noball_overworld_yellow;
197
                other.victory = false;
198
            }
199
            if (image_index == (image_number - 1))
200
            {
201
                image_speed = 0;
202
                image_index = image_number - 1;
203
            }
204
            else
205
            {
206
                image_speed = 0.2;
207
            }
208
        }
209
    }
210
    if (timer == 340)
211
    {
212
        if (victory == true)
213
            audio_play_sound(snd_success, 20, 0);
214
        else
215
            audio_play_sound(snd_hurt, 20, 0);
216
    }
217
    if (timer >= 340 && timer < 380)
218
    {
219
        with (shuffler[current_shuffler])
220
        {
221
            if (floor(image_index) == 0)
222
            {
223
                image_index = 0;
224
                image_speed = 0;
225
            }
226
            else
227
            {
228
                image_speed = -0.2;
229
            }
230
        }
231
    }
232
    if (timer == 379)
233
    {
234
        scr_audio_fade
scr_audio_fade

function scr_audio_fade(arg0, arg1) { var snd = arg0; var fade_len = arg1; with (obj_radio) { audio_other_fade = true; audio_to_fade = snd; audio_fade_length = fade_len; } }
(shuffle_music, 500);
235
        if (victory == true)
236
        {
237
            if (shufflers_round == 3)
238
            {
239
                shufflers_win = true;
240
                timer = 420;
241
                audio_stop_sound(shuffle_music);
242
            }
243
            else if (shufflers_round == 1)
244
            {
245
                timer++;
246
                scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
247
                with (msg)
248
                {
249
                    portrait = false;
250
                    message[0] = "* Nice eye, kid.";
251
                    message[1] = "* Keep it up.";
252
                }
253
            }
254
            else if (shufflers_round == 2)
255
            {
256
                timer++;
257
                scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
258
                with (msg)
259
                {
260
                    portrait = false;
261
                    message[0] = "* You're doin' good, kid.";
262
                    message[1] = "* Now don't let it go to#  ya head.";
263
                }
264
            }
265
        }
266
        else
267
        {
268
            failure = true;
269
            shufflers_failsafe += 1;
270
            shufflers_select = false;
271
            shufflers_round = 1;
272
            global.snowdin_flag[8] = 3;
273
            timer = 382;
274
        }
275
    }
276
    else if (timer == 380)
277
    {
278
        if (!instance_exists(obj_dialogue))
279
        {
280
            timer = 89;
281
            victory = false;
282
            shufflers_round++;
283
            with (obj_snowdin_13_shuffler_overworld_yellow)
284
            {
285
                if (other.shufflers_round > 1)
286
                    shuffle_speed = 6;
287
            }
288
        }
289
    }
290
    if (timer < 460 && (failure == true || shufflers_win == true))
291
    {
292
        if (timer >= 435)
293
        {
294
            with (obj_snowdin_13_rephil)
295
            {
296
                if (image_alpha != 1)
297
                {
298
                    image_alpha = 1;
299
                    instance_destroy(instance_position(x, y, obj_snowdin_13_shuffler_overworld_yellow));
300
                    image_index = image_number - 1;
301
                    image_speed = -0.5;
302
                }
303
                else if (image_index == 0)
304
                {
305
                    image_speed = 0;
306
                    image_index = 0;
307
                    sprite_index = spr_rephil_overworld_yellow;
308
                }
309
            }
310
        }
311
        if (timer >= 421)
312
        {
313
            with (obj_snowdin_13_swig)
314
            {
315
                if (image_alpha != 1)
316
                {
317
                    image_alpha = 1;
318
                    instance_destroy(instance_position(x, y, obj_snowdin_13_shuffler_overworld_yellow));
319
                    image_index = image_number - 1;
320
                    image_speed = -0.5;
321
                }
322
                else if (image_index == 0)
323
                {
324
                    image_speed = 0;
325
                    image_index = 0;
326
                    sprite_index = spr_swig_overworld_yellow;
327
                }
328
            }
329
        }
330
        if (timer == 450)
331
        {
332
            with (obj_snowdin_13_toast)
333
            {
334
                if (image_alpha != 1)
335
                {
336
                    image_alpha = 1;
337
                    instance_destroy(instance_position(x, y, obj_snowdin_13_shuffler_overworld_yellow));
338
                    image_index = image_number - 1;
339
                    image_speed = -0.5;
340
                }
341
                else if (image_index == 0)
342
                {
343
                    image_speed = 0;
344
                    image_index = 0;
345
                    sprite_index = spr_toast_overworld_yellow;
346
                    if (other.failure == true)
347
                    {
348
                        other.shufflers_puzzle = false;
349
                    }
350
                    else if (other.shufflers_win == true)
351
                    {
352
                        audio_play_sound(mus_occupied_turf_yellow, 1, 1);
353
                        global.snowdin_flag[8] = 4;
354
                        other.shufflers_puzzle = false;
355
                    }
356
                    other.timer++;
357
                }
358
            }
359
        }
360
    }
361
    if (timer <= 300 || (timer >= 302 && timer < 380) || (timer >= 382 && timer < 450) || timer > 500)
362
        timer++;
363
}