Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_attackpress_Draw_0

(view raw script w/o annotations or w/e)
1
if (global.chapter == 3 && instance_exists(obj_knight_enemy) && obj_knight_enemy.end_cutscene_version > 0)
2
    exit;
3
if (global.chapter == 3 && instance_exists(obj_elnina_lanino_rematch_controller))
4
{
5
    if (!i_ex(obj_elnina_rematch_enemy) && !i_ex(obj_lanino_rematch_enemy))
6
    {
7
        instance_destroy();
8
        exit;
9
    }
10
}
11
maxdelaytimer += 1;
12
if (spelluse == 1)
13
{
14
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() > 0)
15
    {
16
        for (xyz = 0; xyz < 3; xyz += 1)
17
        {
18
            if (maxdelaytimer == spelldelay[xyz])
19
            {
20
                if (charitem[xyz] == 1)
21
                {
22
                    with (global.charinstance[xyz])
23
                        state = 4;
24
                }
25
                if (charspell[xyz] == 1)
26
                {
27
                    with (global.charinstance[xyz])
28
                        state = 2;
29
                }
30
            }
31
        }
32
    }
33
}
34
if (maxdelaytimer >= maxdelay)
35
    active = 1;
36
if (active == 1)
37
{
38
    for (i = 0; i < 3; i += 1)
39
    {
40
        if (havechar[0] == 1 || havechar[1] == 1 || havechar[2] == 1)
41
        {
42
            draw_set_color(bcolor);
43
            if (i == 1 || i == 2)
44
                draw_rectangle(x + 77, y + (38 * i), x + 300, y + (38 * i) + 1, false);
45
        }
46
        if (global.char[i] != 0 && global.charauto[global.char[i]] == 0 && havechar[i] == 1)
47
        {
48
            draw_set_color(bcolor);
49
            j = global.char[i];
50
            fullbox = 0;
51
            if (j == 1)
52
            {
53
                draw_set_color(c_blue);
54
                if (pressbuffer[1] > 0)
55
                    draw_set_color(merge_color(c_blue, c_white, pressbuffer[1] / 5));
56
            }
57
            if (j == 2)
58
            {
59
                draw_set_color(c_purple);
60
                if (pressbuffer[2] > 0)
61
                    draw_set_color(merge_color(c_purple, c_white, pressbuffer[2] / 5));
62
            }
63
            if (j == 3)
64
            {
65
                draw_set_color(c_green);
66
                if (pressbuffer[3] > 0)
67
                    draw_set_color(merge_color(c_green, c_white, pressbuffer[3] / 5));
68
            }
69
            if (j == 4)
70
            {
71
                draw_set_color(c_yellow);
72
                if (pressbuffer[2] > 0)
73
                    draw_set_color(merge_color(c_yellow, c_white, pressbuffer[2] / 5));
74
            }
75
            draw_rectangle(x + 78, y + (38 * i), x + 80 + (15 * boltspeed), y + (38 * i) + 36, true);
76
            draw_rectangle(x + 79, y + (38 * i) + 2, (x + 80 + (15 * boltspeed)) - 1, y + (38 * i) + 35, true);
77
            draw_sprite(spr_pressfront, j - 1, x, y + (38 * i));
78
            if (global.flag[13 use_old_attack] == 0)
79
                draw_sprite(spr_pressfront_b, 0, x, y + (38 * i));
80
            if (global.flag[13 use_old_attack] == 1)
81
                draw_sprite(spr_pressfront_b, i, x, y + (38 * i));
82
            draw_sprite(spr_pressspot, j - 1, x + 80, y + (38 * i));
83
        }
84
    }
85
    boltcount[0] = 0;
86
    boltcount[1] = 0;
87
    boltcount[2] = 0;
88
    if (my_method == 1)
89
    {
90
        for (i = 0; i < bolttotal; i += 1)
91
        {
92
            offset = boltchar[i];
93
            if ((boltframe[i] - boltx) < -5)
94
                boltalive[i] = 0;
95
            boltalpha = 1;
96
            if ((boltframe[i] - boltx) < 0)
97
            {
98
                boltalpha = 1 + ((boltframe[i] - boltx) / 3);
99
            }
100
            else if (imagetimer == 0 && boltalive[i] == 1)
101
            {
102
                img = instance_create((x + 80 + (boltframe[i] * boltspeed)) - (boltx * boltspeed), y + (38 * offset), obj_afterimage);
103
                with (img)
104
                {
105
                    sprite_index = spr_attackspot;
106
                    image_alpha = 0.4;
107
                }
108
            }
109
            if (boltalive[i] == 1)
110
            {
111
                draw_sprite_ext(spr_attackspot, 0, (x + 80 + (boltframe[i] * boltspeed)) - (boltx * boltspeed), y + (38 * offset), 1, 1, 0, c_white, boltalpha);
112
                boltcount[boltchar[i]] += 1;
113
            }
114
        }
115
        for (i = 0; i < 3; i += 1)
116
        {
117
            if (boltcount[i] == 0 && havechar[i] == 1 && attacked[i] == 0)
118
            {
119
                attacked[i] = 1;
120
                target = i;
121
                event_user(1);
122
            }
123
        }
124
    }
125
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() > 0)
126
    {
127
        if (global.flag[13 use_old_attack] == 1)
128
        {
129
            if (button1_p() && havechar[0] == 1)
130
                
scr_boltcheck
scr_boltcheck

function
scr_boltcheck(arg0)
{ pressbuffer[global.char[arg0]] = 5; qualifybolt = -1; close = 99; topclose = 99; for (i = 0; i < bolttotal; i += 1) { if (boltchar[i] == arg0 && boltalive[i] == 1) { close = boltframe[i] - boltx; if (close < 15 && close > -5) { if (close < topclose) { topclose = close; qualifybolt = i; } } } } if (qualifybolt != -1) { p = abs(topclose); burstbolt = instance_create((x + 80 + (boltframe[qualifybolt] * boltspeed)) - (boltx * boltspeed), y + (38 * arg0), obj_burstbolt); if (p == 0) { points[arg0] += 150; with (burstbolt) image_blend = c_yellow; with (burstbolt) mag = 0.2; } if (p == 1) points[arg0] += 120; if (p == 2) points[arg0] += 110; if (p >= 3) { points[arg0] += 100 - (abs(topclose) * 2); burstbolt.image_blend = boltcolor[arg0]; } if (p >= 15) burstbolt.image_blend = charcolor[arg0]; boltalive[qualifybolt] = 0; } }
(0);
131
            if (button2_p() && havechar[1] == 1)
132
                
scr_boltcheck
scr_boltcheck

function
scr_boltcheck(arg0)
{ pressbuffer[global.char[arg0]] = 5; qualifybolt = -1; close = 99; topclose = 99; for (i = 0; i < bolttotal; i += 1) { if (boltchar[i] == arg0 && boltalive[i] == 1) { close = boltframe[i] - boltx; if (close < 15 && close > -5) { if (close < topclose) { topclose = close; qualifybolt = i; } } } } if (qualifybolt != -1) { p = abs(topclose); burstbolt = instance_create((x + 80 + (boltframe[qualifybolt] * boltspeed)) - (boltx * boltspeed), y + (38 * arg0), obj_burstbolt); if (p == 0) { points[arg0] += 150; with (burstbolt) image_blend = c_yellow; with (burstbolt) mag = 0.2; } if (p == 1) points[arg0] += 120; if (p == 2) points[arg0] += 110; if (p >= 3) { points[arg0] += 100 - (abs(topclose) * 2); burstbolt.image_blend = boltcolor[arg0]; } if (p >= 15) burstbolt.image_blend = charcolor[arg0]; boltalive[qualifybolt] = 0; } }
(1);
133
            if (button3_p() && havechar[2] == 1)
134
                
scr_boltcheck
scr_boltcheck

function
scr_boltcheck(arg0)
{ pressbuffer[global.char[arg0]] = 5; qualifybolt = -1; close = 99; topclose = 99; for (i = 0; i < bolttotal; i += 1) { if (boltchar[i] == arg0 && boltalive[i] == 1) { close = boltframe[i] - boltx; if (close < 15 && close > -5) { if (close < topclose) { topclose = close; qualifybolt = i; } } } } if (qualifybolt != -1) { p = abs(topclose); burstbolt = instance_create((x + 80 + (boltframe[qualifybolt] * boltspeed)) - (boltx * boltspeed), y + (38 * arg0), obj_burstbolt); if (p == 0) { points[arg0] += 150; with (burstbolt) image_blend = c_yellow; with (burstbolt) mag = 0.2; } if (p == 1) points[arg0] += 120; if (p == 2) points[arg0] += 110; if (p >= 3) { points[arg0] += 100 - (abs(topclose) * 2); burstbolt.image_blend = boltcolor[arg0]; } if (p >= 15) burstbolt.image_blend = charcolor[arg0]; boltalive[qualifybolt] = 0; } }
(2);
135
        }
136
        else if (button1_p())
137
        {
138
            
scr_boltcheck_onebutton
scr_boltcheck_onebutton

function
scr_boltcheck_onebutton()
{ dualbolt = -1; dualboltid = -1; pressbuffer[0] = 5; pressbuffer[1] = 5; pressbuffer[2] = 5; pressbuffer[3] = 5; qualifybolt = -1; close = 99; topclose = 999; for (i = 0; i < bolttotal; i += 1) { if (boltalive[i] == 1) { close = boltframe[i] - boltx; if (close < 15 && close > -5) { if (close == topclose) { dualbolt = 1; dualboltid = i; } if (close < topclose) { topclose = close; qualifybolt = i; } } } } if (qualifybolt != -1) { bc = boltchar[qualifybolt]; p = abs(topclose); burstbolt = instance_create((x + 80 + (boltframe[qualifybolt] * boltspeed)) - (boltx * boltspeed), y + (38 * bc), obj_burstbolt); if (p == 0) { points[bc] += 150; with (burstbolt) image_blend = c_yellow; with (burstbolt) mag = 0.2; } if (p == 1) points[bc] += 120; if (p == 2) points[bc] += 110; if (p >= 3) { points[bc] += 100 - (abs(topclose) * 2); burstbolt.image_blend = boltcolor[bc]; } if (p >= 15) burstbolt.image_blend = charcolor[bc]; boltalive[qualifybolt] = 0; if (dualbolt == 1) { bc = boltchar[dualboltid]; p = abs(topclose); burstbolt = instance_create((x + 80 + (boltframe[dualboltid] * boltspeed)) - (boltx * boltspeed), y + (38 * bc), obj_burstbolt); if (p == 0) { points[bc] += 150; with (burstbolt) image_blend = c_yellow; with (burstbolt) mag = 0.2; } if (p == 1) points[bc] += 120; if (p == 2) points[bc] += 110; if (p >= 3) { points[bc] += 100 - (abs(topclose) * 2); burstbolt.image_blend = boltcolor[bc]; } if (p >= 15) burstbolt.image_blend = charcolor[bc]; boltalive[dualboltid] = 0; } } }
();
139
        }
140
    }
