Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_heart_battle_menu_Step_0

(view raw script w/o annotations or w/e)
1
if live_call()
2
    return global.live_result;
3
var battle_menu_number = global.battle_menu_number
4
var battle_enemy_name = global.battle_enemy_name
5
var enemy_count = global.enemy_count
6
var game_mode = global.game_mode
7
script_execute(gml_Script_scr_controls_battle_main)
8
if (instance_exists(obj_dialogue_box_battle) && key_select)
9
{
10
    if (battle_menu_number == 1)
11
    {
12
        if (!instance_exists(obj_fight_locked))
13
        {
14
            if (global.enemy_dead == false && global.enemy_spared == false)
15
                instance_create(0, 0, obj_text_battle_move_selected_enemy_fight)
16
            if (enemy_count >= 2)
17
            {
18
                if (global.enemy_dead_2 == false && global.enemy_spared_2 == false)
19
                    instance_create(0, 0, obj_text_battle_move_selected_enemy_fight_2)
20
            }
21
            if (enemy_count >= 3)
22
            {
23
                if (global.enemy_dead_3 == false && global.enemy_spared_3 == false)
24
                    instance_create(0, 0, obj_text_battle_move_selected_enemy_fight_3)
25
            }
26
            instance_create((obj_dialogue_box_battle.x + 44), (obj_dialogue_box_battle.y + 36), obj_heart_battle_menu_fight)
27
            script_execute(gml_Script_scr_battle_core_directory_hp_displacements)
28
            script_execute(gml_Script_scr_determine_can_display_enemy_hp_ui)
29
            if (enemy_count >= 1)
30
            {
31
                if (global.enemy_vulnerable == false && global.enemy_dead == false && global.enemy_spared == false)
32
                {
33
                    with (obj_battle_hp_current_enemy)
34
                        instance_destroy()
35
                    with (obj_battle_hp_max_enemy)
36
                        instance_destroy()
37
                }
38
            }
39
            if (enemy_count >= 2)
40
            {
41
                if (global.enemy_vulnerable_2 == false && global.enemy_dead_2 == false && global.enemy_spared_2 == false)
42
                {
43
                    with (obj_battle_hp_current_enemy_2)
44
                        instance_destroy()
45
                    with (obj_battle_hp_max_enemy_2)
46
                        instance_destroy()
47
                }
48
            }
49
            if (enemy_count >= 3)
50
            {
51
                if (global.enemy_vulnerable_3 == false && global.enemy_dead_3 == false && global.enemy_spared_3 == false)
52
                {
53
                    with (obj_battle_hp_current_enemy_3)
54
                        instance_destroy()
55
                    with (obj_battle_hp_max_enemy_3)
56
                        instance_destroy()
57
                }
58
            }
59
            with (obj_dialogue_battle_move_select_parent)
60
                instance_destroy()
61
            audio_play_sound(snd_battle_item_weapon_select, 20, false)
62
            image_alpha = 0
63
        }
64
        else
65
            audio_play_sound(snd_fail, 1, 0)
66
    }
67
    if (battle_menu_number == 2)
68
    {
69
        if (global.enemy_dead == false && global.enemy_spared == false)
70
            instance_create(0, 0, obj_text_battle_move_selected_enemy_name)
71
        if (enemy_count >= 2)
72
        {
73
            if (global.enemy_dead_2 == false && global.enemy_spared_2 == false)
74
                instance_create(0, 0, obj_text_battle_move_selected_enemy_name_2)
75
        }
76
        if (enemy_count >= 3)
77
        {
78
            if (global.enemy_dead_3 == false && global.enemy_spared_3 == false)
79
                instance_create(0, 0, obj_text_battle_move_selected_enemy_name_3)
80
        }
81
        instance_create((obj_dialogue_box_battle.x + 44), (obj_dialogue_box_battle.y + 36), obj_heart_battle_menu_act)
82
        with (obj_dialogue_battle_move_select_parent)
83
            instance_destroy()
84
        audio_play_sound(snd_battle_item_weapon_select, 20, false)
85
        image_alpha = 0
86
    }
87
    if (battle_menu_number == 3)
88
    {
89
        if (obj_item.image_index == 1)
90
        {
91
            global.item_page_count = 1
92
            global.item_number_row = 1
93
            global.item_number_column = 1
94
            if (global.item_slot[1] != "Nothing")
95
                instance_create(0, 0, obj_text_battle_move_selected_item_1)
96
            if (global.item_slot[2] != "Nothing")
97
                instance_create(0, 0, obj_text_battle_move_selected_item_2)
98
            if (global.item_slot[3] != "Nothing")
99
                instance_create(0, 0, obj_text_battle_move_selected_item_3)
100
            if (global.item_slot[4] != "Nothing")
101
                instance_create(0, 0, obj_text_battle_move_selected_item_4)
102
            instance_create(0, 0, obj_text_battle_move_selected_item_page_count)
103
            instance_create((obj_dialogue_box_battle.x + 44), (obj_dialogue_box_battle.y + 36), obj_heart_battle_menu_item)
104
            with (obj_dialogue_battle_move_select_parent)
105
                instance_destroy()
106
            audio_play_sound(snd_battle_item_weapon_select, 20, false)
107
            image_alpha = 0
108
        }
109
        else
110
            audio_play_sound(snd_hurt, 20, false)
111
    }
112
    if (battle_menu_number == 4)
113
    {
114
        instance_create(0, 0, obj_text_battle_move_selected_spare)
115
        if (global.enemy_fleeable == true)
116
            instance_create(0, 0, obj_text_battle_move_selected_flee)
117
        instance_create((obj_dialogue_box_battle.x + 44), (obj_dialogue_box_battle.y + 36), obj_heart_battle_menu_mercy)
118
        with (obj_dialogue_battle_move_select_parent)
119
            instance_destroy()
120
        audio_play_sound(snd_battle_item_weapon_select, 20, false)
121
        image_alpha = 0
122
    }
123
}
124
if (key_select == 0)
125
{
126
    if (key_right && key_left == 0)
127
    {
128
        var battle_menu_number_prev = battle_menu_number
129
        var move_number = true
130
        while (move_number == true)
131
        {
132
            if (battle_menu_number == 4)
133
                global.battle_menu_number = 1
134
            else
135
                global.battle_menu_number += 1
136
            battle_menu_number = global.battle_menu_number
137
            if ((battle_menu_number == 1 && instance_exists(obj_fight)) || (battle_menu_number == 2 && instance_exists(obj_act)) || (battle_menu_number == 3 && instance_exists(obj_item)) || (battle_menu_number == 4 && instance_exists(obj_mercy)))
138
                move_number = false
139
        }
140
        if (global.battle_menu_number != battle_menu_number_prev)
141
            audio_play_sound(snd_mainmenu_select, 20, false)
142
    }
143
    if (key_left && key_right == 0)
144
    {
145
        battle_menu_number_prev = battle_menu_number
146
        move_number = true
147
        while (move_number == true)
148
        {
149
            if (battle_menu_number == 1)
150
                global.battle_menu_number = 4
151
            else
152
                global.battle_menu_number -= 1
153
            battle_menu_number = global.battle_menu_number
154
            if ((battle_menu_number == 1 && instance_exists(obj_fight)) || (battle_menu_number == 2 && instance_exists(obj_act)) || (battle_menu_number == 3 && instance_exists(obj_item)) || (battle_menu_number == 4 && instance_exists(obj_mercy)))
155
                move_number = false
156
        }
157
        if (global.battle_menu_number != battle_menu_number_prev)
158
            audio_play_sound(snd_mainmenu_select, 20, false)
159
    }
160
}
161
if (battle_menu_number == 1 && instance_exists(obj_fight_locked))
162
    global.battle_menu_number = 2
163
battle_menu_number = global.battle_menu_number
164
if (battle_menu_number == 1)
165
{
166
    x = obj_fight.x + 17
167
    y = obj_fight.y + 23
168
}
169
else if (battle_menu_number == 2)
170
{
171
    x = obj_act.x + 17
172
    y = obj_act.y + 23
173
}
174
else if (battle_menu_number == 3)
175
{
176
    x = obj_item.x + 17
177
    y = obj_item.y + 23
178
}
179
else if (battle_menu_number == 4)
180
{
181
    x = obj_mercy.x + 17
182
    y = obj_mercy.y + 23
183
}
184
if (no_loop_determine_sparing == false)
185
{
186
    script_execute(gml_Script_scr_determine_low_hp_enemy_sparing)
187
    no_loop_determine_sparing = true
188
}
189
if (image_alpha == 1 && no_loop == false)
190
{
191
    script_execute(gml_Script_scr_battle_core_directory_flavor_text_recreation)
192
    no_loop = true
193
}