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