Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_attack_moray_sword_spin_Step_0

(view raw script w/o annotations or w/e)
1
var battle_box = obj_dialogue_box_battle_transformation_any
2
switch attack_state
3
{
4
    case 1:
5
        var x_target = battle_box.x
6
        x = lerp(x, x_target, 0.3)
7
        if (abs(x - x_target) <= 1)
8
        {
9
            x = x_target
10
            attack_state += 1
11
        }
12
        break
13
    case 2:
14
        if (image_speed == 0)
15
            image_speed = 0.5
16
        if (image_index >= (image_number - 1))
17
        {
18
            sword_color = choose("blue", "orange")
19
            attack_state += 1
20
            if (sword_color == "blue")
21
            {
22
                sprite_index = spr_attack_moray_sword_blue_start
23
                image_index = 0
24
                image_speed = (1/3)
25
            }
26
            if (sword_color == "orange")
27
            {
28
                sprite_index = spr_attack_moray_sword_orange_start
29
                image_index = 0
30
                image_speed = (1/3)
31
            }
32
        }
33
        break
34
    case 3:
35
        if (image_index >= (image_number - 1))
36
        {
37
            if (sword_color == "blue")
38
            {
39
                sprite_index = spr_attack_moray_sword_blue_spin
40
                image_index = 0
41
                image_speed = 0.25
42
            }
43
            if (sword_color == "orange")
44
            {
45
                sprite_index = spr_attack_moray_sword_orange_spin
46
                image_index = 0
47
                image_speed = 0.25
48
            }
49
            attack_state += 1
50
            no_loop = false
51
            return;
52
        }
53
        break
54
    case 4:
55
        box_dist = abs(y - battle_box.y)
56
        if (y > battle_box.y)
57
            attack_state += 1
58
        else
59
            attack_state += 2
60
        break
61
    case 5:
62
        if (path_position == 0)
63
            path_start(fly_path, 25, path_action_stop, true)
64
        else if (path_position >= 1)
65
            attack_state = 7
66
        break
67
    case 6:
68
        if (path_position == 1)
69
            path_start(fly_path, -25, path_action_stop, true)
70
        else if (path_position <= 0)
71
            attack_state = 7
72
        break
73
    case 7:
74
        if (image_index >= (image_number - 1))
75
        {
76
            if (irandom(pseudo_random_number) == 0)
77
            {
78
                attack_state = 4
79
                pseudo_random_number = pseudo_random_max
80
                return;
81
            }
82
            else
83
                pseudo_random_number = clamp((pseudo_random_number - 1), 0, pseudo_random_max)
84
            if (sword_color == "blue")
85
                sword_color = "orange"
86
            else
87
                sword_color = "blue"
88
            if (sword_color == "blue")
89
            {
90
                sprite_index = spr_attack_moray_sword_blue_start
91
                image_index = 0
92
                image_speed = 0.75
93
            }
94
            if (sword_color == "orange")
95
            {
96
                sprite_index = spr_attack_moray_sword_orange_start
97
                image_index = 0
98
                image_speed = 0.75
99
            }
100
            attack_state = 4
101
        }
102
        break
103
}
104
105
if (path_speed >= 0.1 || path_speed <= -0.1)
106
{
107
    var remnant = instance_create(x, y, obj_attack_moray_sword_spin_remnant)
108
    remnant.sprite_index = sprite_index
109
    remnant.image_speed = 0
110
    remnant.image_index = 0
111
}
112
if ((sprite_index == spr_attack_moray_sword_blue_start || (sprite_index == sprite_index) == 3501) && image_index >= (image_number - 1))
113
{
114
    if (sword_color == "blue")
115
    {
116
        sprite_index = spr_attack_moray_sword_blue_spin
117
        image_index = 0
118
        image_speed = 0.25
119
    }
120
    if (sword_color == "orange")
121
    {
122
        sprite_index = spr_attack_moray_sword_orange_spin
123
        image_index = 0
124
        image_speed = 0.25
125
    }
126
}
127
if (sword_color == "blue")
128
{
129
    if instance_exists(obj_attack_moray_sword_spin_orange)
130
        instance_destroy(obj_attack_moray_sword_spin_orange)
131
    if (!instance_exists(obj_attack_moray_sword_spin_blue))
132
        instance_create(x, y, obj_attack_moray_sword_spin_blue)
133
}
134
else if (sword_color == "orange")
135
{
136
    if instance_exists(obj_attack_moray_sword_spin_blue)
137
        instance_destroy(obj_attack_moray_sword_spin_blue)
138
    if (!instance_exists(obj_attack_moray_sword_spin_orange))
139
        instance_create(x, y, obj_attack_moray_sword_spin_orange)
140
}