Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_heart_Step_0

(view raw script w/o annotations or w/e)
1
wallcheck = 0;
2
press_l = 0;
3
press_r = 0;
4
press_d = 0;
5
press_u = 0;
6
bkx = 0;
7
bky = 0;
8
bkxy = 0;
9
jelly = 2;
10
if (left_h())
11
    press_l = 1;
12
if (right_h())
13
    press_r = 1;
14
if (up_h())
15
    press_u = 1;
16
if (down_h())
17
    press_d = 1;
18
px = 0;
19
py = 0;
20
if (canmove)
21
{
22
    if (press_r == 1)
23
        px = wspeed;
24
    if (press_l == 1)
25
        px = -wspeed;
26
    if (press_d == 1)
27
        py = wspeed;
28
    if (press_u == 1)
29
        py = -wspeed;
30
    if (button2_h() && global.flag[22 disable_x_slowing] == 0)
31
    {
32
        if (disableslow == 0)
33
        {
34
            px = ceil(px * 0.5);
35
            py = ceil(py * 0.5);
36
        }
37
    }
38
    else
39
    {
40
        disableslow = 0;
41
    }
42
}
43
if (color == 0)
44
    remove_slow_z_buffer += 0.5;
45
xmeet = 0;
46
ymeet = 0;
47
xymeet = 0;
48
if (place_meeting(x + px, y + py, obj_battlesolid))
49
    xymeet = 1;
50
if (place_meeting(x + px, y, obj_battlesolid))
51
{
52
    if (place_meeting(x + px, y, obj_battlesolid))
53
    {
54
        for (g = wspeed; g > 0; g -= 1)
55
        {
56
            mvd = 0;
57
            if (press_d == 0 && !place_meeting(x + px, y - g, obj_battlesolid))
58
            {
59
                y -= g;
60
                py = 0;
61
                break;
62
                mvd = 1;
63
            }
64
            if (press_u == 0 && mvd == 0 && !place_meeting(x + px, y + g, obj_battlesolid))
65
            {
66
                y += g;
67
                py = 0;
68
                break;
69
            }
70
        }
71
    }
72
    xmeet = 1;
73
    bkx = 0;
74
    if (px > 0)
75
    {
76
        for (i = px; i >= 0; i -= 1)
77
        {
78
            if (!place_meeting(x + i, y, obj_battlesolid))
79
            {
80
                px = i;
81
                bkx = 1;
82
                break;
83
            }
84
        }
85
    }
86
    if (px < 0)
87
    {
88
        for (i = px; i <= 0; i += 1)
89
        {
90
            if (!place_meeting(x + i, y, obj_battlesolid))
91
            {
92
                px = i;
93
                bkx = 1;
94
                break;
95
            }
96
        }
97
    }
98
    if (bkx == 0)
99
        px = 0;
100
}
101
if (place_meeting(x, y + py, obj_battlesolid))
102
{
103
    ymeet = 1;
104
    bky = 0;
105
    if (place_meeting(x, y + py, obj_battlesolid))
106
    {
107
        for (g = wspeed; g > 0; g -= 1)
108
        {
109
            mvd = 0;
110
            if (press_r == 0 && !place_meeting(x - g, y + py, obj_battlesolid))
111
            {
112
                x -= g;
113
                px = 0;
114
                break;
115
                mvd = 1;
116
            }
117
            if (mvd == 0 && press_l == 0 && !place_meeting(x + g, y + py, obj_battlesolid))
118
            {
119
                x += g;
120
                px = 0;
121
                break;
122
            }
123
        }
124
    }
125
    if (py > 0)
126
    {
127
        for (i = py; i >= 0; i -= 1)
128
        {
129
            if (!place_meeting(x, y + i, obj_battlesolid))
130
            {
131
                py = i;
132
                bky = 1;
133
                break;
134
            }
135
        }
136
    }
137
    if (py < 0)
138
    {
139
        for (i = py; i <= 0; i += 1)
140
        {
141
            if (!place_meeting(x, y + i, obj_battlesolid))
142
            {
143
                py = i;
144
                bky = 1;
145
                break;
146
            }
147
        }
148
    }
149
    if (bky == 0)
150
        py = 0;
151
}
152
if (place_meeting(x + px, y + py, obj_battlesolid))
153
{
154
    xymeet = 1;
155
    bkxy = 0;
156
    i = px;
157
    j = py;
158
    while (j != 0 || i != 0)
159
    {
160
        if (!place_meeting(x + i, y + j, obj_battlesolid))
161
        {
162
            px = i;
163
            py = j;
164
            bkxy = 1;
165
            break;
166
        }
167
        if (abs(j) >= 1)
168
        {
169
            if (j > 0)
170
                j -= 1;
171
            if (j < 0)
172
                j += 1;
173
        }
174
        else
175
        {
176
            j = 0;
177
        }
178
        if (abs(i) >= 1)
179
        {
180
            if (i > 0)
181
                i -= 1;
182
            if (i < 0)
183
                i += 1;
184
        }
185
        else
186
        {
187
            i = 0;
188
        }
189
    }
190
    if (bkxy == 0)
191
    {
192
        px = 0;
193
        py = 0;
194
    }
195
}
196
if ((x + px) >= ((__view_get(e__VW.XView, 0) + 640) - sprite_width))
197
    px = (__view_get(e__VW.XView, 0) + 640) - sprite_width - x;
