Deltarune (Chapter 5) script viewer

← back to main script listing

gml_GlobalScript_scr_rhythmgame_song_load

(view raw script w/o annotations or w/e)
1
function scr_rhythmgame_load_song(arg0 = 0, arg1 = true, arg2 = true, arg3 = false)
2
{
3
    
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("song loading");
4
    if (song_loaded && !arg3)
5
        scr_rhythmgame_song_reset();
6
    song_id = arg0;
7
    notetime[0] = 0;
8
    notespeed = 150;
9
    loop = false;
10
    signature = 4;
11
    signature_count = 1;
12
    signature_change = [0];
13
    signature_time = [0];
14
    bpm_time = [0];
15
    bpm_change = [0];
16
    signature_index = 0;
17
    
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("trying to load");
18
    if (arg0 == 0)
19
    {
20
        track1_id = "ch3_karaoke_no_guitar.ogg";
21
        track2_id = "ch3_karaoke_full.ogg";
22
        oneAtATime = true;
23
        dynamic_solo = true;
24
        bpm = 230;
25
        startoffset = 0;
26
        track_length = 174.26;
27
        notespacing = 60 / bpm;
28
        meter = notespacing * 4;
29
        if ((
scr_debug
scr_debug

function
scr_debug()
{ return global.debug == 1; }
() && arg3) || (v_ex("debugsong") && debugsong))
30
            trackstart = scr_round_to_beat(14.5, bpm);
31
        else
32
            trackstart = 0;
33
        timestamp[0] = scr_round_to_beat(37.56, bpm, 1) - notespacing;
34
        timestamp[1] = scr_round_to_beat(58.43, bpm, 1) - notespacing;
35
        timestamp[2] = scr_round_to_beat(79.3, bpm, 1) - notespacing;
36
        timestamp[3] = scr_round_to_beat(100.17, bpm, 1) - notespacing;
37
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading main song");
38
    }
39
    else if (arg0 == 1)
40
    {
41
        track1_id = "ch3-practice_song_noguit.ogg";
42
        track2_id = "ch3-practice_song_combined.ogg";
43
        oneAtATime = true;
44
        bpm = 75;
45
        startoffset = 0;
46
        track_length = 24;
47
        trackstart = 0;
48
        notespeed = 90;
49
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading practice song");
50
    }
51
    else if (arg0 == 2)
52
    {
53
        track1_id = "tenna_battle.ogg";
54
        track2_id = "tenna_battle_guitar.ogg";
55
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading tenna_battle");
56
        oneAtATime = false;
57
        track_length = 165.405;
58
        bpm = 148;
59
        notespeed = 120;
60
        notespacing = 60 / bpm;
61
        meter = notespacing * 4;
62
        if (i_ex(obj_rhythmgame))
63
        {
64
            if (obj_rhythmgame.tenna_boss)
65
                loop = true;
66
            else
67
                trackstart = 0 - (meter * 1);
68
        }
69
    }
70
    else if (arg0 == 3)
71
    {
72
        track1_id = "ch3_tvtime.ogg";
73
        track2_id = "ch3_tvtime_guitar.ogg";
74
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Tutorial time!");
75
        trackstart = 0;
76
        oneAtATime = true;
77
        track_length = 32.842;
78
        bpm = 190;
79
        loop = true;
80
        notespacing = 60 / bpm;
81
        meter = notespacing * 4;
82
        trackstart = 0 - meter;
83
    }
84
    else if (arg0 == 4)
85
    {
86
        track1_id = "board4_rhythm.ogg";
87
        track2_id = "board4_rhythm.ogg";
88
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading very good board 4 song");
89
        trackstart = (room == room_dw_rhythm || arg3) ? 8 : 0;
90
        oneAtATime = true;
91
        track_length = 15.265;
92
        notespeed = 30;
93
        bpm = 60;
94
    }
95
    else if (arg0 == 5)
96
    {
97
        track1_id = "rudebuster_boss.ogg";
98
        track2_id = "rudebuster_boss.ogg";
99
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Time to get FUNKY");
100
        trackstart = 0;
101
        oneAtATime = true;
102
        track_length = 143.384;
103
        bpm = 140;
104
    }
105
    else if (arg0 == 6)
106
    {
107
        track1_id = "battle_vapor.ogg";
108
        track2_id = "battle_vapor.ogg";
109
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading battle_vapor");
110
        trackstart = 7;
111
        oneAtATime = true;
112
        bpm = 200;
113
    }
114
    else if (arg0 == 7)
115
    {
116
        track1_id = "tenna_battle_old.ogg";
117
        track2_id = "tenna_battle_old.ogg";
118
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading tenna_battle_old");
119
        trackstart = 0;
120
        oneAtATime = true;
121
        track_length = 127.92;
122
        bpm = 148;
123
        notespeed = 120;
124
    }
125
    else if (arg0 == 8)
126
    {
127
        track1_id = "battle.ogg";
128
        track2_id = "battle.ogg";
129
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading Rude Buster");
130
        trackstart = 0;
131
        oneAtATime = true;
132
        track_length = 75.428;
133
        bpm = 140;
134
        notespeed = 120;
135
    }
136
    else if (arg0 == 9)
137
    {
138
        track1_id = "field_of_hopes.ogg";
139
        track2_id = "field_of_hopes.ogg";
140
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading Field of Hopes and Dreams");
141
        trackstart = 0;
142
        oneAtATime = true;
143
        track_length = 161.28;
144
        bpm = 125;
145
        notespeed = 120;
146
    }
147
    else if (arg0 == 10)
148
    {
149
        track1_id = "rhythm_knockdown_no_guit.ogg";
150
        track2_id = "rhythm_knockdown_combined.ogg";
151
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading Knock You Down!!");
152
        bpm = 195;
153
        notespacing = 60 / bpm;
154
        meter = notespacing * 4;
155
        trackstart = scr_round_to_beat(-2 * (240 / bpm), bpm);
156
        oneAtATime = true;
157
        track_length = 137.846;
158
        notespeed = 120;
159
    }
160
    else if (arg0 == 11)
161
    {
162
        track1_id = "rhythm_3rd_sanctuary_noguit.ogg";
163
        track2_id = "rhythm_3rd_sanctuary_guit.ogg";
164
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading Third Sanctuary");
165
        bpm = 170;
166
        notespeed = 60;
167
        trackstart = scr_round_to_beat(-(405 / bpm), bpm);
168
        oneAtATime = true;
169
        track_length = 129;
170
        notespeed = 120;
171
        signature = 9;
172
        scr_rhythmgame_add_time_signature(5.5, 12.7);
173
    }
174
    else if (arg0 == 12)
175
    {
176
        track1_id = "Flowerman_Arrangement.ogg";
177
        track2_id = "Flowerman_Arrangement.ogg";
178
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading Flower Man");
179
        bpm = 160;
180
        oneAtATime = true;
181
        track_length = 192.024;
182
        notespeed = 120;
183
        signature = 4;
184
    }
185
    else if (arg0 == 13)
186
    {
187
        track1_id = "pumpkin_boss.ogg";
188
        track2_id = "pumpkin_boss.ogg";
189
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading A DARK ZOAN...");
190
        bpm = 150;
191
        notespeed = 60;
192
        oneAtATime = true;
193
        track_length = 138;
194
        notespeed = 120;
195
        signature = 3;
196
        scr_rhythmgame_add_time_signature(4, 20.4);
197
        scr_rhythmgame_add_bpm(200, 20.4);
198
    }
199
    else if (arg0 == 15)
200
    {
201
        track1_id = "4rd_sanctuary_noguit.ogg";
202
        track2_id = "4rd_sanctuary.ogg";
203
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Loading 4rd Sanctuary");
204
        bpm = 200;
205
        notespeed = 120;
206
        oneAtATime = true;
207
        track_length = 79.2;
208
        notespeed = 180;
209
        signature = 9;
210
        trackstart = scr_round_to_beat(-(405 / bpm), bpm);
211
        scr_rhythmgame_add_time_signature(7, 10.8);
212
        scr_rhythmgame_add_time_signature(4.5, 12.9);
213
        scr_rhythmgame_add_time_signature(7, 14.25);
214
        scr_rhythmgame_add_time_signature(4.5, 16.35);
215
        scr_rhythmgame_add_time_signature(7, 17.7);
216
        scr_rhythmgame_add_time_signature(4.5, 19.8);
217
        scr_rhythmgame_add_time_signature(7, 21.15);
218
        scr_rhythmgame_add_time_signature(5, 23.25);
219
        scr_rhythmgame_add_time_signature(5.5, 24.75);
220
        scr_rhythmgame_add_time_signature(5, 29.7);
221
        scr_rhythmgame_add_time_signature(5.5, 31.2);
222
        scr_rhythmgame_add_time_signature(6, 37.8);
223
        scr_rhythmgame_add_time_signature(4.5, 39.6);
224
        scr_rhythmgame_add_time_signature(6, 40.95);
225
        scr_rhythmgame_add_time_signature(5.5, 42.75);
226
        scr_rhythmgame_add_time_signature(6, 44.4);
227
        scr_rhythmgame_add_time_signature(5.5, 46.2);
228
        scr_rhythmgame_add_time_signature(6, 47.85);
229
        scr_rhythmgame_add_time_signature(5.5, 49.65);
230
        scr_rhythmgame_add_time_signature(6, 51.3);
231
        scr_rhythmgame_add_time_signature(5, 53.1);
232
        scr_rhythmgame_add_time_signature(6, 54.6);
233
        scr_rhythmgame_add_time_signature(5.5, 56.4);
234
        scr_rhythmgame_add_time_signature(6, 58.05);
235
        scr_rhythmgame_add_time_signature(4, 59.85);
236
        scr_rhythmgame_add_time_signature(9, 61.05);
237
        scr_rhythmgame_add_time_signature(8.5, 66.45);
238
        scr_rhythmgame_add_time_signature(19, 69);
239
        scr_rhythmgame_add_time_signature(9, 74.7);
240
    }
241
    if (arg3)
242
    {
243
        notespacing = 60 / bpm;
244
        meter = notespacing * signature;
245
    }
246
    else if (arg0 >= 0)
247
    {
248
        with (obj_rhythmgame_chart)
249
        {
250
            signature_time = other.signature_time;
251
            signature_change = other.signature_change;
252
            signature_count = other.signature_count;
253
            bpm_count = other.bpm_count;
254
            bpm_change = other.bpm_change;
255
            bpm_time = other.bpm_time;
256
        }
257
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading da other stuff");
258
        notespacing = 60 / bpm;
259
        meter = notespacing * signature;
260
        if (arg0 == 2 || arg0 == 10)
261
            speed_modifier = 1.5;
262
        scr_rhythmgame_notechart_lead(arg0);
263
        if (tutorial > 0)
264
            scr_rhythmgame_toggle_notes(false);
265
        musicm.bpm = bpm;
266
        musicm.beat_offset += bpm / 2;
267
        if (arg1)
268
        {
269
            with (drums)
270
            {
271
                scr_rhythmgame_notechart_drums(arg0);
272
                bpm = other.bpm;
273
                signature = other.signature;
274
                notespacing = other.notespacing;
275
                meter = other.meter;
276
                loop = other.loop;
277
            }
278
        }
279
        if (arg2)
280
        {
281
            with (vocals)
282
            {
283
                scr_rhythmgame_notechart_vocals(arg0);
284
                bpm = other.bpm;
285
                signature = other.signature;
286
                notespacing = other.notespacing;
287
                meter = other.meter;
288
                loop = other.loop;
289
                if (i_ex(obj_rhythmgame) && obj_rhythmgame.tenna_boss)
290
                {
291
                    if (maxnote == 0 || chart_start > notetime[0] || (chart_start + (meter * 2)) < notetime[0])
292
                        performer.sprite_index = spr_ralsei_sing_clap;
293
                }
294
            }
295
        }
296
        scr_rhythmgame_load_events(arg0);
297
    }
298
}
299
300
function scr_rhythmgame_song_reset()
301
{
302
    timestamp = [];
303
    timestamp[0] = 0;
304
    dynamic_solo = false;
305
    track1_id = 0;
306
    track2_id = 0;
307
    song_id = -1;
308
    oneAtATime = false;
309
    bpm = 230;
310
    notespacing = 60 / bpm;
311
    meter = notespacing * 4;
312
}
313
314
function scr_rhythmgame_song_select(arg0)
315
{
316
    if (arg0 == 0)
317
    {
318
        song_id = 8;
319
        vinyl_id = 0;
320
        preview = "battle_preview.ogg";
321
        alt_preview = "battle_preview_crisp.ogg";
322
        local_preview = snd_songpreview_knockdown;
323
        chapter = 1;
324
        bpm = 140;
325
    }
326
    if (arg0 == 1)
327
    {
328
        song_id = 9;
329
        vinyl_id = 0;
330
        preview = "field_of_hopes_preview.ogg";
331
        alt_preview = "field_of_hopes_preview_crisp.ogg";
332
        local_preview = snd_songpreview_knockdown;
333
        chapter = 1;
334
        bpm = 125;
335
    }
336
    if (arg0 == 2)
337
    {
338
        song_id = 10;
339
        vinyl_id = 1;
340
        preview = "boxing_boss_preview.ogg";
341
        alt_preview = "boxing_boss_preview_crisp.ogg";
342
        local_preview = snd_songpreview_knockdown;
343
        chapter = 2;
344
        bpm = 195;
345
    }
346
    if (arg0 == 3)
347
    {
348
        song_id = 0;
349
        vinyl_id = 1;
350
        preview = "ch3_karaoke_preview.ogg";
351
        alt_preview = "ch3_karaoke_preview_crisp.ogg";
352
        local_preview = snd_songpreview_video;
353
        chapter = 3;
354
        bpm = 230;
355
    }
356
    if (arg0 == 4)
357
    {
358
        song_id = 2;
359
        vinyl_id = 1;
360
        preview = "tenna_battle_preview.ogg";
361
        alt_preview = "tenna_battle_preview_crisp.ogg";
362
        local_preview = snd_songpreview_tenna;
363
        chapter = 3;
364
        bpm = 148;
365
    }
366
    if (arg0 == 5)
367
    {
368
        song_id = 11;
369
        chapter = 4;
370
        bpm = 170;
371
    }
372
    if (arg0 == 6)
373
    {
374
        song_id = 13;
375
        chapter = 4;
376
        bpm = 150;
377
    }
378
    if (arg0 == 7)
379
    {
380
        song_id = 12;
381
        chapter = 5;
382
        bpm = 160;
383
    }
384
    if (arg0 == 9)
385
    {
386
        song_id = 15;
387
        chapter = 4;
388
        bpm = 200;
389
        local_preview = snd_songpreview_4rd;
390
    }
391
}
392
393
function scr_rhythmgame_song_select_id(arg0)
394
{
395
    if (arg0 == 0)
396
        return 8;
397
    else if (arg0 == 1)
398
        return 9;
399
    else if (arg0 == 2)
400
        return 10;
401
    else if (arg0 == 3)
402
        return 0;
403
    else if (arg0 == 4)
404
        return 2;
405
    else if (arg0 == 5)
406
        return 11;
407
    else if (arg0 == 6)
408
        return 13;
409
    else if (arg0 == 7)
410
        return 12;
411
    else if (arg0 == 8)
412
        return 14;
413
    else if (arg0 == 9)
414
        return 15;
415
}
416
417
function scr_rhythmgame_rank_scores(arg0, arg1 = 0)
418
{
419
    var _rank_scores = [14500, 18000, 22000, 25000, 28000];
420
    if (arg0 == 2)
421
        _rank_scores = [33500, 37000, 41000, 44000, 47000];
422
    if (arg0 == 10)
423
        _rank_scores = [32500, 36000, 40000, 43000, 45000];
424
    if (arg0 == 11)
425
        _rank_scores = [28000, 32000, 36500, 38500, 41000];
426
    if (arg0 == 15)
427
        _rank_scores = [15500, 18500, 21000, 22500, 24000];
428
    if (arg1 > 0)
429
    {
430
        for (var i = 0; i < 5; i++)
431
            _rank_scores[i] = (_rank_scores[i] * 1.1) - 1200;
432
    }
433
    return _rank_scores;
434
}
435
436
function scr_rhythmgame_get_rank(arg0, arg1)
437
{
438
    var _rank_scores = scr_rhythmgame_rank_scores(arg0);
439
    var _rank = 0;
440
    if (arg1 >= _rank_scores[4])
441
        return 5;
442
    for (i = 0; i < 5; i++)
443
    {
444
        if (arg1 < _rank_scores[i])
445
        {
446
            _rank = i;
447
            break;
448
        }
449
    }
450
    return _rank;
451
}
452
453
function scr_rhythmgame_add_time_signature(arg0, arg1, arg2 = true)
454
{
455
    if (signature_count == 1 && arg1 != 0)
456
    {
457
        signature_change[0] = signature;
458
        signature_time[0] = 0;
459
    }
460
    signature_change[signature_count] = arg0;
461
    var _bpm_check = scr_rhythmgame_get_bpm(arg1);
462
    signature_time[signature_count] = scr_round_to_beat(arg1, _bpm_check, 4, signature_time[signature_count - 1]);
463
    signature_count++;
464
    if (arg2)
465
    {
466
    }
467
}
468
469
function scr_rhythmgame_add_bpm(arg0, arg1, arg2 = true)
470
{
471
    if (bpm_count == 1 && arg1 != 0)
472
    {
473
        bpm_change[0] = bpm;
474
        bpm_time[0] = 0;
475
    }
476
    bpm_change[bpm_count] = arg0;
477
    bpm_time[bpm_count] = scr_round_to_beat(arg1, bpm_change[bpm_count - 1], undefined, bpm_time[bpm_count - 1]);
478
    bpm_count++;
479
    if (arg2)
480
    {
481
    }
482
}
483
484
function scr_rhythmgame_get_bpm(arg0, arg1 = 0, arg2 = false)
485
{
486
    if (bpm_count == 1)
487
        return bpm;
488
    for (var i = 1; i < bpm_count; i++)
489
    {
490
        if ((arg0 + arg1) < bpm_time[i])
491
            return bpm_change[i - 1];
492
    }
493
    return bpm_change[bpm_count - 1];
494
}
495
496
function scr_rhythmgame_get_bpm_index(arg0, arg1 = 0)
497
{
498
    if (bpm_count == 1)
499
        return bpm;
500
    for (var i = 1; i < bpm_count; i++)
501
    {
502
        if ((arg0 + arg1) < bpm_time[i])
503
            return i - 1;
504
    }
505
    return bpm_change[bpm_count - 1];
506
}
507
508
function scr_rhythmgame_get_signature(arg0, arg1 = 0)
509
{
510
    if (signature_count == 1)
511
        return signature;
512
    for (var i = 1; i < signature_count; i++)
513
    {
514
        if ((arg0 + arg1) < signature_time[i])
515
            return signature_change[i - 1];
516
    }
517
    return signature_change[signature_count - 1];
518
}
519
520
function scr_rhythmgame_get_signature_change(arg0, arg1 = true)
521
{
522
    if (signature_count <= 1)
523
        return signature;
524
    if (arg1 && signature_index < (signature_count - 1) && arg0 > signature_time[signature_index + 1])
525
        return signature_change[signature_index + 1];
526
    else if (!arg1 && signature_index > 0 && arg0 < signature_time[signature_index])
527
        return signature_change[signature_index - 1];
528
    else
529
        return signature;
530
}
531
532
function scr_rhythmgame_get_bpm_change(arg0, arg1 = true)
533
{
534
    if (bpm_count <= 1)
535
        return bpm;
536
    if (arg1 && bpm_index < (bpm_count - 1) && arg0 > bpm_time[bpm_index + 1])
537
        return bpm_change[bpm_index + 1];
538
    else if (!arg1 && bpm_index > 0 && arg0 < bpm_time[bpm_index])
539
        return bpm_change[bpm_index - 1];
540
    else
541
        return bpm;
542
}
543
544
function scr_rhythmgame_chart_update_info()
545
{
546
    var _rg = 238;
547
    signature = _rg.signature;
548
    with (obj_rhythmgame)
549
    {
550
        other.signature_change = signature_change;
551
        other.signature_count = signature_count;
552
        other.signature_index = signature_index;
553
    }
554
}
555
556
function scr_rhythmgame_toggle_notes(arg0, arg1 = true)
557
{
558
    if (arg0)
559
    {
560
        var _startpoint = scr_ceil_to_beat(trackpos + (meter * 1.5), bpm, 0.25);
561
        if (_startpoint > track_length)
562
            loop_start = _startpoint - track_length;
563
        for (i = 0; i < maxnote; i++)
564
        {
565
            if (notetime[i] < _startpoint)
566
            {
567
                continue;
568
            }
569
            else
570
            {
571
                notescore[i] = 0;
572
                notealive[i] = 1;
573
            }
574
        }
575
    }
576
    else
577
    {
578
        for (i = 0; i < maxnote; i++)
579
        {
580
            notescore[i] = arg1 ? 40 : 0;
581
            notealive[i] = 0;
582
        }
583
    }
584
}