Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_battle_enemy_attack_guardener_attack_6_Step_0

(view raw script w/o annotations or w/e)
1
if live_call()
2
    return global.live_result;
3
var box = obj_dialogue_box_battle_transformation_any
4
switch scene
5
{
6
    case 0:
7
        if (obj_guardener_guy_a.active == false && obj_guardener_guy_a.is_on_target && obj_guardener_guy_b.is_on_target)
8
        {
9
            instance_create(-40, box.y, obj_guardener_guy_b_shield)
10
            instance_create((room_width + 40), box.y, obj_guardener_guy_a_flintlock)
11
            cutscene_advance()
12
        }
13
        obj_guardener_guy_a.active = false
14
        obj_guardener_guy_b.active = false
15
        break
16
    case 1:
17
    case 3:
18
        var adv = 2
19
        with (obj_guardener_guy_a_flintlock)
20
        {
21
            var x_target = box.bbox_right + 80
22
            x = lerp(x, x_target, 0.2)
23
            y = lerp(y, box.y, 0.2)
24
            if (((abs(x + y)) - (abs(x_target + box.y))) < 1)
25
                adv -= 1
26
        }
27
        with (obj_guardener_guy_b_shield)
28
        {
29
            x_target = box.bbox_left - 40
30
            x = lerp(x, x_target, 0.2)
31
            y = lerp(y, box.y, 0.2)
32
            if (((abs(x + y)) - (abs(x_target + box.y))) < 1)
33
                adv -= 1
34
        }
35
        if (adv <= 0)
36
            cutscene_advance()
37
        break
38
    case 2:
39
        var lerp_amount_new = 0.1
40
        if (obj_guardener_guy_a_flintlock.sprite_index != spr_guardener_guy_b_flintlock_shoot)
41
        {
42
            lerp_amount_new = 0.01
43
            lerp_amount = lerp_amount_new
44
        }
45
        lerp_amount = 0.1
46
        obj_guardener_guy_a_flintlock.y = lerp(obj_guardener_guy_a_flintlock.y, (obj_heart_battle_fighting_red.y + 30), lerp_amount)
47
        if (shoot_timer > 0)
48
            shoot_timer -= 1
49
        else
50
        {
51
            with (obj_guardener_guy_a_flintlock)
52
            {
53
                audio_play_sound(snd_guardener_flintlock, 1, 0)
54
                sprite_index = spr_guardener_guy_b_flintlock_shoot
55
                image_index = 0
56
                instance_create_depth((x - 40), (y - 30), (obj_heart_battle_fighting_parent.depth - 1), obj_battle_enemy_attack_guardener_bullet)
57
            }
58
            shoot_timer = shoot_timer_max
59
            shoot_count -= 1
60
            if (shoot_count == 0)
61
                cutscene_advance()
62
        }
63
        break
64
    case 4:
65
        obj_guardener_guy_a_flintlock.sprite_index = spr_guardener_guy_b_flintlock
66
        cutscene_wait(1)
67
        break
68
    case 5:
69
        adv = 2
70
        with (obj_guardener_guy_a_flintlock)
71
        {
72
            x_target = 720
73
            x = lerp(x, x_target, 0.2)
74
            if (x > (x_target - 40))
75
                adv -= 1
76
        }
77
        with (obj_guardener_guy_b_shield)
78
        {
79
            x_target = -40
80
            x = lerp(x, x_target, 0.2)
81
            if (x < (x_target + 20))
82
                adv -= 1
83
        }
84
        if (adv <= 0)
85
            cutscene_advance()
86
        break
87
    case 6:
88
        obj_guardener_guy_a.active = true
89
        obj_guardener_guy_b.active = true
90
        instance_destroy()
91
        break
92
}
93
94
if instance_exists(obj_guardener_guy_b_shield)
95
{
96
    var current_ball = instance_find(obj_battle_enemy_attack_guardener_bullet, 0)
97
    if instance_exists(obj_battle_enemy_attack_guardener_bullet)
98
        obj_guardener_guy_b_shield.y = lerp(obj_guardener_guy_b_shield.y, (current_ball.y + 20), 0.4)
99
}
100
with (obj_guardener_guy_a_flintlock)
101
{
102
    if (image_index >= (image_number - 1))
103
    {
104
        switch sprite_index
105
        {
106
            case spr_guardener_guy_b_flintlock_reload:
107
                sprite_index = spr_guardener_guy_b_flintlock
108
                image_index = 0
109
                break
110
            case 3628:
111
                sprite_index = spr_guardener_guy_b_flintlock_reload
112
                image_index = 0
113
                break
114
        }
115
116
    }
117
}
118
with (obj_battle_enemy_attack_guardener_bullet)
119
{
120
    if (x < (obj_guardener_guy_b_shield.x + 40))
121
    {
122
        var max_shards = 3
123
        var shard_spread = 45
124
        for (var i = 0; i < max_shards; i++)
125
        {
126
            var shard = instance_create_depth(x, y, (obj_heart_battle_fighting_parent.depth - 1), obj_battle_enemy_attack_guardener_bullet_shard)
127
            shard.speed = 4
128
            shard.direction = -45 + i * shard_spread
129
        }
130
        audio_play_sound(snd_guardener_flintlock_shield, 1, 0)
131
        instance_destroy()
132
    }
133
}