Deltarune (Chapter 3) 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
    trackpos = obj_rhythmgame.trackpos;
12
    var timeunit = trackpos - remtrackpos[0];
13
    var averagetimeunit = ((trackpos - remtrackpos[0]) + (remtrackpos[0] - remtrackpos[1]) + (remtrackpos[1] - remtrackpos[2])) / 3;
14
    remtrackpos[4] = remtrackpos[3];
15
    remtrackpos[3] = remtrackpos[2];
16
    remtrackpos[2] = remtrackpos[1];
17
    remtrackpos[1] = remtrackpos[0];
18
    remtrackpos[0] = trackpos;
19
    var notecheckmax = -1;
20
    var notecheck = minnote;
21
    var foundnotes = 0;
22
    while (notecheck < maxnote)
23
    {
24
        notecheckmax++;
25
        if (abs(notetime[notecheck] - trackpos) < 0.12)
26
        {
27
            foundnotes = 1;
28
            targetnote[notecheckmax] = notecheck;
29
            notecheck++;
30
        }
31
        else if (auto_play == 1 && (notetime[notecheck] - trackpos) < 0)
32
        {
33
            foundnotes = 1;
34
            targetnote[notecheckmax] = notecheck;
35
            notecheck++;
36
        }
37
        else
38
        {
39
            notecheckmax--;
40
            break;
41
        }
42
    }
43
    pressedtimer[0]++;
44
    pressedtimer[1]++;
45
    buffer[0]--;
46
    buffer[1]--;
47
    hold_score = 0;
48
    if (con >= 0 && instrument == 1)
49
    {
50
        masher -= rhythmgame.pitch;
51
        if (masher <= 0)
52
        {
53
            if (con < 3)
54
            {
55
                mash_hit = con;
56
            }
57
            else if (con == 5)
58
            {
59
                mash_hit = 0;
60
                con = 6;
61
            }
62
            else if (con == 6)
63
            {
64
                mash_hit = 1;
65
                con = 5;
66
            }
67
            else if (con == 7)
68
            {
69
                mash_hit = irandom(2);
70
            }
71
            else if (con >= 8)
72
            {
73
                mash_hit = con - 5;
74
            }
75
            masher = mash_speed;
76
        }
77
    }
78
    if (hurt_flash > 0)
79
        hurt_flash--;
80
    invc--;
81
    if (fade > 0 && fade < 1)
82
        fade -= 0.02;
83
    for (i = 0; i < 3; i++)
84
    {
85
        var checkpress = false;
86
        var holdpress = false;
87
        if (mash_hit == i && !auto_play)
88
        {
89
            if (fade > 0)
90
            {
91
                miss_timer = 10;
92
                if (fade == 1)
93
                {
94
                    with (obj_rhythmgame)
95
                    {
96
                        missnotecon = 1;
97
                        if (fame > 3000)
98
                            fixed_penalty = 200;
99
                        else if (song_id == 1)
100
                            fixed_penalty = 100;
101
                        else
102
                            fixed_penalty = -1;
103
                    }
104
                    missnotecon = 1;
105
                }
106
                if (obj_rhythmgame.song_id != 1)
107
                    snd_play_x(rhythm_battle_snare, clamp01(fade), rhythmgame.pitch);
108
            }
109
            checkpress = true;
110
            if (v_ex("performer"))
111
            {
112
                if (mash_hit == 0)
113
                    performer.sprite_index = spr_susie_drum_play;
114
                if (mash_hit == 1)
115
                    performer.sprite_index = spr_susie_drum_play_right;
116
                if (mash_hit == 2)
117
                    performer.sprite_index = spr_susie_drum_play_mid;
118
                if (mash_hit == 3)
119
                    performer.sprite_index = spr_susie_drumsticks;
120
                if (mash_hit == 4)
121
                    performer.sprite_index = spr_susie_drumsticks_2;
122
                with (performer)
123
                    event_user(0);
124
            }
125
            mash_hit = -1;
126
        }
127
        if (hold_end[i] > 0)
128
        {
129
            if (hold_end[i] < trackpos || (!holdpress && !auto_play))
130
            {
131
                if (trackpos >= hold_start[i])
132
                {
133
                    var chainPoints = (floor(((min(hold_end[i], trackpos) - hold_start[i]) / meter) * 40) * 10) + 50;
134
                    rhythmgame.total_score += chainPoints;
135
                    score_scale = 4;
136
                    rhythmgame.total_fame += chainPoints;
137
                    if (instrument == 2)
138
                        performer.sprite_index = performer.idle;
139
                    if (fade == 1)
140
                    {
141
                        if (instrument == 2)
142
                        {
143
                            with (rhythmgame)
144
                            {
145
                                var _fame_increase = (song_id == 0 && trackpos < 37.56) ? 100 : 0;
146
                                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);
147
                            }
148
                        }
149
                        combo++;
150
                    }
151
                }
152
                hold_end[i] = 0;
153
            }
154
            else if (trackpos >= hold_start[i])
155
            {
156
                if (score_scale < 2.5)
157
                    score_scale += 0.4;
158
                if (note_hit_timer[i] <= 1)
159
                    note_hit_timer[i] = 3;
160
            }
161
        }
