Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_battle_enemy_attack_macro_knight_Step_0

(view raw script w/o annotations or w/e)
1
if live_call()
2
    return global.live_result;
3
var soul = obj_heart_battle_fighting_red
4
switch state
5
{
6
    case "idle":
7
        sprite_index = spr_bigfrog_knight_idle
8
        image_speed = 1
9
        state_timer -= 1
10
        if (state_timer <= 0)
11
        {
12
            self.state_switch("run")
13
            if (soul.y >= bbox_top)
14
            {
15
                if (irandom(3) == 1)
16
                    self.state_switch("attack")
17
            }
18
        }
19
        break
20
    case "run":
21
        if (sprite_index != spr_bigfrog_knight_start_run && sprite_index != spr_bigfrog_knight_run)
22
        {
23
            sprite_index = spr_bigfrog_knight_start_run
24
            image_index = 0
25
            image_speed = 1
26
            run_switch_count = irandom_range(1, 2)
27
        }
28
        hsp = lerp(hsp, hsp_max, 0.25)
29
        var jump_chance = 5
30
        if (run_switch_count <= 0 && abs(x - soul.x) < 60)
31
        {
32
            self.state_switch("jump")
33
            if (soul.y >= bbox_top)
34
            {
35
                if (irandom(2) == 1)
36
                    self.state_switch("attack")
37
            }
38
        }
39
        break
40
    case "jump":
41
        if (sprite_index != spr_bigfrog_knight_air_slash)
42
        {
43
            sprite_index = spr_bigfrog_knight_air_slash
44
            image_index = 0
45
            image_speed = 1
46
        }
47
        else if (image_index == 1 && floored == true)
48
        {
49
            floored = false
50
            vsp = -8
51
        }
52
        else if (image_index >= (image_number - 1))
53
        {
54
            image_index = image_number - 1
55
            image_speed = 0
56
            if (floored == true)
57
            {
58
                self.state_switch("idle")
59
                if (soul.y >= bbox_top)
60
                {
61
                    if (irandom(5) == 1)
62
                        self.state_switch("attack")
63
                }
64
            }
65
        }
66
        if (hsp_max > 0)
67
        {
68
            if (hsp > 0)
69
                hsp -= 0.3
70
            else
71
                hsp = 0
72
        }
73
        else if (hsp < 0)
74
            hsp += 0.3
75
        else
76
            hsp = 0
77
        break
78
    case "attack":
79
        if (sprite_index != spr_bigfrog_knight_slash && sprite_index != spr_bigfrog_knight_slash_reset)
80
        {
81
            sprite_index = spr_bigfrog_knight_slash
82
            image_index = 0
83
            image_speed = 1
84
            hsp = 7
85
            hsp_max = abs(hsp_max)
86
            if (soul.x < x)
87
            {
88
                hsp = -7
89
                hsp_max = (-abs(hsp_max))
90
            }
91
        }
92
        else if (image_index >= (image_number - 1))
93
        {
94
            if (sprite_index != spr_bigfrog_knight_slash_reset)
95
            {
96
                sprite_index = spr_bigfrog_knight_slash_reset
97
                image_index = 0
98
                image_speed = 1
99
            }
100
            else
101
                self.state_switch("run")
102
        }
103
        if (hsp_max > 0)
104
        {
105
            if (hsp > 0)
106
                hsp -= 0.15
107
            else
108
                hsp = 0
109
        }
110
        else if (hsp < 0)
111
            hsp += 0.15
112
        else
113
            hsp = 0
114
        break
115
    case "cast":
116
        if (sprite_index != spr_bigfrog_knight_slash && sprite_index != spr_bigfrog_knight_slash_reset)
117
        {
118
            sprite_index = spr_bigfrog_knight_slash
119
            image_index = 0
120
            image_speed = 1
121
            can_cast = true
122
        }
123
        else if (image_index >= 1 && can_cast)
124
        {
125
            for (var i = 0; i < 3; i++)
126
            {
127
                var bullet = instance_create_depth(x, y, (depth + 1), obj_battle_enemy_attack_macro_knight_bullet)
128
                if (hsp_max > 0)
129
                    bullet.direction = i * 30
130
                else
131
                    bullet.direction = 180 - i * 30
132
                bullet.speed = 11
133
            }
134
            can_cast = false
135
        }
136
        else if (image_index >= (image_number - 1))
137
        {
138
            if (sprite_index != spr_bigfrog_knight_slash_reset)
139
            {
140
                sprite_index = spr_bigfrog_knight_slash_reset
141
                image_index = 0
142
                image_speed = 1
143
            }
144
            else
145
                self.state_switch("run")
146
        }
147
        break
148
    case "victory":
149
        hsp = 0
150
        if (sprite_index != spr_bigfrog_knight_victory)
151
        {
152
            sprite_index = spr_bigfrog_knight_victory
153
            image_index = 0
154
            image_speed = 1
155
        }
156
        else if (image_index >= (image_number - 1))
157
        {
158
            instance_destroy()
159
            instance_destroy(obj_battle_enemy_attack_macro_sword_frog_creator)
160
            return;
161
        }
162
        break
163
}
164
165
x += hsp
166
vsp += grav
167
if ((y + vsp) >= (battle_box.bbox_bottom - 4))
168
{
169
    while ((y + sign(vsp)) < (battle_box.bbox_bottom - 4))
170
        y += sign(vsp)
171
    vsp = 0
172
    floored = true
173
}
174
y += vsp
175
function state_switch_gml_Object_obj_battle_enemy_attack_macro_knight_Step_0(argument0) //gml_Script_state_switch_gml_Object_obj_battle_enemy_attack_macro_knight_Step_0
176
{
177
    state = argument0
178
    state_timer = 15
179
    if (attack_timer <= 0)
180
        state = "victory"
181
}
182
183
if ((x + hsp * 3) >= (battle_box.bbox_right - 4) || (x + hsp * 3) <= (battle_box.bbox_left + 4))
184
{
185
    hsp = 0
186
    hsp_max *= -1
187
    run_switch_count -= 1
188
    if (state == "run" && irandom(3) == 1)
189
        state_switch("cast")
190
}
191
if (hsp_max > 0)
192
    image_xscale = -1
193
else if (hsp_max < 0)
194
    image_xscale = 1
195
attack_timer--