Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_chefs_kris_Step_0

(view raw script w/o annotations or w/e)
1
if (!obj_chefs_game.gamestart)
2
    exit;
3
t++;
4
if (i_ex(obj_chefs_game))
5
    pointsprev = obj_chefs_game.scorepoints;
6
if (firewait > 0)
7
{
8
    firewait--;
9
    if (firewait <= 0)
10
        invincible = 60;
11
}
12
if (invincible > 0)
13
{
14
    invincible--;
15
    if (image_alpha == 0.3)
16
        image_alpha = 1;
17
    else
18
        image_alpha = 0.3;
19
}
20
else
21
{
22
    image_alpha = 1;
23
}
24
var _x = clamp(x, xstart - 128, xstart + 128);
25
if (x != _x)
26
{
27
    x = _x;
28
    hspeed = 0;
29
}
30
if (obj_chefs_game.gameover)
31
{
32
    image_speed = 0;
33
    gravity = 0;
34
    speed = 0;
35
    y = yprevious;
36
    x = xprevious;
37
    image_alpha = 1;
38
    exit;
39
}
40
var _h = 0;
41
var _cap = max(4, stack_height) + 3;
42
if (jumping == 0)
43
{
44
    if (left_h())
45
        _h = -1;
46
    if (right_h())
47
        _h = 1;
48
    if (throwing || firewait > 0 || stun > 0)
49
        _h = 0;
50
    var _maxspd = 8;
51
    var _spd = _h * ((_cap - stack_height) / _cap) * _maxspd;
52
    var _acc = (((_cap - stack_height) / _cap) * (_maxspd / 3)) + (_maxspd / 3);
53
    hspeed = clamp_gradual(hspeed, _spd, _spd, _acc);
54
    if (!throwing)
55
    {
56
        if (round(hspeed) == 0)
57
        {
58
            sprite_index = spr_kris_chef;
59
        }
60
        else
61
        {
62
            image_speed = _h * ((_cap - stack_height) / _cap);
63
            sprite_index = spr_kris_chef_walk;
64
        }
65
    }
66
    if ((button2_p() || (i_ex(obj_tenna_enemy) && button1_p())) && !throwing && !(firewait > 0 || stun > 0))
67
    {
68
        jumping = 1;
69
        jumphspeed = hspeed;
70
        hspeed = 0;
71
        jumpwait = 1 + stack_height;
72
    }
73
}
74
if (jumping == 1)
75
{
76
    jumpwait--;
77
    if (!throwing)
78
        sprite_index = spr_kris_chef_squat;
79
    if (jumpwait <= 0)
80
    {
81
        hspeed = jumphspeed;
82
        snd_play(snd_jump);
83
        gravity_direction = 270;
84
        gravity = 1;
85
        vspeed = -12 + ((stack_height / _cap) * 5);
86
        hspeed = clamp(hspeed, -4, 4);
87
        jumping = 2;
88
        jump_spinspd = 0.5 + (0.5 * ((10 - min(stack_height, 10)) / 10));
89
        if (hspeed != 0)
90
            jump_spinspd *= sign(hspeed);
91
    }
92
}
93
if (jumping == 2 && !throwing)
94
{
95
    image_speed = jump_spinspd;
96
    sprite_index = spr_krisb_pirouette_plate;
97
}
98
if ((jumping == 2 || stun > 0) && y >= (ystart - abs(vspeed)) && vspeed > 0)
99
{
100
    jumping = false;
101
    gravity = 0;
102
    y = ystart;
103
    vspeed = 0;
104
}
105
if (stun > 0)
106
{
107
    stun--;
108
    image_speed = 0;
109
    sprite_index = spr_chefs_kris_stun;
110
    if (y < ystart)
111
    {
112
        image_index = 0;
113
    }
114
    else
115
    {
116
        y = ystart;
117
        image_index = 1;
118
        vspeed = 0;
119
    }
120
}
121
if (throwing == 0 && button1_p() && !i_ex(obj_tenna_enemy) && obj_chefs_game.microgame != 1)
122
    throw_food();
123
if (throwing == 1)
124
{
125
    throwwait--;
126
    if (throwwait <= 0)
127
    {
128
        if (stack_height > 0)
129
        {
130
            var _stack = instance_create(x, food[0].y, obj_chefs_stackbox);
131
            _stack.vspeed = 20;
132
            _stack.stack_height = stack_height;
133
            snd_play_pitch(snd_wing, 0.8);
134
            repeat (stack_height)
135
            {
136
                with (food[stack_height - 1])
137
                {
138
                    if (i_ex(obj_chefs_firewhip))
139
                        depth = -999999;
140
                    thrown = true;
141
                    vspeed = 20;
142
                    if (other.pos == 0)
143
                        x = other.x;
144
                    _stack.food[other.stack_height - 1] = id;
145
                    fixate = _stack;
146
                    fixate_y = y - _stack.y;
147
                }
148
                array_delete(food, stack_height - 1, 1);
149
                stack_height--;
150
            }
151
            var _scale = clamp(_stack.stack_height, 1, 5) / 5;
152
            _stack.image_yscale = _scale;
153
        }
154
        throwing = 2;
155
        image_index = 1;
156
        image_speed = 1;
157
    }
158
}