162
        if (checkpress && buffer[i] <= 0)
163
        {
164
            note_hit_timer[i] = 5;
165
            pressedtimer[i] = 0;
166
            buffer[i] = 2;
167
        }
168
        if ((pressedtimer[i] < (room_speed / 10) || auto_play) && foundnotes == 1 && fade == 1)
169
        {
170
            for (var notei = 0; notei <= notecheckmax; notei++)
171
            {
172
                if (notetype[targetnote[notei]] == i && notealive[targetnote[notei]] == 1)
173
                {
174
                    var leniency = 1.6;
175
                    if (auto_play)
176
                    {
177
                        if (notetime[targetnote[notei]] <= (trackpos + averagetimeunit))
178
                        {
179
                            notescore[targetnote[notei]] = 100;
180
                            if (instrument == 2)
181
                                performer.sprite_index = performer.mid;
182
                            if (instrument == 1)
183
                            {
184
                                if (auto_play && (tenna_boss || (i_ex(obj_rhythmgame) && obj_rhythmgame.freeplay)))
185
                                {
186
                                    if (i == 0)
187
                                        performer.sprite_index = spr_susie_drum_play_mid;
188
                                    if (i == 1)
189
                                        performer.sprite_index = spr_susie_drum_play;
190
                                }
191
                                with (performer)
192
                                    event_user(0);
193
                            }
194
                        }
195
                        else
196
                        {
197
                            break;
198
                        }
199
                    }
200
                    else if (abs(notetime[targetnote[notei]] - trackpos) < (averagetimeunit * leniency))
201
                    {
202
                        notescore[targetnote[notei]] = 100;
203
                    }
204
                    else if (abs(notetime[targetnote[notei]] - trackpos) < (averagetimeunit * leniency * 1.5))
205
                    {
206
                        notescore[targetnote[notei]] = 60;
207
                    }
208
                    else
209
                    {
210
                        notescore[targetnote[notei]] = 40;
211
                    }
212
                    rhythmgame.total_score += notescore[targetnote[notei]];
213
                    rhythmgame.total_fame += notescore[targetnote[notei]];
214
                    score_scale = min(4, score_scale + (notescore[targetnote[notei]] / 100));
215
                    if (notescore[targetnote[notei]] >= 40 && noteend[targetnote[notei]] > 0)
216
                    {
217
                        hold_start[i] = notetime[targetnote[notei]];
218
                        hold_end[i] = noteend[targetnote[notei]];
219
                    }
220
                    else if (notescore[targetnote[notei]] >= 40)
221
                    {
222
                        if (fade == 1)
223
                            combo++;
224
                    }
225
                    if (notescore[targetnote[notei]] > 0)
226
                    {
227
                        if (auto_play)
228
                        {
229
                            if (instrument == 2)
230
                            {
231
                                note_hit_timer[0] = 0;
232
                                note_hit_timer[1] = 0;
233
                                note_hit_timer[2] = 0;
234
                                note_hit_timer[i] = 3;
235
                            }
236
                            note_hit_timer[i] = 5;
237
                        }
238
                        note_streak++;
239
                    }
240
                    notealive[targetnote[notei]] = 0;
241
                }
242
            }
243
        }
244
    }
245
    if (missnotecon == 1)
246
    {
247
        missnotecon = 0;
248
        combo = 0;
249
        invc = 60;
250
        if (fade >= 1)
251
            hurt_flash = 6;
252
    }
253
}