Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_knight_roaring_star_Step_0

(view raw script w/o annotations or w/e)
1
if (x < (camerax() - sprite_width) || x > (camerax() + camerawidth() + sprite_width) || y < (cameray() - sprite_height) || y > (cameray() + 480 + sprite_height))
2
{
3
    if (outbound)
4
    {
5
        instance_destroy();
6
        exit;
7
    }
8
}
9
else
10
{
11
    outbound = true;
12
}
13
if (con == 1)
14
{
15
    friction = 0.5;
16
    con++;
17
}
18
else if (con == 2)
19
{
20
    if (speed == 0 && gravity == 0)
21
    {
22
        gravity = 0.1;
23
        gravity_direction = direction - 180;
24
        friction = 0;
25
        if (split)
26
        {
27
            var _finaltime = 54 - timer;
28
            var _len = 0.5 * gravity * sqr(_finaltime);
29
            var _subfinalx = screenx() + lengthdir_x(_len, gravity_direction);
30
            var _subfinaly = screeny() + lengthdir_y(_len, gravity_direction);
31
            finalx = _subfinalx - (_subfinaly / 2);
32
        }
33
    }
34
    timer++;
35
    if (timer >= 40 && !split)
36
    {
37
        timer = 0;
38
        con++;
39
        if (playSound)
40
            snd_play(snd_explosion_firework);
41
    }
42
    growstart = image_xscale;
43
}
44
else if (con == 2.5)
45
{
46
    if (split == 1)
47
    {
48
        speed = 0;
49
        gravity = 0;
50
        sprite_index = spr_knight_bullet_star_top;
51
        timer = -10;
52
        split = 2;
53
    }
54
    timer++;
55
    splitease = 
scr_ease_out
scr_ease_out

function
scr_ease_out(arg0, arg1)
{ if (arg1 < -3 || arg1 > 7) return arg0; switch (arg1) { case -3: return ease_out_bounce(arg0, 0, 1, 1); case -2: return ease_out_elastic(arg0, 0, 1, 1); case -1: return ease_out_back(arg0, 0, 1, 1); case 0: return arg0; case 1: return sin(arg0 * 1.5707963267948966); case 2: return -arg0 * (arg0 - 2); case 6: return -power(2, -10 * arg0) + 1; case 7: arg0--; return sqrt(1 - (arg0 * arg0)); default: arg0--; if (arg1 == 4) { return -1 * (power(arg0, arg1) - 1); break; } return power(arg0, arg1) + 1; } }
(clamp01(timer / 20), 4) * splitmax * image_xscale;
56
    if (timer == 20)
57
    {
58
        con = 3;
59
        timer = 0;
60
    }
61
}
62
else if (con == 3)
63
{
64
    timer++;
65
    image_xscale = growstart + clamp01(timer / 2);
66
    image_yscale = growstart + clamp01(timer / 2);
67
    if (timer == 3)
68
    {
69
        var _angle = 90;
70
        for (i = 0; i < 6; i++)
71
        {
72
            var _xx = x;
73
            var _yy = y;
74
            if (split > 0)
75
            {
76
                if (i == 0 || i >= 4)
77
                {
78
                    _xx += ((splitmax * image_xscale) / 2);
79
                    _yy += (splitmax * image_xscale);
80
                }
81
                else
82
                {
83
                    _xx -= ((splitmax * image_xscale) / 2);
84
                    _yy -= (splitmax * image_xscale);
85
                }
86
            }
87
            d = 
scr_childbullet
scr_childbullet

function
scr_childbullet()
{ var __child = instance_create(argument[0], argument[1], argument[2]); var __parent = (argument_count == 4) ? argument[3] : id; if (__parent.damage != -1) __child.damage = __parent.damage; if (__parent.grazepoints != -1) __child.grazepoints = __parent.grazepoints; if (__parent.timepoints != -1) __child.timepoints = __parent.timepoints; if (__parent.inv != -1) __child.inv = __parent.inv; if (__parent.target != -1) __child.target = __parent.target; if (__parent.grazed != -1) __child.grazed = __parent.grazed; if (__parent.grazetimer != -1) __child.grazetimer = __parent.grazetimer; __child.element = __parent.element; return __child; }
(x, y, obj_knight_pointing_starchild);
88
            d.image_angle = _angle;
89
            d.direction = _angle;
90
            d.speed = 1;
91
            d.friction = -0.1;
92
            d.image_xscale = image_xscale * 0.5;
93
            d.image_yscale = image_yscale * 0.5;
94
            d.deceleration = 0.15;
95
            if (i == 1 || i == 4)
96
                _angle += 57;
97
            else
98
                _angle += 66;
99
        }
100
    }
101
    if (timer >= 4)
102
    {
103
        image_xscale = (sprite_width + 16) / sprite_get_width(sprite_index);
104
        image_yscale = (sprite_height + 16) / sprite_get_height(sprite_index);
105
        var _aimage = 
scr_afterimage
scr_afterimage

function
scr_afterimage()
{ afterimage = instance_create(x, y, obj_afterimage); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
();
106
        _aimage.fadeSpeed *= 3;
107
        instance_destroy();
108
    }
109
}