Undertale script viewer

← back to main script listing

gml_Object_obj_time_Step_1

(view raw script w/o annotations or w/e)
1
if (started <= 0)
2
{
3
    if (global.savedata_async_id >= 0)
4
        exit;
5
    started = -1;
6
    if (!trophy_init())
7
    {
8
        if (trophy_ts < 0)
9
            trophy_ts = current_time;
10
        exit;
11
    }
12
    ossafe_ini_open("config.ini");
13
    var lang = ini_read_string("General", "lang", "");
14
    var sb_i = ini_read_real("General", "sb", -1);
15
    var b0_i = ini_read_real("joypad1", "b0", -1);
16
    var b1_i = ini_read_real("joypad1", "b1", -1);
17
    var b2_i = ini_read_real("joypad1", "b2", -1);
18
    var as_i = ini_read_real("joypad1", "as", -1);
19
    var jd_i = ini_read_real("joypad1", "jd", -1);
20
    if (string_length(lang) > 0)
21
        global.language = lang;
22
    if (sb_i >= 0)
23
        global.screen_border_id = sb_i;
24
    if (b0_i >= 0)
25
        global.button0 = b0_i;
26
    if (b1_i >= 0)
27
        global.button1 = b1_i;
28
    if (b2_i >= 0)
29
        global.button2 = b2_i;
30
    if (as_i >= 0)
31
        global.analog_sense = as_i;
32
    if (jd_i >= 0)
33
        global.joy_dir = jd_i;
34
    ossafe_ini_close();
35
    scr_enable_screen_border
scr_enable_screen_border

var flag = argument0; flag = flag != 0; if (flag != global.screen_border_active) { global.screen_border_active = flag != 0; global.screen_border_state = 0; global.screen_border_dynamic_fade_id = 0; global.screen_border_dynamic_fade_level = 0; }
(global.osflavor >= 4);
36
    if (global.osflavor >= 4)
37
    {
38
        global.analog_sense = 0.15;
39
        if (os_type == os_psvita)
40
            global.analog_sense = 0.9;
41
        global.joy_dir = 0;
42
    }
43
    ossafe_ini_open("undertale.ini");
44
    fskip = ini_read_real("FFFFF", "E", -1);
45
    ftime = ini_read_real("FFFFF", "F", -1);
46
    true_end = ini_read_real("EndF", "EndF", -1);
47
    ossafe_ini_close();
48
    sksk = 0;
49
    if (ftime == 1)
50
    {
51
        sksk = 1;
52
        room_goto(room_f_start Omega Flowey - Initializer [Dogchecked]);
53
    }
54
    if (true_end == 1 && sksk == 0)
55
    {
56
        sksk = 1;
57
        room_goto(room_flowey_regret Flowey's pacifist speech [Dogchecked]);
58
    }
59
    if (fskip >= 1 && sksk == 0)
60
    {
61
        global.filechoice = 8;
62
        scr_load
scr_load

filechoicebk = global.filechoice; room_set_persistent(global.currentroom, 0); script_execute(SCR_GAMESTART); global.filechoice = filechoicebk; file = "file" + string(global.filechoice); myfileid = ossafe_file_text_open_read(file); global.charname = ossafe_file_text_read_string(myfileid); ossafe_file_text_readln(myfileid); global.lv = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.maxhp = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.maxen = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.at = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.wstrength = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.df = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.adef = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.sp = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.xp = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.gold = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.kills = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); for (i = 0; i < 8; i += 1) { global.item[i] = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.phone[i] = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); } global.weapon = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.armor = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); for (i = 0; i < 512; i += 1) { global.flag[i] = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); } global.plot = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); for (i = 0; i < 3; i += 1) { global.menuchoice[i] = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); } global.flag[94 current_napstablook_song] = 0; global.currentsong = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.currentroom = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); obj_time.time = ossafe_file_text_read_real(myfileid); ossafe_file_text_readln(myfileid); global.lastsavedkills = global.kills; global.lastsavedtime = obj_time.time; global.lastsavedlv = global.lv; ossafe_file_text_close(myfileid); global.hp = global.maxhp; global.en = global.maxen; script_execute(scr_tempsave); if (global.currentroom < room_tundra_garage) global.area = 0; if (global.currentroom >= room_tundra_garage) global.area = 1; global.flag[360 rain_unmuted] = 0; global.flag[361 rain_track1_volume] = 0; global.flag[362 rain_track2_volume] = 0; global.flag[363 rain_track1] = 0; global.flag[364 rain_track2] = 0; scr_dogcheck(); if (dogcheck == 1) room_goto(global.currentroom);
();
63
        if (fskip == 1)
64
            room_goto(room_flowey_endchoice Omega Flowey - Wilting [Dogchecked]);
65
        if (fskip == 2)
66
            room_goto(room_castle_exit Flowey post-battle);
67
    }
68
    else if (sksk == 0)
69
    {
70
        room_goto_next();
71
    }
72
    if (ossafe_file_exists("system_information_962") && !ossafe_file_exists("system_information_963"))
