Deltarune (Chapter 4) 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
        if (havechar[0] == 1 || havechar[1] == 1 || havechar[2] == 1)
31
        {
32
            draw_set_color(bcolor);
33
            if (i == 1 || i == 2)
34
                ossafe_fill_rectangle(x + 77, y + (38 * i), x + 300, y + (38 * i) + 1, false);
35
        }
36
        if (global.char[i] != 0 && global.charauto[global.char[i]] == 0 && havechar[i] == 1)
37
        {
38
            draw_set_color(bcolor);
39
            j = global.char[i];
40
            fullbox = 0;
41
            if (j == 1)
42
            {
43
                draw_set_color(c_blue);
44
                if (pressbuffer[1] > 0)
45
                    draw_set_color(merge_color(c_blue, c_white, pressbuffer[1] / 5));
46
            }
47
            if (j == 2)
48
            {
49
                draw_set_color(c_purple);
50
                if (pressbuffer[2] > 0)
51
                    draw_set_color(merge_color(c_purple, c_white, pressbuffer[2] / 5));
52
            }
53
            if (j == 3)
54
            {
55
                draw_set_color(c_green);
56
                if (pressbuffer[3] > 0)
57
                    draw_set_color(merge_color(c_green, c_white, pressbuffer[3] / 5));
58
            }
59
            if (j == 4)
60
            {
61
                draw_set_color(c_yellow);
62
                if (pressbuffer[2] > 0)
63
                    draw_set_color(merge_color(c_yellow, c_white, pressbuffer[2] / 5));
64
            }
65
            ossafe_fill_rectangle(x + 78, y + (38 * i) + 1, x + 80 + (15 * boltspeed), y + (38 * i) + 36, true);
66
            ossafe_fill_rectangle(x + 79, y + (38 * i) + 2, (x + 80 + (15 * boltspeed)) - 1, y + (38 * i) + 35, true);
67
            draw_sprite(spr_pressfront, j - 1, x, y + (38 * i));
68
            if (global.flag[13 use_old_attack] == 0)
69
                draw_sprite(spr_pressfront_b, 0, x, y + (38 * i));
70
            if (global.flag[13 use_old_attack] == 1)
71
                draw_sprite(spr_pressfront_b, i, x, y + (38 * i));
72
            draw_sprite(spr_pressspot, j - 1, x + 80, y + (38 * i));
73
        }
74
    }
75
    boltcount[0] = 0;
76
    boltcount[1] = 0;
77
    boltcount[2] = 0;
78
    if (my_method == 1)
79
    {
80
        for (i = 0; i < bolttotal; i += 1)
81
        {
82
            offset = boltchar[i];
83
            if ((boltframe[i] - boltx) < -5)
84
                boltalive[i] = 0;
85
            boltalpha = 1;
86
            if ((boltframe[i] - boltx) < 0)
87
            {
88
                boltalpha = 1 + ((boltframe[i] - boltx) / 3);
89
            }
90
            else if (imagetimer == 0 && boltalive[i] == 1)
91
            {
92
                img = instance_create((x + 80 + (boltframe[i] * boltspeed)) - (boltx * boltspeed), y + (38 * offset), obj_afterimage);
93
                with (img)
94
                {
95
                    sprite_index = spr_attackspot;
96
                    image_alpha = 0.4;
97
                }
98
            }
99
            if (boltalive[i] == 1)
100
            {
101
                draw_sprite_ext(spr_attackspot, 0, (x + 80 + (boltframe[i] * boltspeed)) - (boltx * boltspeed), y + (38 * offset), 1, 1, 0, c_white, boltalpha);
102
                boltcount[boltchar[i]] += 1;
103
            }
104
        }
105
        for (i = 0; i < 3; i += 1)
106
        {
107
            if (boltcount[i] == 0 && havechar[i] == 1 && attacked[i] == 0)
108
            {
109
                attacked[i] = 1;
110
                target = i;
111
                event_user(1);
112
            }
113
        }
114
    }
115
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() > 0)
116
    {
117
        if (global.flag[13 use_old_attack] == 1)
118
        {
119
            if (button1_p() && havechar[0] == 1)
120
                
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 (i_ex(obj_hammer_of_justice_enemy))
scr_tensionheal(6);
} 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);
121
            if (button2_p() && havechar[1] == 1)
122
                
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 (i_ex(obj_hammer_of_justice_enemy))
scr_tensionheal(6);
} 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);
123
            if (button3_p() && havechar[2] == 1)
124
                
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 (i_ex(obj_hammer_of_justice_enemy))
scr_tensionheal(6);
} 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);
125
        }
126
        else if (button1_p())
127
        {
128
            
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; } } }
();
129
        }
130
    }
131
    else
132
    {
133
        fakefade = 1;
134
        if (posttimer < (timermax - 35))
135
            posttimer = timermax - 34;
136
    }
137
    imagetimer += 1;
138
    boltx += 1;
139
    pressbuffer[0] -= 1;
140
    pressbuffer[1] -= 1;
141
    pressbuffer[2] -= 1;
142
    pressbuffer[3] -= 1;
143
    if (imagetimer > 1)
144
        imagetimer = 0;
145
    goahead = 0;
146
    if (attacked[0] == 1 || havechar[0] == 0)
147
    {
148
        if (attacked[1] == 1 || havechar[1] == 0)
149
        {
150
            if (attacked[2] == 1 || havechar[2] == 0)
151
                goahead = 1;
152
        }
153
    }
154
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
155
        goahead = 1;
156
    if (goahead == 1)
157
    {
158
        posttimer += 1;
159
        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)
160
        {
161
            global.charinstance[sus].points = 160;
162
            if (global.automiss[global.chartarget[sus]] == 1)
163
                global.charinstance[sus].points = 0;
164
            with (global.charinstance[sus])
165
            {
166
                state = 1;
167
                attacktimer = 0;
168
                is_auto_susie = 1;
169
            }
170
            posttimer -= 25;
171
            autoed = 1;
172
        }
173
        if (posttimer > timermax)
174
        {
175
            fade = 1;
176
            with (obj_heroparent)
177
            {
178
                if (state == 1)
179
                    state = 0;
180
                attacked = 0;
181
                itemed = 0;
182
            }
183
            techwon = 0;
184
            if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 0)
185
                techwon = 1;
186
            if (techwon == 1)
187
                
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; } }
();
188
            if (techwon == 0)
189
            {
190
                if (global.mnfight != 1.5 && global.mnfight != 2)
191
                    global.mnfight = 1;
192
                global.myfight = -1;
193
            }
194
        }
195
    }
196
    if (fade == 1 || fakefade == 1)
197
    {
198
        fadeamt += 0.08;
199
        draw_set_color(c_black);
200
        draw_set_alpha(fadeamt);
201
        ossafe_fill_rectangle(x - 1, y, x + 640, y + 300, false);
202
        draw_set_alpha(1);
203
        if (fade == 1)
204
        {
205
            if (fadeamt > 1)
206
                instance_destroy();
207
        }
208
    }
209
}