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