Deltarune (Chapter 3) script viewer

← back to main script listing

gml_GlobalScript_scr_complete_save_file

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

function
scr_complete_save_file()
{ _remfilechoice = global.filechoice; global.filechoice += 3; scr_set_ini_value(global.chapter, global.filechoice, "SideB", scr_sideb_active());
scr_save();
global.filechoice = _remfilechoice; } function scr_chapter_save_file_exists(arg0) { var _exists = false; for (var i = 0; i < 3; i++) { _exists = ossafe_file_exists("filech" + string(arg0) + "_" + string(i)); if (_exists == true) break; } return _exists; } function scr_completed_chapter(arg0) { return ossafe_file_exists("filech" + string(arg0) + "_" + string(global.filechoice + 3)); } function scr_completed_chapter_any_slot(arg0) { var _file_exists = false; for (var i = 0; i < 3; i++) { if (ossafe_file_exists("filech" + string(arg0) + "_" + string(i + 3))) { _file_exists = true; break; } } return _file_exists; } function scr_get_secret_boss_result(arg0) { var fought_flag = scr_get_secret_boss_flag(arg0); return global.flag[fought_flag]; } function scr_defeated_secret_boss_any_slot(arg0) { var _fought_boss = scr_fought_secret_boss_any_slot(arg0); var _defeated = false; if (_fought_boss) { for (var i = 0; i < 3; i++) { var _slot = i; var _result = scr_get_ura_value(arg0, _slot); if (_result == 1 || _result == 3) { _defeated = true; break; } } } return _defeated; } function scr_spared_secret_boss_any_slot(arg0) { var _fought_boss = scr_fought_secret_boss_any_slot(arg0); var _spared = false; if (_fought_boss) { for (var i = 0; i < 3; i++) { var _slot = i; var _result = scr_get_ura_value(arg0, _slot); if (_result >= 2) { _spared = true; break; } } } return _spared; } function scr_fought_secret_boss(arg0) { return scr_get_secret_boss_result(arg0) > 0; } function scr_fought_secret_boss_any_slot(arg0) { var _fought = false; for (var i = 0; i < 3; i++) { var _slot = i; var _result = scr_get_ura_value(arg0, _slot); if (_result > 0) { _fought = true; ...
()
2
{
3
    _remfilechoice = global.filechoice;
4
    global.filechoice += 3;
5
    scr_set_ini_value(global.chapter, global.filechoice, "SideB", scr_sideb_active());
6
    
scr_save
scr_save

function
scr_save()
{
scr_saveprocess(global.filechoice);
filechoicebk2 = global.filechoice; global.filechoice = 9;
scr_saveprocess(9);
global.filechoice = filechoicebk2; iniwrite = ossafe_ini_open("dr.ini"); ini_write_string(
scr_ini_chapter(global.chapter, global.filechoice), "Name", global.truename);
ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "Level", global.lv);
ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "Love", global.llv);
ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "Time", global.time);
ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "Date", date_current_datetime());
ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "Room", scr_get_id_by_room_index(room));
ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "InitLang", global.flag[912 language]);
var uraboss = 0; if (global.chapter == 1) { if (global.flag[241 JEVIL_plot] == 6) uraboss = 1; else if (global.flag[241 JEVIL_plot] == 7) uraboss = 2; } else { uraboss = scr_get_secret_boss_result(global.chapter); } ini_write_real(
scr_ini_chapter(global.chapter, global.filechoice), "UraBoss", uraboss);
ini_write_string(
scr_ini_chapter(global.chapter, global.filechoice), "Version", string(global.versionno));
ossafe_ini_close(); scr_store_ura_result(global.chapter, global.filechoice, uraboss); ossafe_ini_open("keyconfig_" + string(global.filechoice) + ".ini"); for (i = 0; i < 10; i += 1) ini_write_real("KEYBOARD_CONTROLS", string(i), global.input_k[i]); for (i = 0; i < 10; i += 1) ini_write_real("GAMEPAD_CONTROLS", string(i), global.input_g[i]); ini_write_real("SHOULDERLB_REASSIGN", "SHOULDERLB_REASSIGN", obj_gamecontroller.gamepad_shoulderlb_reassign); ossafe_ini_close(); ossafe_savedata_save(); }
();
7
    global.filechoice = _remfilechoice;