73
        room_goto(room_nothingness Genocide - The Nothingness [Dogchecked]);
74
    started = 1;
75
    exit;
76
}
77
if (!paused)
78
    time += 1;
79
if (global.osflavor <= 2)
80
{
81
    if (jt == 0)
82
    {
83
        if (j_ch != 2)
84
        {
85
            if (joystick_exists(1))
86
                j_ch = 1;
87
            else if (j_ch == 1)
88
                j_ch = 0;
89
        }
90
    }
91
    if (jt == 4)
92
    {
93
        if (j_ch != 1)
94
        {
95
            if (joystick_exists(2))
96
                j_ch = 2;
97
            else if (j_ch == 2)
98
                j_ch = 0;
99
        }
100
    }
101
    jt += 1;
102
    if (jt >= 8)
103
        jt = 0;
104
}
105
control_update();
106
if (j_ch > 0)
107
{
108
    j_fr_p = j_fr;
109
    j_fl_p = j_fl;
110
    j_fu_p = j_fu;
111
    j_fd_p = j_fd;
112
    j_fr = 0;
113
    j_fl = 0;
114
    j_fu = 0;
115
    j_fd = 0;
116
    if (global.osflavor >= 4)
117
    {
118
        if (gamepad_button_check(j_ch - 1, gp_padu) || gamepad_button_check(j_ch - 1, gp_padd) || gamepad_button_check(j_ch - 1, gp_padl) || gamepad_button_check(j_ch - 1, gp_padr))
119
        {
120
            j_fu = gamepad_button_check(j_ch - 1, gp_padu);
121
            j_fd = gamepad_button_check(j_ch - 1, gp_padd);
122
            j_fl = gamepad_button_check(j_ch - 1, gp_padl);
123
            j_fr = gamepad_button_check(j_ch - 1, gp_padr);
124
        }
125
        else if (global.joy_dir != 2)
126
        {
127
            var j_xpos = gamepad_axis_value(j_ch - 1, gp_axislh);
128
            var j_ypos = gamepad_axis_value(j_ch - 1, gp_axislv);
129
            var analog_sense = global.analog_sense;
130
            if (sqrt(sqr(j_xpos) + sqr(j_ypos)) >= analog_sense)
131
            {
132
                var angle = darctan2(j_ypos, j_xpos);
133
                if (angle < 0)
134
                    angle += 360;
135
                if (angle < 67.5 || angle > 292.5)
136
                    j_fr = 1;
137
                if (angle > 22.5 && angle < 157.5)
138
                    j_fd = 1;
139
                if (angle > 112.5 && angle < 247.5)
140
                    j_fl = 1;
141
                if (angle > 202.5 && angle < 337.5)
142
                    j_fu = 1;
143
            }
144
        }
145
    }
146
    else
147
    {
148
        var j_xpos, j_ypos;
149
        if (global.joy_dir == 0 || global.joy_dir == 1)
150
        {
151
            j_xpos = joystick_xpos(j_ch);
152
            j_ypos = joystick_ypos(j_ch);
153
        }
154
        j_dir = joystick_direction(j_ch);
155
        if (global.joy_dir == 0 || global.joy_dir == 1)
156
        {
157
            if (j_dir == 101)
158
            {
159
                if (j_xpos >= global.analog_sense)
160
                    j_fr = 1;
161
                if (j_xpos <= -global.analog_sense)
162
                    j_fl = 1;
163
                if (j_ypos >= global.analog_sense)
164
                    j_fd = 1;
165
                if (j_ypos <= -global.analog_sense)
166
                    j_fu = 1;
167
            }
168
        }
169
        if (j_dir != 101)
170
        {
171
            if (j_dir == 100)
172
                j_fl = 1;
173
            if (j_dir == 98)
174
                j_fd = 1;
175
            if (j_dir == 102)
176
                j_fr = 1;
177
            if (j_dir == 104)
178
                j_fu = 1;
179
            if (j_dir == 99)
180
            {
181
                j_fr = 1;
182
                j_fd = 1;
183
            }
184
            if (j_dir == 97)
185
            {
186
                j_fd = 1;
187
                j_fl = 1;
188
            }
189
            if (j_dir == 103)
190
            {
191
                j_fu = 1;
192
                j_fl = 1;
193
            }
194
            if (j_dir == 105)
195
            {
196
                j_fu = 1;
197
                j_fr = 1;
198
            }
199
        }
200
        if (global.joy_dir == 0 || global.joy_dir == 2)
201
        {
202
            j_pov = joystick_pov(j_ch);
203
            if (j_pov == 0)
204
                j_fu = 1;
205
            if (j_pov == 270)
206
                j_fl = 1;
207
            if (j_pov == 90)
208
                j_fr = 1;
209
            if (j_pov == 180)
210
                j_fd = 1;
211
            if (j_pov == 315)
212
            {
213
                j_fu = 1;
214
                j_fl = 1;
215
            }
216
            if (j_pov == 45)
217
            {
218
                j_fu = 1;
219
                j_fr = 1;
220
            }
221
            if (j_pov == 225)
222
            {
223
                j_fd = 1;
224
                j_fl = 1;
225
            }
226
            if (j_pov == 135)
227
            {
228
                j_fd = 1;
229
                j_fr = 1;
230
            }
231
        }
232
    }
233
    if (j_fr != j_fr_p && j_fr == 1)
234
        keyboard_key_press(vk_right);
235
    if (j_fl != j_fl_p && j_fl == 1)
236
        keyboard_key_press(vk_left);
237
    if (j_fd != j_fd_p && j_fd == 1)
238
        keyboard_key_press(vk_down);
239
    if (j_fu != j_fu_p && j_fu == 1)
240
        keyboard_key_press(vk_up);
241
    if (j_fr != j_fr_p && j_fr == 0)
242
        keyboard_key_release(vk_right);
243
    if (j_fl != j_fl_p && j_fl == 0)
244
        keyboard_key_release(vk_left);
245
    if (j_fd != j_fd_p && j_fd == 0)
246
        keyboard_key_release(vk_down);
247
    if (j_fu != j_fu_p && j_fu == 0)
248
        keyboard_key_release(vk_up);
249
}
250
up = 0;
251
down = 0;
252
left = 0;
253
right = 0;
254
if (keyboard_check(vk_up))
255
    try_up = 1;
