Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_steamworks_manta_Step_0

(view raw script w/o annotations or w/e)
1
if (live_call())
2
    return global.live_result;
3
switch (manta_state)
4
{
5
    case 0:
6
        if (scr_interact
scr_interact

function scr_interact() { if (distance_to_object(obj_pl) < 20 && obj_pl.state == scr_normal_state) { var pl_dir = obj_pl.direction; var pl_x = 0; var pl_y = 0; var check_distance_x = 0; var check_distance_y = 0; switch (pl_dir) { case 0: pl_x = obj_pl.bbox_right; pl_y = obj_pl.bbox_top + 1; check_distance_x = 20; break; case 180: pl_x = obj_pl.bbox_left; pl_y = obj_pl.bbox_top + 1; check_distance_x = -20; break; case 90: pl_x = obj_pl.x; pl_y = obj_pl.bbox_top; check_distance_y = -20; break; case 270: pl_x = obj_pl.x; pl_y = obj_pl.bbox_bottom; check_distance_y = 20; break; } if (collision_line_first(pl_x, pl_y, pl_x + check_distance_x, pl_y + check_distance_y, id, false, false)) return true; } }
() && keyboard_multicheck_pressed(0))
7
            manta_prompt = true;
8
        if (manta_prompt == true)
9
        {
10
            scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
11
            with (msg)
12
            {
13
                message[0] = "* (Take a ride?)";
14
                ch_msg = 0;
15
                ch[1] = "Yes";
16
                ch[2] = "No";
17
                if (outcome == 1)
18
                {
19
                    with (other)
20
                        scr_follower_into_actor
scr_follower_into_actor

function scr_follower_into_actor() { if (global.party_member == -4) return false; actor_follower = instance_create(global.party_member.x, global.party_member.y, global.party_member.npc_actor); with (global.party_member) { switch (sprite_index) { case up_sprite: case up_sprite_idle: case up_sprite_run: other.actor_follower.npc_direction = "up"; other.actor_follower.sprite_index = other.actor_follower.up_sprite; break; case down_sprite: case down_sprite_idle: case down_sprite_run: other.actor_follower.npc_direction = "down"; other.actor_follower.sprite_index = other.actor_follower.down_sprite; break; case left_sprite: case left_sprite_idle: case left_sprite_run: other.actor_follower.npc_direction = "left"; other.actor_follower.sprite_index = other.actor_follower.left_sprite; break; case right_sprite: case right_sprite_idle: case right_sprite_run: other.actor_follower.sprite_index = other.actor_follower.right_sprite; break; } instance_destroy(); } return true; }
();
21
                    instance_create(obj_pl.x, obj_pl.y, obj_player_npc);
22
                    other.manta_state = 2;
23
                }
24
                else if (outcome == 2)
25
                {
26
                    other.manta_state = 0;
27
                }
28
                if (outcome != 0)
29
                    other.manta_prompt = false;
30
            }
31
        }
32
        if (manta_has_passengers == true)
33
        {
34
            if (arrows_alpha < 1)
35
                arrows_alpha += 0.25;
36
            if (arrows_alpha > 0.35)
37
            {
38
                if (global.down_keyp)
39
                    move_in_direction = "down";
40
                else if (global.up_keyp)
41
                    move_in_direction = "up";
42
                else if (global.right_keyp)
43
                    move_in_direction = "right";
44
                else if (global.left_keyp)
45
                    move_in_direction = "left";
46
            }
47
        }
48
        break;
49
    case 1:
50
        if (!audio_is_playing(snd_manta_sail))
51
            audio_play_sound(snd_manta_sail, 1, 0);
52
        var check_distance = 40;
53
        var hor_dir = (sprite_index == (spr_steamworks_manta_right - sprite_index)) == 1344;
54
        var ver_dir = (sprite_index == (spr_steamworks_manta_down - sprite_index)) == 1341;
55
        var checkpoint = collision_line(x, y, x + (hor_dir * check_distance), y + (ver_dir * check_distance), obj_steamworks_manta_checkpoint, false, true);
56
        if (checkpoint != -4 && checkpoint.active == false)
57
        {
58
            if (x < (checkpoint.x + 4) && x > (checkpoint.x - 4) && y < (checkpoint.y + 4) && y > (checkpoint.y - 4))
59
            {
60
                hspeed_current = 0;
61
                vspeed_current = 0;
62
                hspeed_decc = 0;
63
                vspeed_decc = 0;
64
                manta_state = 0;
65
                audio_play_sound(snd_manta_stop_go, 1, 0);
66
                x = checkpoint.x;
67
                y = checkpoint.y;
68
                checkpoint.active = true;
69
            }
70
            up_free = checkpoint.mpoint_up_free;
71
            down_free = checkpoint.mpoint_down_free;
72
            left_free = checkpoint.mpoint_left_free;
73
            right_free = checkpoint.mpoint_right_free;
74
            can_dock = checkpoint.mpoint_can_dock;
75
            dock_x = checkpoint.mpoint_dock_xx;
76
            dock_y = checkpoint.mpoint_dock_yy;
77
        }
78
        if (arrows_alpha > 0)
79
            arrows_alpha -= 0.3;
80
        break;
81
    case 2:
82
        if (manta_get_on_noloop == false)
83
        {
84
            audio_play_sound(snd_manta_startup, 1, 0);
85
            manta_get_on_noloop = true;
86
        }
87
        var npcx, npcy, end_dir, plx, ply;
88
        switch (manta_dir)
89
        {
90
            case 0:
91
                end_dir = "right";
92
                plx = x + 5;
93
                ply = y - 15;
94
                npcx = x - 10;
95
                npcy = y - 15;
96
                break;
97
            case 90:
98
                end_dir = "up";
99
                plx = x;
100
                ply = y - 10;
101
                npcx = x;
102
                npcy = y;
103
                break;
104
            case 180:
105
                end_dir = "left";
106
                plx = x - 5;
107
                ply = y - 15;
108
                npcx = x + 10;
109
                npcy = y - 15;
110
                break;
111
            case 270:
112
                end_dir = "down";
113
                plx = x;
114
                ply = y;
115
                npcx = x;
116
                npcy = y - 10;
117
                break;
118
        }
119
        var dir_prio;
120
        if (abs(obj_player_npc.x - x) > abs(obj_player_npc.y - y))
121
            dir_prio = "y";
122
        else
123
            dir_prio = "x";
124
        var follower_arrived = false;
125
        if (global.party_member != -4)
126
        {
127
            cutscene_npc_walk(actor_follower, npcx, npcy, 3, dir_prio, end_dir);
128
            if (actor_follower.x == npcx && actor_follower.y == npcy)
129
                follower_arrived = true;
130
        }
131
        if (scr_camera_move
scr_camera_move

function scr_camera_move(arg0, arg1, arg2) { if (!instance_exists(obj_camera)) { instance_create(__view_get(e__VW.Object, 0).x, __view_get(e__VW.Object, 0).y, obj_camera); __view_set(e__VW.Object, 0, obj_camera); } else { obj_camera.x = __view_get(e__VW.Object, 0).x; obj_camera.y = __view_get(e__VW.Object, 0).y; __view_set(e__VW.Object, 0, obj_camera); } obj_camera.move = true; obj_camera.xx = arg0; obj_camera.yy = arg1; obj_camera.spd = arg2; if (abs(arg0 - obj_camera.x) <= arg2 && abs(arg1 - obj_camera.y) <= arg2) return true; else return false; } enum e__VW { XView, YView, WView, HView, Angle, HBorder, VBorder, HSpeed, VSpeed, Object, Visible, XPort, YPort, WPort, HPort, Camera, SurfaceID }
(x, y, 3) && cutscene_npc_walk(1168, plx, ply, 3, dir_prio, end_dir))
132
        {
133
            if (global.party_member != -4 && follower_arrived == false)
134
                exit;
135
            instance_destroy(obj_player_npc);
136
            manta_state = 0;
137
            manta_has_passengers = true;
138
            __view_set(e__VW.Object, 0, id);
139
        }
140
        var checkpoint = instance_nearest(x, y, obj_steamworks_manta_checkpoint);
141
        if (checkpoint != -4)
142
        {
143
            up_free = checkpoint.mpoint_up_free;
144
            down_free = checkpoint.mpoint_down_free;
145
            left_free = checkpoint.mpoint_left_free;
146
            right_free = checkpoint.mpoint_right_free;
147
            can_dock = checkpoint.mpoint_can_dock;
148
            dock_x = checkpoint.mpoint_dock_xx;
149
            dock_y = checkpoint.mpoint_dock_yy;
150
        }
151
        break;
152
    case 3:
153
        if (global.sworks_flag[5] < 2 && room == rm_steamworks_19)
154
        {
155
            scr_text
scr_text

function scr_text() { if (!instance_exists(obj_dialogue)) msg = instance_create(x, y, obj_dialogue); }
();
156
            with (msg)
157
            {
158
                if (global.route == 2)
159
                {
160
                    sndfnt_array[0] = 391;
161
                    sndfnt_array[1] = 108;
162
                    sndfnt_array[2] = 108;
163
                    sndfnt_array[3] = 391;
164
                    message[0] = "* You h-ave reached your#  destination-bzzt.";
165
                    message[1] = "* Thanks for the help.";
166
                    message[2] = "* Let's keep moving,#  Clover.";
167
                    message[3] = "* If you need another#  r-ride, I'll be#  here......bzzt.";
168
                    prt[1] = 377;
169
                    prt[2] = 370;
170
                }
171
                else
172
                {
173
                    message[0] = "* You h-ave reached your#  destination-bzzt.";
174
                    message[1] = "* If you need another#  r-ride, I'll be#  here......bzzt.";
175
                }
176
            }
177
            global.sworks_flag[5] = 2;
178
        }
179
        if (global.dialogue_open)
180
            exit;
181
        if (!instance_exists(obj_player_npc))
182
            instance_create(obj_pl.x, obj_pl.y, obj_player_npc);
183
        var follower_arrived = true;
184
        if (global.party_member != -4)
185
        {
186
            follower_arrived = false;
187
            cutscene_npc_walk(actor_follower, dock_x, dock_y, 3, "x", obj_player_npc.npc_direction);
188
            if (actor_follower.x == dock_x && actor_follower.y == dock_y)
189
                follower_arrived = true;
190
        }
191
        if (scr_camera_move
scr_camera_move

function scr_camera_move(arg0, arg1, arg2) { if (!instance_exists(obj_camera)) { instance_create(__view_get(e__VW.Object, 0).x, __view_get(e__VW.Object, 0).y, obj_camera); __view_set(e__VW.Object, 0, obj_camera); } else { obj_camera.x = __view_get(e__VW.Object, 0).x; obj_camera.y = __view_get(e__VW.Object, 0).y; __view_set(e__VW.Object, 0, obj_camera); } obj_camera.move = true; obj_camera.xx = arg0; obj_camera.yy = arg1; obj_camera.spd = arg2; if (abs(arg0 - obj_camera.x) <= arg2 && abs(arg1 - obj_camera.y) <= arg2) return true; else return false; } enum e__VW { XView, YView, WView, HView, Angle, HBorder, VBorder, HSpeed, VSpeed, Object, Visible, XPort, YPort, WPort, HPort, Camera, SurfaceID }
(dock_x, dock_y, 3) && cutscene_npc_walk(1168, dock_x, dock_y, 3, "x", obj_player_npc.npc_direction) && follower_arrived == true)
192
        {
193
            manta_state = 0;
194
            move_in_direction = "none";
195
            manta_has_passengers = false;
196
            __view_set(e__VW.Object, 0, obj_pl);
197
            instance_destroy(obj_player_npc);
198
            scr_actor_into_follower
scr_actor_into_follower

function scr_actor_into_follower(arg0, arg1) { if (!instance_exists(arg0)) return false; if (arg1 == -4) return false; instance_create(arg0.x, arg0.y, arg1); arg1.x = arg0.x; arg1.y = arg0.y; with (arg0) { switch (npc_direction) { case "up": arg1.sprite_index = arg1.up_sprite_idle; break; case "down": arg1.sprite_index = arg1.down_sprite_idle; break; case "left": arg1.sprite_index = arg1.left_sprite_idle; break; case "right": arg1.sprite_index = arg1.right_sprite_idle; break; } } instance_destroy(arg0); }
(1161, 1171);
199
            scr_cutscene_end
scr_cutscene_end

function scr_cutscene_end() { global.cutscene = false; obj_pl.alarm[0] = 1; }
();
200
        }
201
        if (arrows_alpha > 0)
202
            arrows_alpha -= 0.3;
203
        break;
204
}
205
if (move_in_direction != "none" && hspeed_current == 0 && vspeed_current == 0)
206
{
207
    var can_move = false;
208
    var pl_xx = 0;
209
    var pl_yy = 0;
210
    var fl_xx = 0;
211
    var fl_yy = 0;
212
    if (can_dock == move_in_direction)
213
    {
214
        manta_state = 3;
215
        exit;
216
    }
217
    else
218
    {
219
        switch (move_in_direction)
220
        {
221
            case "right":
222
                if (right_free)
223
                {
224
                    can_move = true;
225
                }
226
                else
227
                {
228
                    can_move = false;
229
                    break;
230
                }
231
                pl_xx = x + 5;
232
                pl_yy = y - 15;
233
                fl_xx = x - 10;
234
                fl_yy = y - 15;
235
                manta_dir = 0;
236
                hspeed_current = manta_speed;
237
                sprite_index = spr_steamworks_manta_right;
238
                break;
239
            case "left":
240
                if (left_free)
241
                {
242
                    can_move = true;
243
                }
244
                else
245
                {
246
                    can_move = false;
247
                    break;
248
                }
249
                pl_xx = x - 5;
250
                pl_yy = y - 15;
251
                fl_xx = x + 10;
252
                fl_yy = y - 15;
253
                manta_dir = 180;
254
                hspeed_current = -manta_speed;
255
                sprite_index = spr_steamworks_manta_left;
256
                break;
257
            case "up":
258
                if (up_free)
259
                {
260
                    can_move = true;
261
                }
262
                else
263
                {
264
                    can_move = false;
265
                    break;
266
                }
267
                pl_xx = x;
268
                pl_yy = y - 10;
269
                fl_xx = x;
270
                fl_yy = y - 5;
271
                manta_dir = 90;
272
                vspeed_current = -manta_speed;
273
                sprite_index = spr_steamworks_manta_up;
274
                break;
275
            case "down":
276
                if (down_free)
277
                {
278
                    can_move = true;
279
                }
280
                else
281
                {
282
                    can_move = false;
283
                    break;
284
                }
285
                pl_xx = x;
286
                pl_yy = y;
287
                fl_xx = x;
288
                fl_yy = y - 10;
289
                manta_dir = 270;
290
                vspeed_current = manta_speed;
291
                sprite_index = spr_steamworks_manta_down;
292
                break;
293
        }
294
    }
295
    if (manta_has_passengers == true)
296
    {
297
        if (can_move == true)
298
        {
299
            audio_play_sound(snd_confirm, 1, 0);
300
            obj_pl.x = pl_xx;
301
            obj_pl.y = pl_yy;
302
            obj_pl.direction = manta_dir;
303
            obj_pl.depth = depth - 1;
304
            if (global.party_member != -4)
305
            {
306
                actor_follower.x = fl_xx;
307
                actor_follower.y = fl_yy;
308
                actor_follower.depth = depth - 1;
309
                if (manta_dir == 0)
310
                    actor_follower.npc_direction = "right";
311
                else if (manta_dir == 90)
312
                    actor_follower.npc_direction = "up";
313
                else if (manta_dir == 180)
314
                    actor_follower.npc_direction = "left";
315
                else if (manta_dir == 270)
316
                    actor_follower.npc_direction = "down";
317
                with (actor_follower)
318
                    event_perform(ev_step, ev_step_normal);
319
            }
320
            with (obj_pl)
321
                event_perform(ev_step, ev_step_normal);
322
            var arrow_size_multiply = 1.5;
323
            if (manta_dir == 0)
324
                arrow_size[3] = arrow_size_multiply;
325
            else if (manta_dir == 90)
326
                arrow_size[0] = arrow_size_multiply;
327
            else if (manta_dir == 180)
328
                arrow_size[2] = arrow_size_multiply;
329
            else if (manta_dir == 270)
330
                arrow_size[1] = arrow_size_multiply;
331
        }
332
        else
333
        {
334
            audio_play_sound(snd_fail, 1, 0);
335
            move_in_direction = "none";
336
            exit;
337
        }
338
    }
339
    move_in_direction = "none";
340
    manta_state = 1;
341
    audio_play_sound(snd_manta_stop_go, 1, 0);
342
}
343
if (manta_has_passengers == true)
344
{
345
    obj_pl.hspeed = hspeed_current;
346
    obj_pl.vspeed = vspeed_current;
347
    obj_pl.direction = manta_dir;
348
    if (global.party_member != -4)
349
    {
350
        actor_follower.hspeed = other.hspeed_current;
351
        actor_follower.vspeed = other.vspeed_current;
352
    }
353
}
354
hspeed = hspeed_current;
355
vspeed = vspeed_current;
356
if (hspeed_current == 0 && vspeed_current == 0)
357
{
358
    var new_sprite = -1;
359
    switch (manta_dir)
360
    {
361
        case 0:
362
            new_sprite = 1346;
363
            break;
364
        case 90:
365
            new_sprite = 1345;
366
            break;
367
        case 180:
368
            new_sprite = 1350;
369
            break;
370
        case 270:
371
            new_sprite = 1347;
372
            break;
373
    }
374
    if (sprite_index != new_sprite)
375
        sprite_index = new_sprite;
376
}
377
for (var i = 0; i < array_length_1d(arrow_size); i++)
378
{
379
    if (arrow_size[i] > 1)
380
        arrow_size[i] -= 0.05;
381
    var color_mult = (arrow_size[i] - 1) / 0.5;
382
    arrow_color[i] = make_colour_rgb(255, 255, 255 - (color_mult * 255));
383
}
384
if (manta_get_on_noloop == true && manta_state != 2)
385
    manta_get_on_noloop = false;
386
if (manta_state != 1 && audio_is_playing(snd_manta_sail))
387
    audio_stop_sound(snd_manta_sail);
388
arrows_frame += 0.25;
389
if (arrows_frame >= 5)
390
    arrows_frame = 0;
391
392
enum e__VW
393
{
394
    XView,
395
    YView,
396
    WView,
397
    HView,
398
    Angle,
399
    HBorder,
400
    VBorder,
401
    HSpeed,
402
    VSpeed,
403
    Object,
404
    Visible,
405
    XPort,
406
    YPort,
407
    WPort,
408
    HPort,
409
    Camera,
410
    SurfaceID
411
}