8
}
9
10
function scr_chapter_save_file_exists(arg0)
11
{
12
    var _exists = false;
13
    for (var i = 0; i < 3; i++)
14
    {
15
        _exists = ossafe_file_exists("filech" + string(arg0) + "_" + string(i));
16
        if (_exists == true)
17
            break;
18
    }
19
    return _exists;
20
}
21
22
function scr_completed_chapter(arg0)
23
{
24
    return ossafe_file_exists("filech" + string(arg0) + "_" + string(global.filechoice + 3));
25
}
26
27
function scr_completed_chapter_any_slot(arg0)
28
{
29
    var _file_exists = false;
30
    for (var i = 0; i < 3; i++)
31
    {
32
        if (ossafe_file_exists("filech" + string(arg0) + "_" + string(i + 3)))
33
        {
34
            _file_exists = true;
35
            break;
36
        }
37
    }
38
    return _file_exists;
39
}
40
41
function scr_get_secret_boss_result(arg0)
42
{
43
    var fought_flag = scr_get_secret_boss_flag(arg0);
44
    return global.flag[fought_flag];
45
}
46
47
function scr_defeated_secret_boss_any_slot(arg0)
48
{
49
    var _fought_boss = scr_fought_secret_boss_any_slot(arg0);
50
    var _defeated = false;
51
    if (_fought_boss)
52
    {
53
        for (var i = 0; i < 3; i++)
54
        {
55
            var _slot = i;
56
            var _result = scr_get_ura_value(arg0, _slot);
57
            if (_result == 1 || _result == 3)
58
            {
59
                _defeated = true;
60
                break;
61
            }
62
        }
63
    }
64
    return _defeated;
65
}
66
67
function scr_spared_secret_boss_any_slot(arg0)
68
{
69
    var _fought_boss = scr_fought_secret_boss_any_slot(arg0);
70
    var _spared = false;
71
    if (_fought_boss)
72
    {
73
        for (var i = 0; i < 3; i++)
74
        {
75
            var _slot = i;
76
            var _result = scr_get_ura_value(arg0, _slot);
77
            if (_result >= 2)
78
            {
79
                _spared = true;
80
                break;
81
            }
82
        }
83
    }
84
    return _spared;
85
}
86
87
function scr_fought_secret_boss(arg0)
88
{
89
    return scr_get_secret_boss_result(arg0) > 0;
90
}
91
92
function scr_fought_secret_boss_any_slot(arg0)
93
{
94
    var _fought = false;
95
    for (var i = 0; i < 3; i++)
96
    {
97
        var _slot = i;
98
        var _result = scr_get_ura_value(arg0, _slot);
99
        if (_result > 0)
100
        {
101
            _fought = true;
102
            break;
103
        }
104
    }
105
    return _fought;
106
}
107
108
function scr_get_secret_boss_flag(arg0)
109
{
110
    var fought_flag = 241;
111
    switch (arg0)
112
    {
113
        case 1:
114
            fought_flag = 241;
115
            break;
116
        case 2:
117
            fought_flag = 571;
118
            break;
119
        case 3:
120
            fought_flag = 1047;
121
            break;
122
        default:
123
            break;
124
    }
125
    return fought_flag;
126
}
127
128
function scr_enable_chapter_skip(arg0)
129
{
130
    var _skip_flag = 38;
131
    switch (arg0)
132
    {
133
        case 2:
134
            _skip_flag = 39;
135
            break;
136
        case 3:
137
            _skip_flag = 40;
138
            break;
139
        default:
140
            break;
141
    }
142
    global.tempflag[_skip_flag] = 1;
143
}
144
145
function scr_get_knight_total_loss_count()
146
{
147
    var _times_lost = 0;
148
    var _chapter = 3;
149
    var _fought_boss = scr_fought_secret_boss_any_slot(_chapter);
150
    if (_fought_boss)
151
    {
152
        for (var i = 0; i < 3; i++)
153
        {
154
            var _slot = i;
155
            var _result = scr_get_ura_value(_chapter, _slot);
156
            if (_result == 2)
157
                _times_lost++;
158
        }
159
    }
160
    return _times_lost;
161
}
162
163
function scr_get_knight_total_attempts()
164
{
165
    var _times_attempted = 0;
166
    var _chapter = 3;
167
    var _fought_boss = scr_fought_secret_boss_any_slot(_chapter);
168
    if (_fought_boss)
169
    {
170
        for (var i = 0; i < 3; i++)
171
        {
172
            var _slot = i;
173
            var _result = scr_get_ura_value(_chapter, _slot);
174
            if (_result > 0)
175
                _times_attempted++;
176
        }
177
    }
178
    return _times_attempted;
179
}
180
181
function scr_set_ini_value(arg0, arg1, arg2, arg3)
182
{
183
    var iniwrite = ossafe_ini_open("dr.ini");
184
    ini_write_real(
scr_ini_chapter
scr_ini_chapter

function
scr_ini_chapter(arg0, arg1)
{ if (arg0 >= 2) return "G_" + string(arg0) + "_" + string(arg1); else return "G" + string(arg1); }
(arg0, arg1), arg2, arg3);
185
    ossafe_ini_close();
186
}
187
188
function scr_get_ini_value_all_slots(arg0, arg1)
189
{
190
    var _ini_file = ossafe_ini_open("dr.ini");
191
    var _list = [];
192
    for (var i = 0; i < 6; i++)
193
    {
194
        var _slot = i;
195
        var _value = ini_read_real(
scr_ini_chapter
scr_ini_chapter

function
scr_ini_chapter(arg0, arg1)
{ if (arg0 >= 2) return "G_" + string(arg0) + "_" + string(arg1); else return "G" + string(arg1); }
(arg0, _slot), arg1, 0);
196
        _list[i][0] = _slot;
197
        _list[i][1] = _value;
198
    }
199
    ossafe_ini_close();
200
    return _list;
201
}
202
203
function scr_get_ini_value(arg0, arg1, arg2)
204
{
205
    var _ini_file = ossafe_ini_open("dr.ini");
206
    var _ini_value = ini_read_real(
scr_ini_chapter
scr_ini_chapter

function
scr_ini_chapter(arg0, arg1)
{ if (arg0 >= 2) return "G_" + string(arg0) + "_" + string(arg1); else return "G" + string(arg1); }
(arg0, arg1), arg2, 0);
207
    ossafe_ini_close();
208
    return _ini_value;
209
}
210
211
function scr_get_ura_value(arg0, arg1)
212
{
213
    var _ini_file = ossafe_ini_open("dr.ini");
214
    var _ini_value = ini_read_real("URA", string(arg0) + "_" + string(arg1), 0);
215
    ossafe_ini_close();
216
    return _ini_value;
217
}
218
219
function scr_set_ura_value(arg0, arg1, arg2)
220
{
221
    var _ini_file = ossafe_ini_open("dr.ini");
222
    var _ini_value = ini_write_real("URA", string(arg0) + "_" + string(arg1), arg2);
223
    ossafe_ini_close();
224
    return _ini_value;
225
}
226
227
function scr_store_ura_result(arg0, arg1, arg2)
228
{
229
    if (arg2 == 0)
230
        exit;
231
    var slot = arg1;
232
    if (slot > 2)
233
        slot -= 3;
234
    var current_result = scr_get_ura_value(arg0, slot);
235
    var new_result = arg2;
236
    if ((arg2 + current_result) == 3)
237
        new_result = 3;
238
    scr_set_ura_value(arg0, slot, new_result);
239
}
240
241
function scr_get_vhs_ini_value()
242
{
243
    var _ini_file = ossafe_ini_open("dr.ini");
244
    var _ini_value = ini_read_real("VHS", "watched", 0);
245
    ossafe_ini_close();
246
    return _ini_value;
247
}
248
249
function scr_set_vhs_ini_value(arg0)
250
{
251
    var iniwrite = ossafe_ini_open("dr.ini");
252
    ini_write_real("VHS", "watched", arg0);
253
    ossafe_ini_close();
254
    ossafe_savedata_save();
255
}