Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_knight_pointing_starchild_Step_0

(view raw script w/o annotations or w/e)
1
if (!init)
2
{
3
    init = true;
4
    if (difficulty >= 2)
5
    {
6
        delay = 25;
7
        with (obj_dbulletcontroller)
8
        {
9
            other.delay += delay;
10
            if (subdelay == 4)
11
            {
12
                subdelay = 0;
13
                delay += 5;
14
            }
15
            else
16
            {
17
                subdelay++;
18
                delay++;
19
            }
20
        }
21
    }
22
}
23
event_inherited();
24
if (!i_ex(obj_knight_roaring2))
25
{
26
    if (con <= 2 && con <= 3)
27
    {
28
        if (speed > minspeed)
29
            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, minspeed, deceleration);
30
        if (con == 0)
31
        {
32
            if (delay > 0)
33
            {
34
                timer++;
35
                if (timer >= delay)
36
                {
37
                    if (!
scr_onscreen_tolerance
scr_onscreen_tolerance

function
scr_onscreen_tolerance(arg0, arg1)
{ obj = arg0; spacer = arg1; if ((obj.x + obj.sprite_width + spacer) < camerax() || (obj.x - spacer) > (camerax() + 640) || (obj.y + obj.sprite_height + spacer) < cameray() || (obj.y - spacer) > (cameray() + 480)) return false; else return true; }
(self, 10))
38
                        instance_destroy();
39
                    timer = 0;
40
                    con = 1;
41
                }
42
            }
43
        }
44
    }
45
    if (con >= 1 && con <= 3)
46
    {
47
        target_angle = point_direction(x, y, obj_heart_follower.x + 10, obj_heart_follower.y + 10);
48
        if (con >= 2 && tracking)
49
        {
50
            var _difference = angle_difference(target_angle, direction);
51
            if (abs(_difference) < 90)
52
            {
53
                if (con < 3)
54
                {
55
                    direction = 
scr_rotatetowards
scr_rotatetowards

function
scr_rotatetowards(arg0, arg1, arg2)
{ var __diff = angle_difference(arg1, arg0); if (abs(__diff) > arg2) return arg0 + (sign(__diff) * arg2); else return arg1; } function scr_angle_lerp(arg0, arg1, arg2) { var __diff = angle_difference(arg1, arg0); return arg0 + lerp(0, __diff, arg2); }
(direction, target_angle, 2);
56
                    image_angle = direction;
57
                }
58
                else if (abs(_difference) <= 4)
59
                {
60
                    rotation = 0;
61
                }
62
                else if (abs(_difference) > 30)
63
                {
64
                    rotation = sign(_difference) * 2;
65
                }
66
                else
67
                {
68
                    rotation = sign(_difference);
69
                }
70
            }
71
            else if (con >= 3)
72
            {
73
                tracking = false;
74
                rotation = sign(rotation);
75
            }
76
        }
77
        else
78
        {
79
            direction += rotation;
80
            image_angle += rotation;
81
        }
82
    }
83
    if (con == 1)
84
    {
85
        image_angle = scr_angle_lerp(direction, target_angle, timer / 10);
86
        timer++;
87
        if (timer >= 10)
88
        {
89
            timer = 0;
90
            con = 2;
91
            direction = image_angle;
92
            tracking = true;
93
        }
94
        if (xscale_start == 0)
95
            xscale_start = image_xscale;
96
        if (yscale_start == 0)
97
            yscale_start = image_yscale;
98
        image_yscale = yscale_start * cos((timer / 5) * pi);
99
        image_blend = merge_color(c_white, c_black, cos((timer / 5) * pi));
100
        outline = merge_color(c_black, c_red, cos((timer / 5) * pi));
101
    }
102
    if (con == 2)
103
    {
104
        timer++;
105
        if (timer >= 10)
106
        {
107
            timer = 0;
108
            con = 3;
109
        }
110
    }
111
    if (con >= 1 && ease < 40)
112
    {
113
        var _speed = (1 - (ease / 40)) * 2;
114
        x -= lengthdir_x(_speed, target_angle);
115
        y -= lengthdir_y(_speed, target_angle);
116
        ease++;
117
    }
118
    if (con == 3)
119
    {
120
        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, 25, 0.5);
121
        image_xscale = xscale_start + (speed / 60);
122
        image_yscale = yscale_start - (speed / 90);
123
        var _afbm = 
scr_custom_afterimage
scr_custom_afterimage

function
scr_custom_afterimage(arg0)
{ afterimage = instance_create(x, y, arg0); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth + 1; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
(obj_afterimage_blend);
124
        _afbm = 
scr_custom_afterimage
scr_custom_afterimage

function
scr_custom_afterimage(arg0)
{ afterimage = instance_create(x, y, arg0); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth + 1; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
(obj_afterimage_blend);
125
        _afbm.image_blend = c_red;
126
        _afbm.fadeSpeed = 0.25;
127
        _afbm.image_alpha = 0.5;
128
        _afbm.direction = image_angle;
129
        _afbm.speed = 1;
130
    }
131
    if (con == 4)
132
    {
133
        speed = 0;
134
        timer++;
135
        if (timer >= 4)
136
            instance_destroy();
137
    }
138
}