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 = 3154;
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
            var 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
        {
49
            shoot_timer -= 1;
50
        }
51
        else
52
        {
53
            with (obj_guardener_guy_a_flintlock)
54
            {
55
                audio_play_sound(snd_guardener_flintlock, 1, 0);
56
                sprite_index = spr_guardener_guy_b_flintlock_shoot;
57
                image_index = 0;
58
                instance_create_depth(x - 40, y - 30, obj_heart_battle_fighting_parent.depth - 1, obj_battle_enemy_attack_guardener_bullet);
59
            }
60
            shoot_timer = shoot_timer_max;
61
            shoot_count -= 1;
62
            if (shoot_count == 0)
63
                cutscene_advance();
64
        }
65
        break;
66
    case 4:
67
        obj_guardener_guy_a_flintlock.sprite_index = spr_guardener_guy_b_flintlock;
68
        cutscene_wait(1);
69
        break;
70
    case 5:
71
        var adv = 2;
72
        with (obj_guardener_guy_a_flintlock)
73
        {
74
            var x_target = 720;
75
            x = lerp(x, x_target, 0.2);
76
            if (x > (x_target - 40))
77
                adv -= 1;
78
        }
79
        with (obj_guardener_guy_b_shield)
80
        {
81
            var x_target = -40;
82
            x = lerp(x, x_target, 0.2);
83
            if (x < (x_target + 20))
84
                adv -= 1;
85
        }
86
        if (adv <= 0)
87
            cutscene_advance();
88
        break;
89
    case 6:
90
        obj_guardener_guy_a.active = true;
91
        obj_guardener_guy_b.active = true;
92
        instance_destroy();
93
        break;
94
}
95
if (instance_exists(obj_guardener_guy_b_shield))
96
{
97
    var current_ball = instance_find(obj_battle_enemy_attack_guardener_bullet, 0);
98
    if (instance_exists(obj_battle_enemy_attack_guardener_bullet))
99
        obj_guardener_guy_b_shield.y = lerp(obj_guardener_guy_b_shield.y, current_ball.y + 20, 0.4);
100
}
101
with (obj_guardener_guy_a_flintlock)
102
{
103
    if (image_index >= (image_number - 1))
104
    {
105
        switch (sprite_index)
106
        {
107
            case spr_guardener_guy_b_flintlock_reload:
108
                sprite_index = spr_guardener_guy_b_flintlock;
109
                image_index = 0;
110
                break;
111
            case spr_guardener_guy_b_flintlock_shoot:
112
                sprite_index = spr_guardener_guy_b_flintlock_reload;
113
                image_index = 0;
114
                break;
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
}