Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_scr_loadgame

(view raw script w/o annotations or w/e)
1
function scr_loadgame
scr_loadgame

function scr_loadgame() //gml_Script_scr_loadgame { if file_exists("Save.sav") { scr_initialize() ini_open("Save.sav") var LoadedRoom = ini_read_string("Save1", "room", "rm_ruins00") obj_pl.x = ini_read_real("Save1", "pX", 320) obj_pl.y = ini_read_real("Save1", "pY", 320) obj_pl.direction = ini_read_real("Save1", "dir", 0) obj_controller.steps = ini_read_real("Save1", "SP", 0) global.player_attack = ini_read_real("Save1", "AT - Primary", 0) global.player_weapon_modifier_attack = ini_read_real("Save1", "AT - Secondary", 0) global.player_defense = ini_read_real("Save1", "DFP", 0) global.player_armor_modifier_defense = ini_read_real("Save1", "DFS", 0) global.player_level = ini_read_real("Save1", "LV", 1) global.player_exp = ini_read_real("Save1", "EXP", 0) global.player_weapon_modifier = ini_read_string("Save1", "Ammo", "Rubber Ammo") global.player_armor = ini_read_string("Save1", "Armor", "Worn Hat") global.player_armor_modifier = ini_read_string("Save1", "Accessory", "Patch") global.player_gold = ini_read_real("Save1", "Gold", 0) global.current_hp_self = ini_read_real("Save1", "HP", 1) global.max_hp_self = ini_read_real("Save1", "MAXHP", 20) global.player_weapon = ini_read_string("Save1", "Weapon", "Toy Gun") global.fun_value = ini_read_real("Save1", "FUN", 0) global.current_pp_self = ini_read_real("Save1", "PP", 0) global.max_pp_self = ini_read_real("Save1", "MAXPP", 20) global.current_sp_self = ini_read_real("Save1", "SP", 0) global.max_sp_self = ini_read_real("Save1", "MAXSP", 99) global.player_sprites = ini_read_string("Save1", "playerSprite", "normal") global.current_rp_self = ini_read_real("Save1", "RP", 0) global.max_rp_self = ini_read_real("Save1", "MAXRP", 0) global.player_can_run = ini_read_real("Save1", "playerCanRun", 1) global.saved_datetime = date_current_datetime() global.elapsed_seconds = ini_read_real("Playtime", "Seconds", 0) var _party_member = ini_read_string("Save1", "Follower", "noone") if (_party_member == "noone") global.party_member = noone else global.party_member = asset_get_index(_party_member) global.player_has_satchel = ini_read_real("Save1", "Satchel", 0) global.player_can_travel = ini_read_real("Save1", "FTravel", 0) for (var i = 0; i < array_length_1d(global.ruins_flag); i++) global.ruins_flag[i] = ini_read_real("RuinsFlags", string(i), false) for (i = 0; i < array_length_1d(global.flag); i++) global.flag[i] = ini_read_real("Flags", string(i), false) for (i = 0; i < array_length_1d(global.snowdin_flag); i++) global.snowdin_flag[i] = ini_read_real("SnowdinFlags", string(i), false) for (i = 0; i < array_length_1d(global.dunes_flag); i++) global.dunes_flag[i] = ini_read_real("DunesFlags", string(i), false) for (i = 0; i < array_length_1d(global.dunes_flag_ext); i++) global.dunes_flag_ext[i] = ini_read_real("DunesFlagsExt", string(i), false) for (i = 0; i < array_length_1d(global.sworks_flag); i++) global.sworks_flag[i] = ini_read_real("SworksFlags", string(i), false) global.factory_code = ini_read_string("SworksFlags", "code", "0000") global.factory_code_3 = ini_read_string("SworksFlags", "code3", "0000") var ds_factory_code_2 = ini_read_string("SworksFlags", "code2", "") ds_list_read(global.factory_code_2, ds_factory_code_2) global.sworks_robot_count = ini_read_real("SworksFlags", "RbCount", 0) for (i = 0; i < global.sworks_robot_count; i++) { global.sworks_robot_sprite[i] = ini_read_real("RbSprite", string(i), 0) global.sworks_robot_x[i] = ini_read_real("RbX", string(i), 0) global.sworks_robot_y[i] = ini_read_real("RbY", string(i), 0) global.sworks_robot_depth[i] = ini_read_real("RbD", string(i), 0) global.sworks_robot_scale[i] = ini_read_real("RbS", string(i), 0) global.sworks_robot_angle[i] = ini_read_real("RbA", string(i), 0) } ds_grid_read(global.sworks_id_grid, ini_read_string("SworksFlags", "sworks_id", "")) for (i = 0; i < array_length_1d(global.item_stock); i++) global.item_stock[i] = ini_read_real("ItemStock", string(i), false) for (i = 0; i < array_length_1d(global.hotland_flag); i++) global.hotland_flag[i] = ini_read_real("HotlandFlags", string(i), false) for (i = 0; i < array_length_1d(global.flowey_flag); i++) global.flowey_flag[i] = ini_read_real("FloweyFlags", string(i), false) global.flowey_save_number = ini_read_real("FloweyFlags", "savenumber", 0) global.save_count = ini_read_real("FloweyFlags", "savecount", 1) for (i = 0; i < array_length_1d(global.extra_flag); i++) global.extra_flag[i] = ini_read_real("ExtraFlags", string(i), false) for (i = 0; i < array_length_1d(global.mail_flag); i++) global.mail_flag[i] = ini_read_real("MailFlags", string(i), false) for (i = 0; i < array_length_1d(global.mail_flag); i++) global.mail_flag[i] = ini_read_real("MailFlags", string(i), false) global.mail_count = ini_read_real("Mail", "1", 0) global.mail_pinned = ini_read_real("Mail", "2", 0) global.tinypuzzle = ini_read_real("Misc", "01", 5) deaths = ini_read_real("Misc", "Deaths", false) for (i = 0; i < array_length(global.fun_event); i++) global.fun_event[i] = ini_read_real("Fun Events", string(i), 0) for (i = 1; i <= 8; i++) global.item_slot[i] = ini_read_string("Items", ("0" + (string(i - 1))), "Nothing") var ds_list_string = ini_read_string("DBox", 0, "0") ds_list_read(global.box_slot_list, ds_list_string) ds_list_string = ini_read_string("Mail", 0, "0") ds_list_read(global.mail_list, ds_list_string) ds_list_string = ini_read_string("Mail", "3", "0") ds_list_read(global.mail_list_read, ds_list_string) ds_list_string = ini_read_string("MailUnclaimed", 0, "0") ds_list_read(global.mail_unclaimed_list, ds_list_string) var ds_list_encounters = ini_read_string("Encounters", 0, "0") ds_list_read(global.encounter_list, ds_list_encounters) ...
() //gml_Script_scr_loadgame
2
{
3
    if file_exists("Save.sav")
4
    {
5
        scr_initialize
scr_initialize

function scr_initialize() //gml_Script_scr_initialize { randomize() global.player_level = 1 global.current_hp_self = 20 global.max_hp_self = 20 global.max_hp_boosted = 20 global.player_x = 150 global.player_y = 140 global.player_direction = "down" global.player_area = "" global.player_area_value = 0 global.player_can_run = true global.current_pp_self = 0 global.max_pp_self = 99 global.current_sp_self = 0 global.max_sp_self = 99 global.current_rp_self = 0 global.max_rp_self = 99 global.player_gold = 0 global.player_sprites = "normal" global.player_name = "Clover" global.party_member = -4 global.player_attack = 10 global.player_defense = 10 global.player_speed = 3 global.player_invulnerability = 30 global.player_exp = 0 global.player_weapon = "Toy Gun" global.player_armor = "Worn Hat" global.player_weapon_modifier = "Rubber Ammo" global.player_armor_modifier = "Patch" global.player_weapon_attack = script_execute(gml_Script_scr_determine_weapon_attack) global.player_armor_defense = script_execute(gml_Script_scr_determine_armor_defense) global.player_weapon_modifier_attack = script_execute(gml_Script_scr_determine_weapon_modifier_attack) global.player_armor_modifier_defense = script_execute(gml_Script_scr_determine_armor_modifier_defense) global.player_has_satchel = false global.player_can_travel = false global.saved_datetime = date_current_datetime() global.elapsed_seconds = 0 global.last_room_overworld = "rm_ruins_01" global.story = 0 global.lastroom = 7 scr_init_flags_ruins() scr_init_flags_snowdin() scr_init_flags_dunes() scr_init_flags_steamworks() scr_init_flags_hotland() scr_init_flags_flowey() global.flowey_death_pop = 0 global.flowey_save_number = 1 global.fighting_flowey = 0 global.flowey_battle_1_phase = 0 global.save_count = 0 global.extra_flag[1] = false global.extra_flag[2] = false global.extra_flag[3] = false global.extra_flag[4] = false global.extra_flag[5] = false global.extra_flag[6] = false global.extra_flag[7] = false global.extra_flag[8] = false global.extra_flag[9] = false global.encounter_flag[0] = 0 global.route = 2 global.kill_number[0] = 9999 global.kill_area[0][0] = 9999 global.kill_number[1] = 20 for (var i = 0; i <= 6; i++) global.kill_area[1][i] = 5 global.kill_number[2] = 20 for (i = 0; i <= 7; i++) global.kill_area[2][i] = 5 global.kill_number[3] = 20 for (i = 0; i <= 8; i++) global.kill_area[3][i] = 3 global.kill_number[4] = 20 for (i = 0; i <= 12; i++) global.kill_area[4][i] = 3 global.kill_area_current = 0 global.flGenoCutscene = 0 global.geno_complete[1] = false global.geno_complete[2] = false global.geno_complete[3] = false global.geno_complete[4] = false global.geno_complete[5] = false global.item_stock[0] = 1 global.item_stock[1] = 1 global.item_stock[2] = 1 global.item_stock[3] = 1 global.item_stock[4] = 1 global.item_stock[5] = 1 global.item_stock[6] = 1 global.item_stock[7] = 1 global.item_stock[8] = 3 global.item_stock[9] = 1 global.item_stock[10] = 1 global.item_stock[11] = 1 global.item_stock[12] = 2 global.item_stock[13] = 2 global.item_stock[14] = 1 ...
()
6
        ini_open("Save.sav")
7
        var LoadedRoom = ini_read_string("Save1", "room", "rm_ruins00")
8
        obj_pl.x = ini_read_real("Save1", "pX", 320)
9
        obj_pl.y = ini_read_real("Save1", "pY", 320)
10
        obj_pl.direction = ini_read_real("Save1", "dir", 0)
11
        obj_controller.steps = ini_read_real("Save1", "SP", 0)
12
        global.player_attack = ini_read_real("Save1", "AT - Primary", 0)
13
        global.player_weapon_modifier_attack = ini_read_real("Save1", "AT - Secondary", 0)
14
        global.player_defense = ini_read_real("Save1", "DFP", 0)
15
        global.player_armor_modifier_defense = ini_read_real("Save1", "DFS", 0)
16
        global.player_level = ini_read_real("Save1", "LV", 1)
17
        global.player_exp = ini_read_real("Save1", "EXP", 0)
18
        global.player_weapon_modifier = ini_read_string("Save1", "Ammo", "Rubber Ammo")
19
        global.player_armor = ini_read_string("Save1", "Armor", "Worn Hat")
20
        global.player_armor_modifier = ini_read_string("Save1", "Accessory", "Patch")
21
        global.player_gold = ini_read_real("Save1", "Gold", 0)
22
        global.current_hp_self = ini_read_real("Save1", "HP", 1)
23
        global.max_hp_self = ini_read_real("Save1", "MAXHP", 20)
24
        global.player_weapon = ini_read_string("Save1", "Weapon", "Toy Gun")
25
        global.fun_value = ini_read_real("Save1", "FUN", 0)
26
        global.current_pp_self = ini_read_real("Save1", "PP", 0)
27
        global.max_pp_self = ini_read_real("Save1", "MAXPP", 20)
28
        global.current_sp_self = ini_read_real("Save1", "SP", 0)
29
        global.max_sp_self = ini_read_real("Save1", "MAXSP", 99)
30
        global.player_sprites = ini_read_string("Save1", "playerSprite", "normal")
31
        global.current_rp_self = ini_read_real("Save1", "RP", 0)
32
        global.max_rp_self = ini_read_real("Save1", "MAXRP", 0)
33
        global.player_can_run = ini_read_real("Save1", "playerCanRun", 1)
34
        global.saved_datetime = date_current_datetime()
35
        global.elapsed_seconds = ini_read_real("Playtime", "Seconds", 0)
36
        var _party_member = ini_read_string("Save1", "Follower", "noone")
37
        if (_party_member == "noone")
38
            global.party_member = noone
39
        else
40
            global.party_member = asset_get_index(_party_member)
41
        global.player_has_satchel = ini_read_real("Save1", "Satchel", 0)
42
        global.player_can_travel = ini_read_real("Save1", "FTravel", 0)
43
        for (var i = 0; i < array_length_1d(global.ruins_flag); i++)
44
            global.ruins_flag[i] = ini_read_real("RuinsFlags", string(i), false)
45
        for (i = 0; i < array_length_1d(global.flag); i++)
46
            global.flag[i] = ini_read_real("Flags", string(i), false)
47
        for (i = 0; i < array_length_1d(global.snowdin_flag); i++)
48
            global.snowdin_flag[i] = ini_read_real("SnowdinFlags", string(i), false)
49
        for (i = 0; i < array_length_1d(global.dunes_flag); i++)
50
            global.dunes_flag[i] = ini_read_real("DunesFlags", string(i), false)
51
        for (i = 0; i < array_length_1d(global.dunes_flag_ext); i++)
52
            global.dunes_flag_ext[i] = ini_read_real("DunesFlagsExt", string(i), false)
53
        for (i = 0; i < array_length_1d(global.sworks_flag); i++)
54
            global.sworks_flag[i] = ini_read_real("SworksFlags", string(i), false)
55
        global.factory_code = ini_read_string("SworksFlags", "code", "0000")
56
        global.factory_code_3 = ini_read_string("SworksFlags", "code3", "0000")
57
        var ds_factory_code_2 = ini_read_string("SworksFlags", "code2", "")
58
        ds_list_read(global.factory_code_2, ds_factory_code_2)
59
        global.sworks_robot_count = ini_read_real("SworksFlags", "RbCount", 0)
60
        for (i = 0; i < global.sworks_robot_count; i++)
61
        {
62
            global.sworks_robot_sprite[i] = ini_read_real("RbSprite", string(i), 0)
63
            global.sworks_robot_x[i] = ini_read_real("RbX", string(i), 0)
64
            global.sworks_robot_y[i] = ini_read_real("RbY", string(i), 0)
65
            global.sworks_robot_depth[i] = ini_read_real("RbD", string(i), 0)
66
            global.sworks_robot_scale[i] = ini_read_real("RbS", string(i), 0)
67
            global.sworks_robot_angle[i] = ini_read_real("RbA", string(i), 0)
68
        }
69
        ds_grid_read(global.sworks_id_grid, ini_read_string("SworksFlags", "sworks_id", ""))
70
        for (i = 0; i < array_length_1d(global.item_stock); i++)
71
            global.item_stock[i] = ini_read_real("ItemStock", string(i), false)
72
        for (i = 0; i < array_length_1d(global.hotland_flag); i++)
73
            global.hotland_flag[i] = ini_read_real("HotlandFlags", string(i), false)
74
        for (i = 0; i < array_length_1d(global.flowey_flag); i++)
75
            global.flowey_flag[i] = ini_read_real("FloweyFlags", string(i), false)
76
        global.flowey_save_number = ini_read_real("FloweyFlags", "savenumber", 0)
77
        global.save_count = ini_read_real("FloweyFlags", "savecount", 1)
78
        for (i = 0; i < array_length_1d(global.extra_flag); i++)
79
            global.extra_flag[i] = ini_read_real("ExtraFlags", string(i), false)
80
        for (i = 0; i < array_length_1d(global.mail_flag); i++)
81
            global.mail_flag[i] = ini_read_real("MailFlags", string(i), false)
82
        for (i = 0; i < array_length_1d(global.mail_flag); i++)
83
            global.mail_flag[i] = ini_read_real("MailFlags", string(i), false)
84
        global.mail_count = ini_read_real("Mail", "1", 0)
85
        global.mail_pinned = ini_read_real("Mail", "2", 0)
86
        global.tinypuzzle = ini_read_real("Misc", "01", 5)
87
        deaths = ini_read_real("Misc", "Deaths", false)
88
        for (i = 0; i < array_length(global.fun_event); i++)
89
            global.fun_event[i] = ini_read_real("Fun Events", string(i), 0)
90
        for (i = 1; i <= 8; i++)
91
            global.item_slot[i] = ini_read_string("Items", ("0" + (string(i - 1))), "Nothing")
92
        var ds_list_string = ini_read_string("DBox", 0, "0")
93
        ds_list_read(global.box_slot_list, ds_list_string)
94
        ds_list_string = ini_read_string("Mail", 0, "0")
95
        ds_list_read(global.mail_list, ds_list_string)
96
        ds_list_string = ini_read_string("Mail", "3", "0")
97
        ds_list_read(global.mail_list_read, ds_list_string)
98
        ds_list_string = ini_read_string("MailUnclaimed", 0, "0")
99
        ds_list_read(global.mail_unclaimed_list, ds_list_string)
100
        var ds_list_encounters = ini_read_string("Encounters", 0, "0")
101
        ds_list_read(global.encounter_list, ds_list_encounters)
102
        var ds_list_steal = ini_read_string("Steal", 0, "0")
103
        ds_list_read(global.steal_list, ds_list_steal)
104
        var ds_list_fasttravel = ini_read_string("FastTravel", 0, "0")
105
        ds_list_read(global.fast_travel_list, ds_list_fasttravel)
106
        var ds_map_string = ini_read_string("NPCs", "0", "0")
107
        ds_map_read(global.npc_map, ds_map_string)
108
        var ds_talk_map_string = ini_read_string("Talks", "0", "0")
109
        ds_map_read(global.talk_map, ds_map_string)
110
        global.interaction_count_wardrobe = ini_read_real("Misc2", "00", 0)
111
        global.interaction_count_broom = ini_read_real("Misc2", "01", 0)
112
        global.interaction_count_mini_fridge = ini_read_real("Misc2", "02", 0)
113
        global.interaction_count_painting = ini_read_real("Misc2", "03", 0)
114
        global.interaction_count_dalvsroom_chest = ini_read_real("Misc2", "04", 0)
115
        global.interaction_count_flower_pot = ini_read_real("Misc2", "05", 0)
116
        global.interaction_count_doorway_dalvshouse = ini_read_real("Misc2", "06", 0)
117
        global.interaction_count_dalvroomhall_door = ini_read_real("Misc2", "07", 0)
118
        global.dalv_house_enter_count = ini_read_real("Misc2", "08", 0)
119
        global.interaction_count_books = ini_read_real("Misc2", "09", 0)
120
        deathText = ini_read_real("Misc2", "10", 0)
121
        global.route = ini_read_real("Route", "00", 2)
122
        for (i = 1; i < array_length_1d(global.geno_complete); i++)
123
            global.geno_complete[i] = ini_read_real("GenoComplete", i, 0)
124
        for (i = 1; i < array_length_1d(global.kill_number); i++)
125
        {
126
            global.kill_number[i] = ini_read_real("Kills", i, 20)
127
            for (var j = 0; j < array_length_2d(global.kill_area, i); j++)
128
                global.kill_area[i][j] = ini_read_real("Kill Area", (string(i) + string(j)), 5)
129
        }
130
        global.gold_amount_total = ini_read_real("Save1", "gldtrack", 0)
131
        global.gold_spent = ini_read_real("Save1", "gldspnttrack", 0)
132
        global.hit_tracker = ini_read_real("Save1", "httrack", 0)
133
        global.fighting_flowey = ini_read_real("Misc2", "10", 0)
134
        if (global.fighting_flowey == 0)
135
            room_goto(asset_get_index(LoadedRoom))
136
        else if (global.fighting_flowey == 1)
137
        {
138
            instance_create_depth((camera_get_view_x(view_camera[0]) + 320), (camera_get_view_y(view_camera[0]) + 120), -99999, obj_flowey_rooftop_big)
139
            obj_flowey_rooftop_big.persistent = true
140
            obj_flowey_rooftop_big.image_xscale_base *= 2
141
            obj_flowey_rooftop_big.image_yscale_base *= 2
142
            var controller = instance_create_depth(0, 0, -9999, obj_flowey_world_controller)
143
            controller.scene = 95
144
            instance_create(0, 0, obj_battle_fade_in_screen)
145
            obj_battle_fade_in_screen.persistent = true
146
            obj_battle_fade_in_screen.fade_speed = 0.025
147
            room_goto(rm_battle_flowey Flowey - Phase 1 Battle Room)
148
            if (!texture_is_ready("BattleHotlandFloweyPhase1"))
149
                texture_prefetch("BattleHotlandFloweyPhase1")
150
            global.battling_boss = true
151
            global.battle_start = true
152
            global.sound_carry_overworld = false
153
            scr_cutscene_start
scr_cutscene_start

function scr_cutscene_start() //gml_Script_scr_cutscene_start { global.cutscene = true obj_pl.state = gml_Script_scr_frozen_state obj_pl.image_index = 0 obj_pl.image_speed = 0 }
()
154
            global.battle_enemy_name = "flowey"
155
            obj_pl.image_alpha = 0
156
        }
157
        else if (global.fighting_flowey == 2)
158
        {
159
            global.flowey_phase_2_noloop = true
160
            room_goto(rm_battle_flowey_phase_2 Flowey - Phase 2 Battle Room)
161
            if (!texture_is_ready("BattleHotlandFloweyPaper"))
162
                texture_prefetch("BattleHotlandFloweyPaper")
163
            if (!texture_is_ready("BattleHotlandFloweyGray"))
164
                texture_prefetch("BattleHotlandFloweyGray")
165
            if (!texture_is_ready("BattleHotlandFloweyClay"))
166
                texture_prefetch("BattleHotlandFloweyClay")
167
            if (!texture_is_ready("BattleHotlandFloweyMechanical"))
168
                texture_prefetch("BattleHotlandFloweyMechanical")
169
            if (!texture_is_ready("BattleHotlandFloweyLowpoly"))
170
                texture_prefetch("BattleHotlandFloweyLowpoly")
171
            if (!texture_is_ready("BattleHotlandFloweyYarn"))
172
                texture_prefetch("BattleHotlandFloweyYarn")
173
            if (!texture_is_ready("BattleHotlandFloweyOrganic"))
174
                texture_prefetch("BattleHotlandFloweyOrganic")
175
            global.battling_boss = true
176
            global.battle_start = true
177
            global.sound_carry_overworld = false
178
            global.cutscene = true
179
            global.battle_enemy_name = "flowey2"
180
            obj_pl.image_alpha = 0
181
        }
182
        if (global.party_member != noone && (!instance_exists(global.party_member)))
183
            instance_create_depth(obj_pl.x, obj_pl.y, obj_pl.depth, global.party_member)
184
        ini_close()
185
        if file_exists("Save02.sav")
186
        {
187
            ini_open("Save02.sav")
188
            global.meta_flowey_fight_count = ini_read_real("00", "01", 0)
189
            global.death_count_total = ini_read_real("Deaths", "00", 0)
190
            global.death_count[1] = ini_read_real("Deaths", "01", 0)
191
            global.death_count[2] = ini_read_real("Deaths", "02", 0)
192
            ini_close()
193
        }
194
        if (global.fun_value == 1)
195
            global.fun_swig_name = "Dave"
196
    }
197
}