Deltarune (Chapter 1) script viewer

← back to main script listing

gml_Object_obj_attackpress_Draw_0

(view raw script w/o annotations or w/e)
1
maxdelaytimer += 1;
2
if (spelluse == 1)
3
{
4
    if (scr_monsterpop
scr_monsterpop

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

function scr_monsterpop() { return global.monster[0] + global.monster[1] + global.monster[2]; }
() > 0)
106
    {
107
        if (global.flag[13 use_old_attack] == 1)
108
        {
109
            if (button1_p() && havechar[0] == 1)
110
                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);
111
            if (button2_p() && havechar[1] == 1)
112
                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);
113
            if (button3_p() && havechar[2] == 1)
114
                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);
115
        }
116
        else if (button1_p())
117
        {
118
            scr_boltcheck_onebutton
scr_boltcheck_onebutton

function scr_boltcheck_onebutton() { dualbolt = -1; dualboltid = -1; pressbuffer[0] = 5; pressbuffer[1] = 5; pressbuffer[2] = 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; } } }
(0);
119
        }
120
    }
121
    else
122
    {
123
        fakefade = 1;
124
        if (posttimer < (timermax - 35))
125
            posttimer = timermax - 34;
126
    }
127
    imagetimer += 1;
128
    boltx += 1;
129
    pressbuffer[0] -= 1;
130
    pressbuffer[1] -= 1;
131
    pressbuffer[2] -= 1;
132
    if (imagetimer > 1)
133
        imagetimer = 0;
134
    goahead = 0;
135
    if (attacked[0] == 1 || havechar[0] == 0)
136
    {
137
        if (attacked[1] == 1 || havechar[1] == 0)
138
        {
139
            if (attacked[2] == 1 || havechar[2] == 0)
140
                goahead = 1;
141
        }
142
    }
143
    if (scr_monsterpop
scr_monsterpop

function scr_monsterpop() { return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
144
        goahead = 1;
145
    if (goahead == 1)
146
    {
147
        posttimer += 1;
148
        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)
149
        {
150
            global.charinstance[sus].points = 160;
151
            if (global.automiss[global.chartarget[sus]] == 1)
152
                global.charinstance[sus].points = 0;
153
            with (global.charinstance[sus])
154
            {
155
                state = 1;
156
                attacktimer = 0;
157
                is_auto_susie = 1;
158
            }
159
            posttimer -= 25;
160
            autoed = 1;
161
        }
162
        if (posttimer > timermax)
163
        {
164
            fade = 1;
165
            with (obj_heroparent)
166
            {
167
                if (state == 1)
168
                    state = 0;
169
                attacked = 0;
170
                itemed = 0;
171
            }
172
            techwon = 0;
173
            if (scr_monsterpop
scr_monsterpop

function scr_monsterpop() { return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
174
                techwon = 1;
175
            if (techwon == 0)
176
            {
177
                global.mnfight = 1;
178
                global.myfight = -1;
179
            }
180
            else
181
            {
182
                scr_wincombat
scr_wincombat

function scr_wincombat() { global.myfight = 7; global.mnfight = -1; with (obj_battlecontroller) victory = 1; for (i = 0; i < 3; i += 1) { if (global.monster[i] == 1 && instance_exists(global.monsterinstance[i])) { with (global.monsterinstance[i]) scr_monsterdefeat(); } } }
();
183
            }
184
        }
185
    }
186
    if (fade == 1 || fakefade == 1)
187
    {
188
        fadeamt += 0.08;
189
        draw_set_color(c_black);
190
        draw_set_alpha(fadeamt);
191
        draw_rectangle(x - 1, y - 1, x + 640, y + 300, false);
192
        draw_set_alpha(1);
193
        if (fade == 1)
194
        {
195
            if (fadeamt > 1)
196
                instance_destroy();
197
        }
198
    }
199
}