Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_plat_enm_book_simple_Step_0

related scripts: Alarm_0Collision_obj_plat_playerCreate_0Destroy_0Step_0

(view raw script w/o annotations or w/e)
1
if (!instance_exists(obj_plat_player))
2
{
3
    
scr_flower_despwn
scr_flower_despwn

function
scr_flower_despwn(arg0 = 0)
{ arg0 = 0; hit = 0; with (instance_create_depth(x, y, depth, obj_plat_vfx)) { sprite_index = spr_smokepuff; image_speed = 2; } with (instance_create_depth(x, y, 2450, obj_flower_despwn, { image_blend: petal_color })) colored = true; var _spawner = instance_create_depth(x_home, y_home, 2450, obj_flower_spawner, { image_blend: petal_color }); _spawner._memory = {}; _spawner.image_xscale = image_xscale; _spawner.scale = sign(image_xscale); _spawner.was_onscreen = true; _spawner.colored = true; _spawner.image_yscale = image_yscale; _spawner.image_angle = image_angle; _spawner.obj_index = object_index; _spawner.activate = activate; _spawner.enemy_wave = enemy_wave; var array = __vars; for (var i = 0; i < array_length(array); i++) variable_struct_set(_spawner._memory, array[i], variable_instance_get(id, array[i])); with (_spawner) { obj_index = other.object_index; hp = other.hp; } if (arg0 == 0) { instance_destroy(); } else { } exit; }
();
4
    exit;
5
}
6
if (global.pause_plat)
7
    exit;
8
onscreen = 
scr_onscreen
scr_onscreen

function
scr_onscreen(arg0)
{ __obj = arg0; var __cx = camera_get_view_x(view_camera[0]); var __cy = camera_get_view_y(view_camera[0]); if ((__obj.x + __obj.sprite_width) < __cx || __obj.x > (__cx + 640) || (__obj.y + __obj.sprite_height) < __cy || __obj.y > (__cy + 480)) return false; else return true; }
(id);
9
if (onscreen && state == 0)
10
{
11
    state = 1;
12
    vspeed = -6;
13
    sprite_index = spr_enemy_book_simple_freefall;
14
    image_speed = 0.5;
15
}
16
if (state == 1)
17
{
18
    vspeed += 0.25;
19
    scr_plat_depthcast();
20
    if (vspeed > -2)
21
        state = 2;
22
}
23
if (state == 2)
24
{
25
    var _yoff = sin(timer / 20) * 2;
26
    var _p = 910;
27
    if (instance_exists(_p))
28
        aim = point_direction(x, y, _p.x, _p.y - 5);
29
    var _dir = aim;
30
    timer++;
31
    direction = _dir;
32
    image_xscale = sign(-lengthdir_x(1, aim)) * 2;
33
    if (lengthdir_y(1, aim) > 0.5)
34
    {
35
        image_index = (timer / 2) % 2;
36
        sprite_index = spr_enemy_book_simple_freefall;
37
        speed = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(speed, 7, 0.4);
38
    }
39
    else
40
    {
41
        y += _yoff;
42
        image_speed = 0.5;
43
        sprite_index = spr_enemy_book_simple;
44
        speed = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(speed, onscreen ? 3 : 7, 0.4);
45
    }
46
    if (point_distance(0, 0, (x - _p.x) * 0.75, y - _p.y) <= 200)
47
        state_set(3);
48
}
49
if (state == 3)
50
{
51
    var _p = 910;
52
    if (instance_exists(_p))
53
    {
54
        aim = point_direction(x, y, _p.x, _p.y - 15) + random_range(-10, 10);
55
        dist = point_distance(x, y, _p.x, _p.y - 15);
56
    }
57
    var _dir = aim;
58
    sprite_index = spr_enemy_book_simple_freefall;
59
    if (timer >= 16)
60
    {
61
        image_index = 2;
62
    }
63
    else
64
    {
65
        image_speed = fallspeed / 8;
66
        if (image_index >= 2)
67
            image_index -= 2;
68
    }
69
    fallspeed = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(fallspeed, 4, 0.2);
70
    y += fallspeed;
71
    if (timer != 16 || lengthdir_y(1, aim) <= 0)
72
        timer++;
73
    if (dist > 200)
74
        timer += 3;
75
    if (timer < 20)
76
        speed *= 0.8;
77
    if (timer == 16)
78
    {
79
        var _this = id;
80
        with (obj_plat_enm_book_simple)
81
        {
82
            if (state == 3 && timer >= 12 && timer < 16)
83
                timer = 12;
84
        }
85
    }
86
    if (timer >= 20)
87
    {
88
        state_set(4);
89
        image_speed = 0;
90
        var _xdir = lengthdir_x(1, aim);
91
        if (_xdir > 0)
92
            image_xscale = -abs(image_xscale);
93
        else if (_xdir < 0)
94
            image_xscale = abs(image_xscale);
95
        sprite_index = spr_enemy_book_simple;
96
        flash_hurt(16777215);
97
        snd_play(snd_wing, 0.6, 1.3);
98
    }
99
}
100
if (state == 4)
101
{
102
    var _dir = aim;
103
    var _duration = 40;
104
    var _prog = timer / _duration;
105
    if (substate == 0)
106
    {
107
        speed += 1.5;
108
        image_index = clamp01(speed / 6) * 2;
109
        if (speed >= 15)
110
            substate = 1;
111
    }
112
    else if (substate == 1)
113
    {
114
        speed -= 0.75;
115
        if (speed <= 0)
116
        {
117
            speed = 0;
118
            state_set(2);
119
            fallspeed = 1;
120
        }
121
        else if (speed < 4)
122
        {
123
            image_index = 0;
124
        }
125
        else if (speed < 8)
126
        {
127
            image_index = 3;
128
        }
129
    }
130
    y++;
131
    direction = _dir;
132
}
133
if (state == 10)
134
{
135
}