Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_confetti_overworld_Step_0

(view raw script w/o annotations or w/e)
1
if (global.chapter == 3 && version == 1 && airborne == true)
2
    x -= 1;
3
if (preload)
4
{
5
    if (speed > 0)
6
    {
7
        preload_speed = speed;
8
        speed = 0;
9
    }
10
    exit;
11
}
12
if (!preload && preload_speed != 0)
13
{
14
    speed = preload_speed;
15
    preload_speed = 0;
16
}
17
if ((y - height) > (cameray() + 500) || x < (camerax() - 100) || x > (camerax() + 740) || (!airborne && y < (cameray() - 100)))
18
{
19
    with (shadow)
20
        instance_destroy();
21
    instance_destroy();
22
}
23
if (!init)
24
{
25
    init = true;
26
    if (i_ex(shadow))
27
        shadow.depth = maxDepth + 1;
28
}
29
falltime++;
30
if (!airborne)
31
{
32
    if (!destroyOnLand)
33
        exit;
34
    if (lifetime > 0)
35
    {
36
        lifetime--;
37
        exit;
38
    }
39
    siner -= 0.1;
40
    image_alpha = min(siner, 1);
41
    if (siner <= 0)
42
        instance_destroy();
43
    exit;
44
}
45
if (version == 1)
46
{
47
    if (fallspeed < 0)
48
        fallspeed += fallFriction;
49
    if (fallspeed > -5)
50
        fallFriction = 0.8;
51
    if (speed < 5)
52
        friction = 0.4;
53
    if (fallspeed < 10)
54
        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, 10, 0.15);
55
}
56
else
57
{
58
    if (fallspeed < 0)
59
        fallspeed += fallFriction;
60
    if (fallspeed > -5)
61
        fallFriction = 0.4;
62
    if (speed < 5)
63
        friction = 0.4;
64
    if (fallspeed < 2)
65
        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, 2, 0.1);
66
}
67
height -= fallspeed;
68
var _over_gap = false;
69
if (airborne && (topdrop != 0 || bottomdrop != 0))
70
{
71
    var _minyy = miny;
72
    if (topdrop == 2 && y < (miny + 20))
73
        _minyy += ((1 - cos(abs(x - 320) / 320)) * 40);
74
    if (y < _minyy && topdrop >= 1)
75
        y = _minyy;
76
    else if (y > maxy && bottomdrop == 1)
77
        y = maxy;
78
    else if (y < _minyy && topdrop == -1)
79
        _over_gap = true;
80
    else if (y > maxy && bottomdrop == -1)
81
        _over_gap = true;
82
}
83
var landingheight = 0;
84
if (version == 1)
85
    landingheight = -64;
86
if (airborne && height <= landingheight && !_over_gap && fallspeed >= 0)
87
{
88
    instance_destroy(shadow);
89
    fallspeed = 0;
90
    height = landingheight;
91
    airborne = false;
92
    image_index = (image_index < 4) ? 3 : 7;
93
    speed = 0;
94
    image_speed = 0;
95
    x += sin(siner / 15);
96
    if (version == 0)
97
    {
98
        if (collision_rectangle(x - (sprite_width / 2), y - (sprite_height / 2), x + (sprite_width / 2), y + (sprite_height / 2), obj_confetti_overworld, false, true) != -4)
99
        {
100
            var _list = ds_list_create();
101
            var _count = collision_rectangle_list(x - (sprite_width / 2), y - (sprite_height / 2), x + (sprite_width / 2), y + (sprite_height / 2), obj_confetti_overworld, false, true, _list, false);
102
            depth = maxDepth - _count;
103
            ds_list_destroy(_list);
104
        }
105
        else
106
        {
107
            depth = maxDepth;
108
        }
109
    }
110
    siner = 3;
111
    exit;
112
}
113
x += (sin(siner / 15) * (fallspeed / 2));
114
siner++;
115
image_speed = 1 + (speed / 15);
116
var _midy = (miny + maxy) / 2;
117
if (height < 0 && y < _midy)
118
    scr_depth_relative(maxDepth, _midy);
119
else
120
    
scr_depth_ext
scr_depth_ext

function
scr_depth_ext(arg0 = 100000, arg1 = 10)
{ depth = arg0 - ((y * arg1) + (sprite_height * arg1)); } function scr_depth_ext_alt(arg0 = 100000, arg1 = 10) { depth = arg0 - ((y * arg1) + ((sprite_height - sprite_yoffset) * arg1)); } function scr_depth_relative(arg0 = 100000, arg1 = 0, arg2 = 10) { var __yy = (y + sprite_height) - arg1; depth = arg0 - (__yy * arg2); }
(start_depth);
121
if (i_ex(shadow))
122
{
123
    shadow.image_alpha = (y > !_over_gap) ? 0 : 1;
124
    shadow.image_index = image_index;
125
    shadow.x = x + ((sprite_width - shadow.sprite_width) / 2);
126
    shadow.y = y + ((sprite_height - shadow.sprite_height) / 2);
127
    var shadowScale = clamp((40 - (height / 2)) / 20, 0, 2);
128
    shadow.image_xscale = shadowScale;
129
    shadow.image_yscale = shadowScale;
130
}
131
if (version == 1)
132
{
133
    if (i_ex(obj_rouxls_ch3_enemy))
134
        depth = obj_rouxls_ch3_enemy.depth - 1;
135
}