141
    else
142
    {
143
        fakefade = 1;
144
        if (posttimer < (timermax - 35))
145
            posttimer = timermax - 34;
146
    }
147
    imagetimer += 1;
148
    boltx += 1;
149
    pressbuffer[0] -= 1;
150
    pressbuffer[1] -= 1;
151
    pressbuffer[2] -= 1;
152
    pressbuffer[3] -= 1;
153
    if (imagetimer > 1)
154
        imagetimer = 0;
155
    goahead = 0;
156
    if (attacked[0] == 1 || havechar[0] == 0)
157
    {
158
        if (attacked[1] == 1 || havechar[1] == 0)
159
        {
160
            if (attacked[2] == 1 || havechar[2] == 0)
161
                goahead = 1;
162
        }
163
    }
164
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
165
        goahead = 1;
166
    if (goahead == 1)
167
    {
168
        posttimer += 1;
169
        if (posttimer > (timermax - 35) && haveauto == 1 && autoed == 0 && 
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() > 0)
170
        {
171
            global.charinstance[sus].points = 160;
172
            if (global.automiss[global.chartarget[sus]] == 1)
173
                global.charinstance[sus].points = 0;
174
            with (global.charinstance[sus])
175
            {
176
                state = 1;
177
                attacktimer = 0;
178
                is_auto_susie = 1;
179
            }
180
            posttimer -= 25;
181
            autoed = 1;
182
        }
183
        if (posttimer > timermax)
184
        {
185
            fade = 1;
186
            with (obj_heroparent)
187
            {
188
                if (state == 1)
189
                    state = 0;
190
                attacked = 0;
191
                itemed = 0;
192
            }
193
            techwon = 0;
194
            if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
195
                techwon = 1;
196
            if (techwon == 1)
197
                
scr_wincombat
scr_wincombat

function
scr_wincombat()
{ if (global.flag[60 dojo_next_encounter] == 0 || global.flag[36 dojo_failure] == 1) { global.myfight = 7; global.mnfight = -1; with (obj_battlecontroller) victory = 1; for (i = 0; i < 3; i += 1) { if (global.monster[i] == 1 && i_ex(global.monsterinstance[i])) { with (global.monsterinstance[i])
scr_monsterdefeat();
} } } else { for (i = 0; i < 3; i += 1) { if (global.monster[i] == 1 && i_ex(global.monsterinstance[i])) { with (global.monsterinstance[i])
scr_monsterdefeat();
} } global.encounterno = global.flag[60 dojo_next_encounter];
scr_encountersetup(global.encounterno);
global.flag[60 dojo_next_encounter] = 0; for (__j = 0; __j < 3; __j++) { if (global.monstertype[__j] != 0(None)) { _newmonster =
scr_monster_add(global.monstertype[__j], global.monsterinstancetype[__j]);
global.monsterinstance[_newmonster].x = camerax() + 800; global.monsterinstance[_newmonster].y = global.monstermakey[__j]; with (global.monsterinstance[_newmonster])
scr_move_to_point_over_time(global.monstermakex[myself], global.monstermakey[myself], 10);
} } global.myfight = 5; myfightreturntimer = 15; global.mnfight = -1; } }
();
198
            if (techwon == 0)
199
            {
200
                if (global.mnfight != 1.5 && global.mnfight != 2)
201
                    global.mnfight = 1;
202
                global.myfight = -1;
203
            }
204
        }
205
    }
206
    if (fade == 1 || fakefade == 1)
207
    {
208
        fadeamt += 0.08;
209
        draw_set_color(c_black);
210
        draw_set_alpha(fadeamt);
211
        draw_rectangle(x - 1, y, x + 640, y + 300, false);
212
        draw_set_alpha(1);
213
        if (fade == 1)
214
        {
215
            if (fadeamt > 1)
216
                instance_destroy();
217
        }
218
    }
219
}