198
if ((x + px) <= 0)
199
    px = -x;
200
if ((y + py) <= 0)
201
    py = -y;
202
if ((y + py) >= (((__view_get(e__VW.YView, 0) + 320) - sprite_height) + boundaryup))
203
    py = ((__view_get(e__VW.YView, 0) + 320) - sprite_height - y) + boundaryup;
204
x += px;
205
y += py;
206
if (dmgnoise == 1)
207
{
208
    dmgnoise = 0;
209
    snd_stop(snd_hurt1);
210
    snd_play(snd_hurt1);
211
}
212
global.inv -= 1;
213
if (global.inv > 0)
214
{
215
    image_speed = 0.25;
216
}
217
else
218
{
219
    image_speed = 0;
220
    image_index = 0;
221
}
222
global.heartx = (x + 2) - __view_get(e__VW.XView, 0);
223
global.hearty = (y + 2) - __view_get(e__VW.YView, 0);
224
if (color == 1)
225
{
226
    wspeed = 5;
227
    if (chargeshot_delay > 0)
228
        chargeshot_delay--;
229
    if (button1_p() || (z_hold >= 10 && z_hold <= 39 && button1_r()))
230
    {
231
        if (instance_number(obj_yheart_shot) < 3 && chargeshot_delay == 0)
232
        {
233
            instance_create(x + 10, y + 10, obj_yheart_shot);
234
            snd_play(snd_heartshot_dr_b);
235
        }
236
    }
237
    if (z_hold == 20)
238
    {
239
        chargeshot_sound = snd_loop(snd_chargeshot_charge);
240
        snd_pitch(chargeshot_sound, 0.1);
241
        snd_volume(chargeshot_sound, 0, 0);
242
        snd_volume(chargeshot_sound, 0.3, 20);
243
    }
244
    if (z_hold >= 20 && z_hold < 40)
245
        snd_pitch(chargeshot_sound, 0.1 + ((z_hold - 20) / 20));
246
    if (z_hold >= 40)
247
        image_index = 2;
248
    if (z_charge < 15)
249
        chargeshotcount = 0;
250
    if (z_hold >= 40 && button1_r())
251
    {
252
        snd_stop(chargeshot_sound);
253
        snd_play(snd_chargeshot_fire);
254
        bigshot = instance_create(x + 10, y + 10, obj_yheart_shot);
255
        bigshot.big = 1;
256
        bigshot.sprite_index = spr_yheart_bigshot;
257
        bigshot.hspeed = 4 * f;
258
        bigshot.friction = -0.2 * f;
259
        bigshot.image_alpha = 0.5;
260
        bigshot.image_xscale = 0.1;
261
        bigshot.image_yscale = 2;
262
        z_hold = 0;
263
        chargeshot_delay = 5;
264
        image_index = 0;
265
        chargeshotcount++;
266
        if (chargeshotcount > 1)
267
        {
268
            with (obj_spamton_neo_enemy)
269
                event_user(4);
270
        }
271
        if (global.chapter == 2 && instance_exists(obj_spamton_neo_enemy))
272
            obj_spamton_neo_enemy.bigshotused = 1;
273
        if (global.chapter == 2 && instance_exists(obj_spamton_neo_enemy) && obj_spamton_neo_enemy.bigshotcount > 0)
274
        {
275
            bigshot.hspeed = 10 * f;
276
            bigshot.trail = 1;
277
            obj_spamton_neo_enemy.bigshotcount--;
278
            if (obj_spamton_neo_enemy.bigshotcount == 0)
279
            {
280
                instance_create(x, y, obj_supercharge_end);
281
                snd_play(snd_stardrop);
282
                var a = random(45);
283
                repeat (8)
284
                {
285
                    part = instance_create(other.x + 10, other.y + 10, obj_yheart_sneo_particle);
286
                    part.direction = a + random(15);
287
                    part.image_xscale = 2 + random(2);
288
                    part.image_yscale = 2 + random(2);
289
                    part.speed = 16;
290
                    part.friction = 0.8;
291
                    a += 45;
292
                }
293
            }
294
            else
295
            {
296
                var a = random(45);
297
                repeat (8)
298
                {
299
                    part = instance_create(other.x + 10, other.y + 10, obj_yheart_sneo_particle);
300
                    part.direction = a + random(15);
301
                    part.speed = 8;
302
                    part.friction = 0.8;
303
                    a += 45;
304
                }
305
            }
306
        }
307
    }
308
    if (button1_h())
309
    {
310
        if (global.chapter == 2 && instance_exists(obj_spamton_neo_enemy) && obj_spamton_neo_enemy.bigshotcount > 0)
311
            z_hold_f += 1;
312
        z_hold_f += 1;
313
    }
314
    else
315
    {
316
        z_hold_f = 0;
317
        snd_stop(chargeshot_sound);
318
    }
319
    z_hold = z_hold_f * 2;
320
}
321
322
enum e__VW
323
{
324
    XView,
325
    YView,
326
    WView,
327
    HView,
328
    Angle,
329
    HBorder,
330
    VBorder,
331
    HSpeed,
332
    VSpeed,
333
    Object,
334
    Visible,
335
    XPort,
336
    YPort,
337
    WPort,
338
    HPort,
339
    Camera,
340
    SurfaceID
341
}