256
if (keyboard_check_released(vk_up))
257
    try_up = 0;
258
if (keyboard_check(vk_down))
259
    try_down = 1;
260
if (keyboard_check_released(vk_down))
261
    try_down = 0;
262
if (keyboard_check(vk_right))
263
    try_right = 1;
264
if (keyboard_check_released(vk_right))
265
    try_right = 0;
266
if (keyboard_check(vk_left))
267
    try_left = 1;
268
if (keyboard_check_released(vk_left))
269
    try_left = 0;
270
if (global.osflavor == 1)
271
{
272
    if (try_up)
273
        up = keyboard_check_direct(vk_up);
274
    if (try_down)
275
        down = keyboard_check_direct(vk_down);
276
    if (try_left)
277
        left = keyboard_check_direct(vk_left);
278
    if (try_right)
279
        right = keyboard_check_direct(vk_right);
280
}
281
else
282
{
283
    if (try_up)
284
        up = keyboard_check(vk_up);
285
    if (try_down)
286
        down = keyboard_check(vk_down);
287
    if (try_left)
288
        left = keyboard_check(vk_left);
289
    if (try_right)
290
        right = keyboard_check(vk_right);
291
}
292
if (keyboard_check_released(vk_up))
293
    up = 0;
294
if (keyboard_check_released(vk_down))
295
    down = 0;
296
if (keyboard_check_released(vk_left))
297
    left = 0;
298
if (keyboard_check_released(vk_right))
299
    right = 0;
300
var now_idle = !(up || down || left || right || control_check(0) || control_check(1) || control_check(2));
301
if (now_idle && !idle)
302
    idle_time = current_time;
303
idle = now_idle;
304
if (control_check(2))
305
{
306
    if (global.flag[28 fast_text_skip] == 1)
307
    {
308
        if (instance_exists(OBJ_WRITER) && !instance_exists(obj_choicer))
309
        {
310
            if (h_skip == 0)
311
            {
312
                keyboard_key_press(ord("X"));
313
                keyboard_key_press(ord("Z"));
314
            }
315
            if (h_skip == 1)
316
            {
317
                keyboard_key_release(ord("Z"));
318
                keyboard_key_release(ord("X"));
319
            }
320
            if (h_skip == 0)
321
                h_skip = 1;
322
            else
323
                h_skip = 0;
324
        }
325
    }
326
}
327
if (global.debug == 1)
328
{
329
    if (keyboard_check_pressed(ord("F")))
330
        room_speed = 200;
331
}
332
if (global.debug == 1)
333
{
334
    if (keyboard_check_pressed(ord("W")))
335
        room_speed = 10;
336
}
337
if (keyboard_check_pressed(vk_f4))
338
{
339
    if (window_get_fullscreen())
340
        window_set_fullscreen(false);
341
    else
342
        window_set_fullscreen(true);
343
}
344
if (canquit == 1)
345
{
346
    if (global.debug == 1)
347
    {
348
        if (keyboard_check_pressed(ord("R")) && instance_exists(obj_essaystuff) == 0)
349
        {
350
            debug_r += 1;
351
            if (debug_r > 5)
352
                game_restart();
353
            spec_rtimer = 1;
354
        }
355
    }
356
    spec_rtimer += 1;
357
    if (spec_rtimer >= 6)
358
        debug_r = 0;
359
    if (keyboard_check(vk_escape))
360
    {
361
        quit += 1;
362
        if (instance_exists(obj_quittingmessage) == 0)
363
            instance_create(0, 0, obj_quittingmessage);
364
    }
365
    else
366
    {
367
        quit = 0;
368
    }
369
}