Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_roaringknight_quickslash_attack_Step_0

(view raw script w/o annotations or w/e)
1
local_turntimer--;
2
if (!auto)
3
    exit;
4
if (knight == -4)
5
    knight = 344;
6
if (local_turntimer <= 50)
7
{
8
    if (local_turntimer <= 10 && sprite_index != spr_roaringknight_idle)
9
    {
10
        if (image_xscale < 0)
11
            x -= 220;
12
        image_xscale = abs(image_xscale);
13
        sprite_index = spr_roaringknight_idle;
14
        image_index = 0;
15
    }
16
    else if (local_turntimer < 42 && image_xscale < 0)
17
    {
18
        image_index = 4;
19
    }
20
    if (x < obj_knight_enemy.x)
21
        x++;
22
    var _local_turntimer = local_turntimer;
23
    if (_local_turntimer < 0)
24
        _local_turntimer = 0;
25
    y = lerp(y, knight.y, (50 - _local_turntimer) / 50);
26
    if ((local_turntimer < -60 && turn_type != "short end") || (local_turntimer < -110 && turn_type == "short end"))
27
    {
28
        global.turntimer = 0;
29
        instance_destroy();
30
        exit;
31
    }
32
}
33
else if (recoil != 0)
34
{
35
    x += recoil;
36
    recoil = 
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); } }
(recoil, 0.25 * sign(recoil), 0.5);
37
}
38
if ((local_turntimer < 120 || (local_turntimer < 150 && next_up == 4)) && slash_count < 999 && (slash_count % 2) == 0 && !done)
39
{
40
    slash_count = 999;
41
    if (turn_type == "start" || turn_type == "short start" || turn_type == "short mid")
42
    {
43
        done = true;
44
        local_turntimer = 99999;
45
        slash_count = 1000;
46
        var new_knight = -4;
47
        switch (next_up)
48
        {
49
            case 5:
50
                new_knight = 1174;
51
                slash_count = 993;
52
                break;
53
            case 4:
54
                new_knight = 631;
55
                slash_count = 993;
56
                break;
57
            case 3:
58
                new_knight = 803;
59
                slash_count = 999;
60
                break;
61
            case 2:
62
                new_knight = 670;
63
                slash_count = 999;
64
                break;
65
        }
66
        next_up = -999;
67
        var knight_stream = instance_create(obj_knight_enemy.x - 100, obj_knight_enemy.y - 88, new_knight);
68
        
scr_bullet_inherit
scr_bullet_inherit

function
scr_bullet_inherit(arg0)
{ if (i_ex(arg0)) { if (damage != -1) arg0.damage = damage; if (grazepoints != -1) arg0.grazepoints = grazepoints; if (timepoints != -1) arg0.timepoints = timepoints; if (inv != -1) arg0.inv = inv; if (target != -1) arg0.target = target; if (grazed != -1) arg0.grazed = 0; if (grazetimer != -1) arg0.grazetimer = 0; if (object_index == obj_dbulletcontroller) { arg0.creatorid = creatorid; arg0.creator = creator; } arg0.element = element; } }
(knight_stream);
69
        knight_stream.creatorid = creatorid;
70
        knight_stream.creator = creator;
71
        with (knight_stream)
72
        {
73
            if (new_knight == 631)
74
                x -= 50;
75
            else if (new_knight == 803)
76
                x += 25;
77
            else
78
                x += 50;
79
            y -= 44;
80
            turn_type = "end";
81
            if (new_knight != 1174)
82
            {
83
                with (instance_create_depth(x, y, depth, obj_knight_warp))
84
                {
85
                    master = other.id;
86
                    event_user(0);
87
                }
88
            }
89
            if (other.turn_segment == 0)
90
            {
91
                turn_type = "short mid";
92
                turn_segment = 1;
93
                next_up = other.next_next_up;
94
            }
95
            if (other.turn_segment == 1)
96
            {
97
                turn_type = "short end";
98
                turn_segment = 2;
99
                if (next_up == 4)
100
                    slash_count -= 4;
101
            }
102
            anchor_x = other.anchor_x;
103
            anchor_y = other.anchor_y;
104
            event_user(0);
105
            if (new_knight == 670)
106
                knight_stream.timer = 4;
107
            if (new_knight == 1174)
108
            {
109
                new_knight.alarm[0] = 1;
110
                new_knight.init_start = 3;
111
                new_knight.init = 4;
112
            }
113
        }
114
        exit;
115
    }
116
    slash_anim_count = 999;
117
    timer = -2;
118
}
119
if (slash_count > 999)
120
    exit;
121
if (slash_count == 999 && done)
122
    exit;
123
timer++;
124
if (timer >= spawn_speed)
125
{
126
    if (spawn_speed > 2)
127
        spawn_speed -= 2;
128
    slash_count++;
129
    timer = 0;
130
    if (slash_count == 1000)
131
    {
132
        instance_create(obj_growtangle.x + 33, obj_growtangle.y, obj_roaringknight_quickslash_big);
133
    }
134
    else
135
    {
136
        event_user(3);
137
        if (slash_count == 999)
138
            spawn_speed = 10;
139
    }
140
    spawn_range = 
scr_approach
scr_approach

function
scr_approach(arg0, arg1, arg2)
{ if (arg0 < arg1) { arg0 += arg2; if (arg0 > arg1) return arg1; } else { arg0 -= arg2; if (arg0 < arg1) return arg1; } return arg0; }
(spawn_range, 60, 3);
141
}