Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_board_enemy_black_deer_Step_0

(view raw script w/o annotations or w/e)
1
scr_board_enemy_step_init
scr_board_enemy_step_init

function
scr_board_enemy_step_init()
{ if (state == "init") state = "move"; }
();
2
if (toriel == true && controlled == false)
3
{
4
}
5
else
6
{
7
    
scr_board_enemy_sword_collision
scr_board_enemy_sword_collision

function
scr_board_enemy_sword_collision()
{ var deer_following = false; if (object_index == obj_board_enemy_deer && follow == true) deer_following = true; if (place_meeting(x, y, obj_board_swordhitbox) && hurttimer == 0 && obj_board_controller.kris_object.swordlv >= sword_immunity_lv && deer_following == false) { var hitbox = instance_place(x, y, obj_board_swordhitbox); if (hitbox.detectiononly == true) { with (obj_mainchara_board) { if (swordbuffer <= 0) { swordbuffer = 8; canfreemove = 0; snd_play(choose(snd_board_sword1, snd_board_sword2, snd_board_sword3)); } } } else if ((object_index == obj_board_enemy_monster && image_blend == c_gray) || (object_index == obj_board_enemy_bluebird && room == room_board_dungeon_2)) { snd_stop(snd_board_sword_metal); snd_play(snd_board_sword_metal); hitdir = -1; hurttimer = 10; } else { path_end(); hurttimer = 10; snd_stop(snd_board_damage); snd_play(snd_board_damage); active_hitbox = false; hitdir = obj_board_controller.kris_object.facing; if (hp != 999) hp--; } } if (place_meeting(x, y, obj_board_enemy_deer_ice_spell) && object_index != obj_board_enemy_deer) { snd_stop(snd_board_splash); snd_play(snd_board_splash); if (object_index != obj_board_enemy_bluefish && object_index != obj_board_enemy_yellowflower) { block = instance_create(x, y, obj_pushableblock_board); block.sprite_index = spr_board_pushableblock_ice; block.custom_sprite = spr_board_pushableblock_ice; block.image_xscale = 1; block.image_yscale = 1; var x_cell = floor(block.x / global.cell_size); var y_cell = floor((block.y + 18) / global.cell_size); var position_x = (x_cell * global.cell_size) + (global.cell_size / 2); var position_y = (y_cell * global.cell_size) + (global.cell_size / 2); block.x = position_x - 16; block.y = position_y - 16; var count = 6; for (var i = 0; i < count; i++) { var fx =
scr_board_marker((block.x + 16) - 2, (block.y + 16) - 2, spr_board_snowflake, 0.3, 100000, 2);
fx.direction = ((360 / count) * i) + 45; fx.speed = 8; fx.friction = 0.6;
scr_doom(fx, 10);
fx =
scr_board_marker((block.x + 16) - 2, (block.y + 16) - 2, spr_board_snowflake, 0.3, 100000, 2);
fx.direction = (360 / count) * i; fx.speed = 4; fx.friction = 0.3;
scr_doom(fx, 10);
} } else { var count = 6; for (var i = 0; i < count; i++) { var fx =
scr_board_marker((x + 16) - 2, (y + 16) - 2, spr_board_snowflake, 0.3, 100000, 2);
fx.direction = ((360 / count) * i) + 45; fx.speed = 8; fx.friction = 0.6;
scr_doom(fx, 10);
fx =
scr_board_marker((x + 16) - 2, (y + 16) - 2, spr_board_snowflake, 0.3, 100000, 2);
fx.direction = (360 / count) * i; fx.speed = 4; fx.friction = 0.3;
scr_doom(fx, 10);
} } instance_destroy(); if (spawnerid != -1 && i_ex(spawnerid)) { if (object_index != obj_board_enemy_yellowflower && object_index != obj_board_enemy_bluefish) spawnerid.image_index = 20; else safe_delete(spawnerid); } } if (place_meeting(x, y, obj_board_swordhitbox) && hurttimer == 0 && obj_board_controller.kris_object.swordlv < sword_immunity_lv && deer_following == false) { snd_stop(snd_board_sword_metal); snd_play(snd_board_sword_metal); ...
();
8
}
9
scr_depth_board
scr_depth_board

function
scr_depth_board()
{ depth = 1000000 - ((y * 10) + ((sprite_height - sprite_yoffset) * 10)); } function scr_board_depth() {
scr_depth_board();
}
();
10
scr_board_enemy_hurt_state
scr_board_enemy_hurt_state

function
scr_board_enemy_hurt_state()
{ if (hurttimer > 0) { hurttimer--; active_hitbox = false; if (hurttimer == 0 && hp != maxhp) active_hitbox = true; if (hurttimer == 9 && hp <= 0) { splash = instance_create_depth(centerx(), centery(), depth - 2, obj_board_enemydefeatsplash); splash.depth = depth - 1; global.flag[1255 sword_route_kills]++; obj_board_controller.kris_object.xp += xp_given; instance_destroy(); var a = true; if (object_index == obj_board_enemy_monster && hp == 999) a = false; if (spawnerid != -1 && i_ex(spawnerid) && a == true) { with (spawnerid) instance_destroy(); } if (drop_candy == true) { var drop_rate = 5; if (obj_board_controller.kris_object.myhealth < 8) drop_rate += 20; if (obj_board_controller.kris_object.myhealth < 3) drop_rate += 30; if (obj_board_controller.kris_object.myhealth == obj_board_controller.kris_object.maxhealth) drop_rate = 0; if (irandom(100) < drop_rate || (obj_board_controller.kris_object.monstersdefeated >= 6 && drop_rate > 0) || (obj_board_controller.kris_object.monstersdefeated >= 3 && obj_board_controller.kris_object.myhealth < 3 && drop_rate > 0)) { splash.drop_candy = true; obj_board_controller.kris_object.monstersdefeated = 0; } else { obj_board_controller.kris_object.monstersdefeated++; } } } var dontmove = false; if (object_index == obj_board_enemy_lizard && movecon == 3) dontmove = true; if (hurttimer > 6 && dontmove == false) { if (hitdir == 0) { repeat (20) { if (!place_meeting(x, y + 1, obj_board_solid)) y += 1; else break; } } if (hitdir == 1) { repeat (20) { if (!place_meeting(x + 1, y, obj_board_solid)) x += 1; else break; } } if (hitdir == 2) { repeat (20) { if (!place_meeting(x, y - 1, obj_board_solid)) y -= 1; else break; } } if (hitdir == 3) { repeat (20) { if (!place_meeting(x - 1, y, obj_board_solid)) x -= 1; else break; } } } } if (object_index == obj_board_enemy_lizard && movecon == 3) { if (x < 160) x = 160; if (x > 448) x = 448; if (y < 0) y = 0; if (y > 256) y = 256; } ...
();
11
if (hp < 1)
12
{
13
    obj_mainchara_board.abouttoregaincontrol = true;
14
    with (obj_board_puzzle_wall)
15
        con = 1;
16
    snd_play(snd_impact);
17
}
18
if (abouttoregaincontrol == true)
19
{
20
    if (!left_h() && !right_h() && !up_h() && !down_h())
21
    {
22
        abouttoregaincontrol = false;
23
        controlled = 1;
24
    }
25
}
26
if (controlled == 1)
27
{
28
    var _index = false;
29
    if (place_meeting(x - 30, y, obj_mainchara_board) && !i_ex(obj_board_swordhitbox))
30
    {
31
        with (obj_mainchara_board)
32
        {
33
            swordhitbox = instance_create(x, y, obj_board_swordhitbox);
34
            swordhitbox.facing = 1;
35
            swordhitbox.swordlv = swordlv;
36
            swordhitbox.parentid = id;
37
            swordhitbox.detectiononly = true;
38
            swordfacing = 1;
39
        }
40
    }
41
    else if (place_meeting(x, y - 30, obj_mainchara_board) && !i_ex(obj_board_swordhitbox))
42
    {
43
        with (obj_mainchara_board)
44
        {
45
            swordhitbox = instance_create(x, y, obj_board_swordhitbox);
46
            swordhitbox.facing = 0;
47
            swordhitbox.swordlv = swordlv;
48
            swordhitbox.parentid = id;
49
            swordhitbox.detectiononly = true;
50
            swordfacing = 0;
51
        }
52
    }
53
    nopress = 0;
54
    if (press_d == 0 && press_l == 0 && press_u == 0 && press_r == 0)
55
        nopress = 1;
56
    press_l = 0;
57
    press_r = 0;
58
    press_d = 0;
59
    press_u = 0;
60
    press_1 = 0;
61
    press_2 = 0;
62
    if (left_h())
63
        press_l = 1;
64
    if (right_h())
65
        press_r = 1;
66
    if (up_h())
67
        press_u = 1;
68
    if (down_h())
69
        press_d = 1;
70
    if (button1_p())
71
        press_1 = 1;
72
    if (button2_p())
73
        press_2 = 1;
74
    px = 0;
75
    py = 0;
76
    pressdir = -1;
77
    if (press_r == 1)
78
    {
79
        px = wspeed;
80
        pressdir = 1;
81
    }
82
    if (press_l == 1)
83
    {
84
        px = -wspeed;
85
        pressdir = 3;
86
    }
87
    if (press_d == 1)
88
    {
89
        py = wspeed;
90
        pressdir = 0;
91
    }
92
    if (press_u == 1)
93
    {
94
        py = -wspeed;
95
        pressdir = 2;
96
    }
97
    if (nopress == 1 && pressdir != -1)
98
        facing = pressdir;
99
    if (facing == 2)
100
    {
101
        if (press_d == 1)
102
            facing = 0;
103
        if (press_u == 0 && pressdir != -1)
104
            facing = pressdir;
105
    }
106
    if (facing == 0)
107
    {
108
        if (press_u == 1)
109
            facing = 2;
110
        if (press_d == 0 && pressdir != -1)
111
            facing = pressdir;
112
    }
113
    if (facing == 3)
114
    {
115
        if (press_r == 1)
116
            facing = 1;
117
        if (press_l == 0 && pressdir != -1)
118
            facing = pressdir;
119
    }
120
    if (facing == 1)
121
    {
122
        if (press_l == 1)
123
            facing = 3;
124
        if (press_r == 0 && pressdir != -1)
125
            facing = pressdir;
126
    }
127
    nopress = 0;
128
    xmeet = 0;
129
    ymeet = 0;
130
    xymeet = 0;
131
    var lenient_x = px;
132
    var lenient_y = py;
133
    var on_top_of_ice_block = false;
134
    if (place_meeting(x + px, y + py, obj_board_solid))
135
        xymeet = 1;
136
    if (place_meeting(x + px, y, obj_board_solid))
137
    {
138
        var block = instance_place(x + px, y, obj_board_solid);
139
        if (block.object_index == obj_pushableblock_board && block.jello == true)
140
        {
141
        }
142
        else
143
        {
144
            if (place_meeting(x + px, y, obj_board_solid))
145
            {
146
                for (g = wspeed; g > 0; g -= 1)
147
                {
148
                    mvd = 0;
149
                    if (press_d == 0 && !place_meeting(x + px, y - g, obj_board_solid))
150
                    {
151
                        y -= g;
152
                        _index = true;
153
                        py = 0;
154
                        break;
155
                        mvd = 1;
156
                    }
157
                    if (press_u == 0 && mvd == 0 && !place_meeting(x + px, y + g, obj_board_solid))
158
                    {
159
                        y += g;
160
                        _index = true;
161
                        py = 0;
162
                        break;
163
                    }
164
                }
165
            }
166
            xmeet = 1;
167
            bkx = 0;
168
            if (px > 0)
169
            {
170
                for (i = px; i >= 0; i -= 1)
171
                {
172
                    if (!place_meeting(x + i, y, obj_board_solid))
173
                    {
174
                        px = i;
175
                        bkx = 1;
176
                        break;
177
                    }
178
                }
179
            }
180
            if (px < 0)
181
            {
182
                for (i = px; i <= 0; i += 1)
183
                {
184
                    if (!place_meeting(x + i, y, obj_board_solid))
185
                    {
186
                        px = i;
187
                        bkx = 1;
188
                        break;
189
                    }
190
                }
191
            }
192
            if (bkx == 0)
193
                px = 0;
194
        }
195
    }
196
    if (place_meeting(x, y + py, obj_board_solid))
197
    {
198
        var block = instance_place(x, y + py, obj_board_solid);
199
        if (block.object_index == obj_pushableblock_board && block.jello == true)
200
        {
201
        }
202
        else
203
        {
204
            ymeet = 1;
205
            bky = 0;
206
            if (place_meeting(x, y + py, obj_board_solid))
207
            {
208
                for (g = wspeed; g > 0; g -= 1)
209
                {
210
                    mvd = 0;
211
                    if (press_r == 0 && !place_meeting(x - g, y + py, obj_board_solid))
212
                    {
213
                        x -= g;
214
                        _index = true;
215
                        px = 0;
216
                        break;
217
                        mvd = 1;
218
                    }
219
                    if (mvd == 0 && press_l == 0 && !place_meeting(x + g, y + py, obj_board_solid))
220
                    {
221
                        x += g;
222
                        _index = true;
223
                        px = 0;
224
                        break;
225
                    }
226
                }
227
            }
228
            if (py > 0)
229
            {
230
                for (i = py; i >= 0; i -= 1)
231
                {
232
                    if (!place_meeting(x, y + i, obj_board_solid))
233
                    {
234
                        py = i;
235
                        bky = 1;
236
                        break;
237
                    }
238
                }
239
            }
240
            if (py < 0)
241
            {
242
                for (i = py; i <= 0; i += 1)
243
                {
244
                    if (!place_meeting(x, y + i, obj_board_solid))
245
                    {
246
                        py = i;
247
                        bky = 1;
248
                        break;
249
                    }
250
                }
251
            }
252
            if (bky == 0)
253
                py = 0;
254
        }
255
    }
256
    if (place_meeting(x + px, y + py, obj_board_solid))
257
    {
258
        var block = instance_place(x + px, y + py, obj_board_solid);
259
        if (block.object_index == obj_pushableblock_board && block.jello == true)
260
        {
261
        }
262
        else
263
        {
264
            xymeet = 1;
265
            bkxy = 0;
266
            i = px;
267
            j = py;
268
            while (j != 0 || i != 0)
269
            {
270
                if (!place_meeting(x + i, y + j, obj_board_solid))
271
                {
272
                    px = i;
273
                    py = j;
274
                    bkxy = 1;
275
                    break;
276
                }
277
                if (abs(j) >= 1)
278
                {
279
                    if (j > 0)
280
                        j -= 1;
281
                    if (j < 0)
282
                        j += 1;
283
                }
284
                else
285
                {
286
                    j = 0;
287
                }
288
                if (abs(i) >= 1)
289
                {
290
                    if (i > 0)
291
                        i -= 1;
292
                    if (i < 0)
293
                        i += 1;
294
                }
295
                else
296
                {
297
                    i = 0;
298
                }
299
            }
300
            if (bkxy == 0)
301
            {
302
                px = 0;
303
                py = 0;
304
            }
305
        }
306
    }
307
    var lenient_amount = 8;
308
    if (px == 0 && lenient_y == 0 && lenient_x > 0)
309
    {
310
        var colllide_count = 0;
311
        for (i = 0; i <= 16; i += 1)
312
        {
313
            if (position_meeting(x + 32, (y + 32) - i, obj_board_solid))
314
                colllide_count = i;
315
        }
316
        if (colllide_count <= lenient_amount)
317
        {
318
            y -= wspeed;
319
            _index = true;
320
        }
321
        colllide_count = 0;
322
        for (i = 0; i <= 16; i += 1)
323
        {
324
            if (position_meeting(x + 32, y + 16 + i, obj_board_solid))
325
                colllide_count = i;
326
        }
327
        if (colllide_count <= lenient_amount)
328
        {
329
            y += wspeed;
330
            _index = true;
331
        }
332
    }
333
    if (px == 0 && lenient_y == 0 && lenient_x < 0)
334
    {
335
        var colllide_count = 0;
336
        for (i = 0; i <= 16; i += 1)
337
        {
338
            if (position_meeting(x - 1, (y + 32) - i, obj_board_solid))
339
                colllide_count = i;
340
        }
341
        if (colllide_count <= lenient_amount)
342
        {
343
            y -= wspeed;
344
            _index = true;
345
        }
346
        colllide_count = 0;
347
        for (i = 0; i <= 16; i += 1)
348
        {
349
            if (position_meeting(x - 1, y + 16 + i, obj_board_solid))
350
                colllide_count = i;
351
        }
352
        if (colllide_count <= lenient_amount)
353
        {
354
            y += wspeed;
355
            _index = true;
356
        }
357
    }
358
    if (py == 0 && lenient_x == 0 && lenient_y > 0)
359
    {
360
        lenient_amount = 12;
361
        var colllide_count = 0;
362
        for (i = 0; i <= 32; i += 1)
363
        {
364
            if (position_meeting((x + 32) - i, y + 32, obj_board_solid))
365
                colllide_count = i;
366
        }
367
        if (colllide_count <= lenient_amount)
368
        {
369
            x -= wspeed;
370
            _index = true;
371
        }
372
        colllide_count = 0;
373
        for (i = 0; i <= 32; i += 1)
374
        {
375
            if (position_meeting(x + i, y + 32, obj_board_solid))
376
                colllide_count = i;
377
        }
378
        if (colllide_count <= lenient_amount)
379
        {
380
            x += wspeed;
381
            _index = true;
382
        }
383
        lenient_amount = 8;
384
    }
385
    if (py == 0 && lenient_x == 0 && lenient_y < 0)
386
    {
387
        var colllide_count = 0;
388
        for (i = 0; i <= 32; i += 1)
389
        {
390
            if (position_meeting((x + 32) - i, y, obj_board_solid))
391
                colllide_count = i;
392
        }
393
        if (colllide_count <= lenient_amount)
394
        {
395
            x -= wspeed;
396
            _index = true;
397
        }
398
        colllide_count = 0;
399
        for (i = 0; i <= 32; i += 1)
400
        {
401
            if (position_meeting(x + i, y, obj_board_solid))
402
                colllide_count = i;
403
        }
404
        if (colllide_count <= lenient_amount)
405
        {
406
            x += wspeed;
407
            _index = true;
408
        }
409
    }
410
    x += px;
411
    y += py;
412
    if (px != 0 || py != 0)
413
        image_index += 0.125;
414
}
415
if (x < 128)
416
    x = 128;
417
if (x > 480)
418
    x = 480;
419
if (y < 64)
420
    y = 64;
421
if (y > 288)
422
    y = 288;