Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_rndenc_Step_2

(view raw script w/o annotations or w/e)
1
if instance_exists(obj_transition)
2
    return;
3
var scripted_encounter_dist = false
4
if instance_exists(obj_scriptedencounters)
5
{
6
    with (obj_pl)
7
    {
8
        if (distance_to_object(obj_scriptedencounters) < 150)
9
            scripted_encounter_dist = true
10
    }
11
}
12
if (ds_list_empty(global.encounter_list) || enc_disabled || scripted_encounter_dist == true || global.cutscene == true)
13
    return;
14
var world_current = scr_determine_world_value_yellow
scr_determine_world_value_yellow

function scr_determine_world_value_yellow() //gml_Script_scr_determine_world_value_yellow { if (room != rm_battle && room != rm_shop && room != rm_mainmenu && room != rm_death_screen) global.current_room_overworld = room_get_name(room) var current_room_overworld = global.current_room_overworld switch current_room_overworld { case "rm_ruins_01_yellow": case "rm_ruins_02_yellow": case "rm_ruins_03_yellow": case "rm_ruins_04_yellow": case "rm_ruins_05_yellow": case "rm_ruins_06_yellow": return 0; case "rm_darkruins_01": case "rm_darkruins_02": case "rm_darkruins_03": case "rm_darkruins_04": case "rm_darkruins_05": case "rm_darkruins_06": case "rm_darkruins_07": case "rm_darkruins_08": case "rm_darkruins_08b": case "rm_darkruins_09": case "rm_darkruins_09b": case "rm_darkruins_10": case "rm_darkruins_11": case "rm_darkruins_12": case "rm_darkruins_13": case "rm_darkruins_14": case "rm_darkruins_14b": case "rm_darkruins_15": case "rm_darkruins_16": case "rm_darkruins_16b": case "rm_darkruins_16c": case "rm_darkruins_17": case "rm_darkruins_18": case "rm_dalvhallway": case "rm_dalvshouse": case "rm_dalvsroom": case "rm_dalvroomhall": case "rm_dalvExit": return 1; case "rm_snowdin_01_yellow": case "rm_snowdin_02_yellow": case "rm_snowdin_03_yellow": case "rm_snowdin_03b_yellow": case "rm_snowdin_04_yellow": case "rm_snowdin_05_yellow": case "rm_snowdin_06_yellow": case "rm_snowdin_07_yellow": case "rm_snowdin_08_yellow": case "rm_snowdin_08b_yellow": case "rm_snowdin_09_yellow": case "rm_snowdin_10_yellow": case "rm_snowdin_11_yellow": case "rm_snowdin_12_yellow": case "rm_snowdin_13_yellow": case "rm_snowdin_14_yellow": case "rm_snowdin_14b_yellow": case "rm_snowdin_14c_yellow": case "rm_snowdin_14d_yellow": case "rm_snowdin_14e_yellow": case "rm_snowdin_15_yellow": case "rm_snowdin_16_yellow": case "rm_snowdin_16b_yellow": case "rm_snowdin_17_yellow": case "rm_snowdin_18_yellow": case "rm_snowdin_19_yellow": case "rm_snowdin_20_yellow": case "rm_snowdin_21_yellow": case "rm_snowdin_22_yellow": return 2; case "rm_dunes_01": case "rm_dunes_02": case "rm_dunes_03": case "rm_dunes_04": case "rm_dunes_05": case "rm_dunes_06": case "rm_dunes_07": case "rm_dunes_08": case "rm_dunes_08b": case "rm_dunes_09": case "rm_dunes_10": case "rm_dunes_11": case "rm_dunes_12": case "rm_dunes_12b": case "rm_dunes_13": case "rm_dunes_14": case "rm_dunes_15": case "rm_dunes_16": case "rm_dunes_17": case "rm_dunes_18": case "rm_dunes_19": case "rm_dunes_19B": case "rm_dunes_20": case "rm_dunes_21": case "rm_dunes_22": case "rm_dunes_23": case "rm_dunes_24": case "rm_dunes_25": ...
()
15
var kill_area = global.kill_area[world_current][global.kill_area_current]
16
var kill_world = global.kill_number[world_current]
17
if (enc_time > 0)
18
{
19
    if global.walking
20
        enc_time -= enc_rate
21
    if obj_pl.is_sprinting
22
        enc_time -= (enc_rate * 0.7)
23
}
24
else if (!enc_found)
25
{
26
    if (kill_area > 0 && kill_world > 0)
27
    {
28
        ds_list_shuffle(global.encounter_list)
29
        var rnd_enc = ds_list_find_value(global.encounter_list, 0)
30
        instance_create((obj_pl.x - 4), (obj_pl.y - 26), obj_exclamation_mark)
31
        global.battle_enemy_name = rnd_enc
32
        global.current_room_overworld = room_get_name(room)
33
        global.battling_boss = false
34
        global.battle_start = true
35
    }
36
    else if (kill_world <= 0)
37
    {
38
        global.battle_enemy_name = "nobody came"
39
        global.current_room_overworld = room_get_name(room)
40
        global.battling_boss = false
41
        global.battle_start = true
42
        instance_create((obj_pl.x - 4), (obj_pl.y - 26), obj_exclamation_mark)
43
    }
44
    else if (kill_area <= 0)
45
        instance_create((obj_pl.x - 4), (obj_pl.y - 26), obj_exclamation_mark_fake)
46
    enc_found = true
47
}