Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_rhythmgame_chart_Step_0

(view raw script w/o annotations or w/e)
1
if (loadsong == 1)
2
{
3
    loadsong = 2;
4
    playtimer = 0;
5
}
6
if (loadsong == 2)
7
{
8
}
9
if (obj_rhythmgame.song_initialized)
10
{
11
    if (!init)
12
    {
13
        if (instrument == 1)
14
        {
15
            if (global.chapter > 3 && !demo_mode)
16
                confidence = 0.95;
17
            debug_print("Susie's confidence at " + string(confidence) + "%");
18
        }
19
        init = true;
20
    }
21
    trackpos = obj_rhythmgame.trackpos;
22
    var timeunit = trackpos - remtrackpos[0];
23
    var averagetimeunit = ((trackpos - remtrackpos[0]) + (remtrackpos[0] - remtrackpos[1]) + (remtrackpos[1] - remtrackpos[2])) / 3;
24
    remtrackpos[4] = remtrackpos[3];
25
    remtrackpos[3] = remtrackpos[2];
26
    remtrackpos[2] = remtrackpos[1];
27
    remtrackpos[1] = remtrackpos[0];
28
    remtrackpos[0] = trackpos;
29
    var notecheckmax = -1;
30
    var notecheck = minnote;
31
    var foundnotes = 0;
32
    while (notecheck < maxnote)
33
    {
34
        notecheckmax++;
35
        if (abs(notetime[notecheck] - trackpos) < 0.12)
36
        {
37
            foundnotes = 1;
38
            targetnote[notecheckmax] = notecheck;
39
            notecheck++;
40
        }
41
        else if (auto_play == 1 && (notetime[notecheck] - trackpos) < 0)
42
        {
43
            foundnotes = 1;
44
            targetnote[notecheckmax] = notecheck;
45
            notecheck++;
46
        }
47
        else
48
        {
49
            notecheckmax--;
50
            break;
51
        }
52
    }
53
    pressedtimer[0]++;
54
    pressedtimer[1]++;
55
    buffer[0]--;
56
    buffer[1]--;
57
    hold_score = 0;
58
    if (con >= 0 && instrument == 1)
59
    {
60
        masher--;
61
        if (masher <= 0)
62
        {
63
            if (con < 3)
64
            {
65
                mash_hit = con;
66
            }
67
            else if (con == 5)
68
            {
69
                mash_hit = 0;
70
                con = 6;
71
            }
72
            else if (con == 6)
73
            {
74
                mash_hit = 1;
75
                con = 5;
76
            }
77
            else if (con == 7)
78
            {
79
                mash_hit = irandom(2);
80
            }
81
            else if (con >= 8)
82
            {
83
                mash_hit = con - 5;
84
            }
85
            masher = mash_speed;
86
        }
87
    }
88
    if (hurt_flash > 0)
89
        hurt_flash--;
90
    invc--;
91
    if (fade > 0 && fade < 1)
92
        fade -= 0.02;
93
    for (i = 0; i < 3; i++)
94
    {
95
        var checkpress = false;
96
        var holdpress = false;
97
        if (mash_hit == i && !auto_play)
98
        {
99
            if (fade > 0)
100
            {
101
                miss_timer = 10;
102
                if (fade == 1)
103
                {
104
                    with (obj_rhythmgame)
105
                    {
106
                        missnotecon = 1;
107
                        if (fame > 3000)
108
                            fixed_penalty = 200;
109
                        else if (song_id == 1)
110
                            fixed_penalty = 100;
111
                        else
112
                            fixed_penalty = -1;
113
                    }
114
                    missnotecon = 1;
115
                }
116
                if (obj_rhythmgame.song_id != 1)
117
                    snd_play_volume(rhythm_battle_snare, clamp01(fade));
118
            }
119
            checkpress = true;
120
            if (v_ex("performer"))
121
            {
122
                if (mash_hit == 0)
123
                    performer.sprite_index = spr_susie_drum_play;
124
                if (mash_hit == 1)
125
                    performer.sprite_index = spr_susie_drum_play_right;
126
                if (mash_hit == 2)
127
                    performer.sprite_index = spr_susie_drum_play_mid;
128
                if (mash_hit == 3)
129
                    performer.sprite_index = spr_susie_drumsticks;
130
                if (mash_hit == 4)
131
                    performer.sprite_index = spr_susie_drumsticks_2;
132
                with (performer)
133
                    event_user(0);
134
            }
135
            mash_hit = -1;
136
        }
137
        if (hold_end[i] > 0)
138
        {
139
            if (hold_end[i] < trackpos || (!holdpress && !auto_play))
140
            {
141
                if (trackpos >= hold_start[i])
142
                {
143
                    var chainPoints = (floor(((min(hold_end[i], trackpos) - hold_start[i]) / meter) * 40) * 10) + 50;
144
                    rhythmgame.total_score += chainPoints;
145
                    score_scale = 4;
146
                    rhythmgame.total_fame += chainPoints;
147
                    if (instrument == 2)
148
                        performer.sprite_index = performer.idle;
149
                    if (fade == 1)
150
                    {
151
                        if (instrument == 2)
152
                        {
153
                            with (rhythmgame)
154
                            {
155
                                var _fame_increase = (song_id == 0 && trackpos < 37.56) ? 100 : 0;
156
                                fame = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(fame, max_fame, _fame_increase);
157
                            }
158
                        }
159
                        combo++;
160
                    }
161
                }
162
                hold_end[i] = 0;
163
            }
164
            else if (trackpos >= hold_start[i])
165
            {
166
                if (score_scale < 2.5)
167
                    score_scale += 0.4;
168
                if (note_hit_timer[i] <= 1)
169
                    note_hit_timer[i] = 3;
170
            }
171
        }
172
        if (checkpress && buffer[i] <= 0)
173
        {
174
            note_hit_timer[i] = 5;
175
            pressedtimer[i] = 0;
176
            buffer[i] = 2;
177
        }
178
        var _simul = 0;
179
        var _play_note = auto_play;
180
        if (foundnotes == 1 && confidence < 1)
181
            _play_note = random(1) < power(confidence, combo + 1);
182
        if ((pressedtimer[i] < (room_speed / 10) || _play_note) && foundnotes == 1 && fade == 1)
183
        {
184
            for (var notei = 0; notei <= notecheckmax; notei++)
185
            {
186
                if (notetype[targetnote[notei]] == i && notealive[targetnote[notei]] == 1)
187
                {
188
                    var leniency = 1.6;
189
                    if (auto_play)
190
                    {
191
                        if (notetime[targetnote[notei]] <= (trackpos + averagetimeunit))
192
                        {
193
                            notescore[targetnote[notei]] = 100;
194
                            if (instrument == 2 && noteend[targetnote[notei]] > 0)
195
                                performer.sprite_index = performer.mid;
196
                            if (instrument == 1)
197
                            {
198
                                if (auto_play && (tenna_boss || (i_ex(obj_rhythmgame) && obj_rhythmgame.freeplay)))
199
                                {
200
                                    if (_simul == 1)
201
                                    {
202
                                        performer.sprite_index = spr_susie_drum_play;
203
                                        _simul++;
204
                                    }
205
                                    else if (noteanim[targetnote[notei]] == 1)
206
                                    {
207
                                        if (i == 0)
208
                                            performer.sprite_index = spr_susie_drum_play;
209
                                        if (i == 1)
210
                                            performer.sprite_index = spr_susie_drum_play_mid;
211
                                    }
212
                                    else
213
                                    {
214
                                        if (i == 0)
215
                                            performer.sprite_index = spr_susie_drum_play_mid;
216
                                        if (i == 1)
217
                                            performer.sprite_index = spr_susie_drum_play_right;
218
                                        _simul++;
219
                                    }
220
                                }
221
                                with (performer)
222
                                    event_user(0);
223
                            }
224
                        }
225
                        else
226
                        {
227
                            break;
228
                        }
229
                    }
230
                    else if (abs(notetime[targetnote[notei]] - trackpos) < (averagetimeunit * leniency))
231
                    {
232
                        notescore[targetnote[notei]] = 100;
233
                    }
234
                    else if (abs(notetime[targetnote[notei]] - trackpos) < (averagetimeunit * leniency * 1.5))
235
                    {
236
                        notescore[targetnote[notei]] = 60;
237
                    }
238
                    else
239
                    {
240
                        notescore[targetnote[notei]] = 40;
241
                    }
242
                    rhythmgame.total_score += notescore[targetnote[notei]];
243
                    rhythmgame.total_fame += notescore[targetnote[notei]];
244
                    score_scale = min(4, score_scale + (notescore[targetnote[notei]] / 100));
245
                    if (notescore[targetnote[notei]] >= 40 && noteend[targetnote[notei]] > 0)
246
                    {
247
                        hold_start[i] = notetime[targetnote[notei]];
248
                        hold_end[i] = noteend[targetnote[notei]];
249
                        if (instrument == 2)
250
                            clapping = false;
251
                    }
252
                    else if (notescore[targetnote[notei]] >= 40)
253
                    {
254
                        if (fade == 1)
255
                            combo++;
256
                        if (instrument == 2)
257
                            clapping = true;
258
                    }
259
                    if (notescore[targetnote[notei]] > 0)
260
                    {
261
                        if (auto_play)
262
                        {
263
                            if (instrument == 2)
264
                            {
265
                                note_hit_timer[0] = 0;
266
                                note_hit_timer[1] = 0;
267
                                note_hit_timer[2] = 0;
268
                                note_hit_timer[i] = 3;
269
                            }
270
                            note_hit_timer[i] = 5;
271
                        }
272
                        note_streak++;
273
                    }
274
                    notealive[targetnote[notei]] = 0;
275
                }
276
            }
277
        }
278
    }
279
    if (missnotecon == 1)
280
    {
281
        missnotecon = 0;
282
        combo = 0;
283
        invc = 60;
284
        if (fade >= 1)
285
            hurt_flash = 6;
286
    }
287
}