Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_spearshot_Other_10

(view raw script w/o annotations or w/e)
1
if (!i_ex(obj_heart))
2
{
3
    instance_destroy();
4
    exit;
5
}
6
if (redhammer)
7
{
8
    if (x < (camerax() - 30))
9
        instance_destroy();
10
    if (x > (camerax() + camerawidth() + 30))
11
        instance_destroy();
12
    if (y < (cameray() - 30))
13
        instance_destroy();
14
    if (y > (cameray() + cameraheight() + 30))
15
        instance_destroy();
16
}
17
if (!i_ex(obj_spearblocker))
18
    exit;
19
debug_message(string(id) + "is calling event user zero");
20
var shielddir = obj_spearblocker.image_angle + 180;
21
if (shielddir >= 360)
22
    shielddir -= 360;
23
var breakshield = false;
24
var shieldradius, shieldlength;
25
if (obj_spearblocker.diagonal_enabled == false)
26
{
27
    shieldlength = 50;
28
    shieldradius = 36;
29
}
30
if (obj_spearblocker.diagonal_enabled == true)
31
{
32
    shieldlength = 30;
33
    shieldradius = 46;
34
}
35
longnotebeingheld = false;
36
var parryradius = shieldradius;
37
if (bouncespear == 1 && hp == 1)
38
    shieldradius -= 30;
39
if (bouncespear == 2 && bouncespearcon == 2 && sprite_index == spr_bounce_shell_hit_center)
40
    shieldradius += 10;
41
if (longspear == 1 && obj_spearblocker.diagonal_enabled == false)
42
    shieldradius += 5;
43
if (redhammer)
44
    shieldradius += 15;
45
var dontblockshell = false;
46
if (bouncespear == 1 && (len > 36 || distance_to_point(obj_heart.x + 10, obj_heart.y + 10) > 36))
47
    dontblockshell = true;
48
if (bouncespear == 2 && (len > 46 || distance_to_point(obj_heart.x + 10, obj_heart.y + 10) > 46))
49
    dontblockshell = true;
50
if (bouncespear > 0 && (shakeduration > 0 || (bouncespearcon == 2 && fakespeed < 0)))
51
    dontblockshell = true;
52
if (len < shieldradius && dontblockshell == false && ((abs(angle_difference(image_angle, shielddir)) < shieldlength && bouncespear != 2) || (abs(angle_difference(direction, shielddir)) < shieldlength && bouncespear == 2)))
53
{
54
    if (redhammer == 1)
55
    {
56
        breakshield = true;
57
    }
58
    else if (longspear == 1)
59
    {
60
        longnotebeingheld = true;
61
        len = shieldradius;
62
        x = obj_spearblocker.x + lengthdir_x(len, direction + 180);
63
        y = obj_spearblocker.y + lengthdir_y(len, direction + 180);
64
        exit;
65
    }
66
    else
67
    {
68
        if (i_ex(obj_sound_of_justice_enemy))
69
        {
70
            if (image_angle == 0)
71
                snd_play(snd_soundbattle_leftblock);
72
            if (image_angle == 270)
73
                snd_play(snd_soundbattle_upblock);
74
            if (image_angle == 180)
75
                snd_play(snd_soundbattle_rightblock);
76
            if (image_angle == 90)
77
                snd_play(snd_soundbattle_downblock);
78
        }
79
        if (obj_spearblocker.just > 0)
80
        {
81
            if (i_ex(obj_sound_of_justice_enemy))
82
                
scr_tensionheal
scr_tensionheal

function
scr_tensionheal(arg0)
{ if (i_ex(obj_jackenstein_enemy) && global.tempflag[89] >= 3) global.tension += ceil(arg0 * 1.5); else global.tension += arg0; if (global.tension > global.maxtension) global.tension = global.maxtension; }
(2.5);
83
            else
84
                
scr_tensionheal
scr_tensionheal

function
scr_tensionheal(arg0)
{ if (i_ex(obj_jackenstein_enemy) && global.tempflag[89] >= 3) global.tension += ceil(arg0 * 1.5); else global.tension += arg0; if (global.tension > global.maxtension) global.tension = global.maxtension; }
(2.5);
85
            var xx = 0;
86
            var yy = 0;
87
            if (image_angle == 0)
88
            {
89
                xx = -68;
90
                yy -= 35;
91
            }
92
            if (image_angle == 90)
93
                yy = 32;
94
            if (image_angle == 180)
95
            {
96
                xx = 68;
97
                yy -= 35;
98
            }
99
            if (image_angle == 270)
100
                yy = -64;
101
            if (image_angle == 35 || image_angle == 45)
102
            {
103
                xx = -63;
104
                yy = 17;
105
            }
106
            if (image_angle == 135 || image_angle == 135)
107
            {
108
                xx = 53;
109
                yy = 24;
110
            }
111
            if (image_angle == 215 || image_angle == 225)
112
            {
113
                xx = 65;
114
                yy = -49;
115
            }
116
            if (image_angle == 305 || image_angle == 315)
117
            {
118
                xx = -56;
119
                yy = -56;
120
            }
121
            if (bouncespear > 0 && hp > 1)
122
            {
123
                if (i_ex(obj_sound_of_justice_enemy))
124
                    snd_play_x(snd_parry_fast_nodelay, 0.4, 1);
125
                else
126
                    snd_play(snd_parry_fast_nodelay);
127
                obj_spearblocker.parryflashtimer = 6;
128
                spinindex = 0;
129
            }
130
            else
131
            {
132
                snd_play(snd_bell_bounce_short);
133
            }
134
            obj_spearblocker.justflash = 1.8;
135
            with (obj_spearblocker)
136
                event_user(1);
137
        }
138
        else
139
        {
140
            
scr_tensionheal
scr_tensionheal

function
scr_tensionheal(arg0)
{ if (i_ex(obj_jackenstein_enemy) && global.tempflag[89] >= 3) global.tension += ceil(arg0 * 1.5); else global.tension += arg0; if (global.tension > global.maxtension) global.tension = global.maxtension; }
(1.25);
141
            if (giant == 0)
142
            {
143
                if (i_ex(obj_sound_of_justice_enemy))
144
                    snd_play_x(snd_bell, 0.4, 1);
145
                else
146
                    snd_play(snd_bell);
147
            }
148
        }
149
        with (obj_spearblocker)
150
        {
151
            image_angle = idealdir;
152
            bullethitid = other;
153
            event_user(0);
154
        }
155
        if (bouncespear > 0 && hp > 1)
156
        {
157
            x3 = 0;
158
            if (shakeduration != 5)
159
                hp--;
160
            bouncespearcon = 1;
161
            savedir = direction;
162
            sprite_index = spr_bounce_shell_squish;
163
            if (bouncespear == 1)
164
                sprite_index = spr_bounce_shell_squish2;
165
            image_angle = direction;
166
            image_index = 1;
167
            len = parryradius - 5;
168
            if (bouncespear == 1)
169
                len = parryradius - 12;
170
            if (bouncespear == 2)
171
                len = parryradius - 12;
172
            x = obj_spearblocker.x + lengthdir_x(len, direction + 180);
173
            y = obj_spearblocker.y + lengthdir_y(len, direction + 180);
174
            bouncespeartimer = 0;
175
            shakeduration = 5;
176
            hitstopbounce = 1;
177
        }
178
        else
179
        {
180
            if (bouncespear == 2)
181
            {
182
                len = parryradius - 10;
183
                len = parryradius - 10;
184
                x = obj_spearblocker.x + lengthdir_x(len, direction + 180);
185
                y = obj_spearblocker.y + lengthdir_y(len, direction + 180);
186
                var scale = 0.75;
187
                if (gigashell == true)
188
                    scale = 1;
189
                anim = instance_create(x, y, obj_gerson_animation);
190
                anim.sprite_index = spr_bounce_shell_idle;
191
                anim.spinindex = spinindex - 0.5;
192
                anim.image_xscale = scale;
193
                anim.image_yscale = scale;
194
                anim.image_angle = point_direction(x, y, obj_heart.x + 10, obj_heart.y + 10);
195
                anim.image_speed = 60;
196
            }
197
            if (breakshield == 1)
198
                event_user(1);
199
            instance_destroy();
200
        }
201
        exit;
202
    }
203
}
204
var heartcollisionlen = 16;
205
if (bouncespear > 0)
206
    heartcollisionlen = 2;
207
if (bouncespearcon == 2 && sprite_index != spr_bounce_shell_hit_center)
208
    heartcollisionlen -= 10;
209
if (bouncespear == 2)
210
    heartcollisionlen += 14;
211
var hitheart = false;
212
if (len < heartcollisionlen)
213
{
214
    var a = (global.hp[2] - 30) / 250;
215
    if (a < 0)
216
        a = 0;
217
    damage = lerp(12, 90, a);
218
    if (i_ex(obj_sound_of_justice_enemy))
219
    {
220
        target = 4;
221
        damage = 67;
222
    }
223
    if (redhammer)
224
    {
225
        breakshield = true;
226
        hitheart = true;
227
        global.inv = -1;
228
        
scr_damage
scr_damage

function
scr_damage()
{ if (global.inv < 0) {
scr_damage_cache();
var __element = 0; if (variable_instance_exists(id, "element") && is_real(element)) __element = element; if (global.chapter == 4 && i_ex(obj_hammer_of_justice_enemy)) obj_hammer_of_justice_enemy.gothitlastturn++; if (global.chapter == 4 && i_ex(obj_sound_of_justice_enemy)) obj_sound_of_justice_enemy.gothitlastturn++; if (global.chapter == 4 && i_ex(obj_guei_enemy)) obj_guei_enemy.gothitthisturn = true; if (global.chapter == 4 && global.encounterno == 157 && !i_ex(obj_herosusie) && !i_ex(obj_heroralsei)) damage = round(damage * 0.7); if (global.chapter == 4 && i_ex(obj_jackenstein_enemy) && obj_jackenstein_enemy.scaredycat) damage = round(damage * 1.5); with (obj_mike_minigame_controller) hurt = true; if (target < 3) { var skipthis = false; if (global.chapter == 4) { if (i_ex(obj_climb_kris)) skipthis = true; } if (!skipthis) { if (global.hp[global.char[target]] <= 0) {
scr_randomtarget_old();
target = mytarget; with (global.charinstance[target]) { image_blend = c_white; darkify = 0; } } } } var __remtarget = -1; if (target == 4) { __remtarget = 4;
scr_randomtarget_old();
target = mytarget; var getList = array_length(global.char); if ((global.hp[global.char[target]] / global.maxhp[global.char[target]]) < (
scr_party_hpaverage() / 2))
{
scr_randomtarget_old();
target = mytarget; } if ((global.hp[global.char[target]] / global.maxhp[global.char[target]]) < (
scr_party_hpaverage() / 2))
{
scr_randomtarget_old();
target = mytarget; } if (target == 0 && (global.hp[global.char[target]] / global.maxhp[global.char[target]]) < 0.35) {
scr_randomtarget_old();
target = mytarget; } with (global.charinstance[target]) { image_blend = c_white; darkify = 0; } } chartarget = 3; if (global.chapter == 4 && i_ex(obj_titan_enemy) && obj_titan_enemy.forcehitralsei) { damage *= 0.5; if (global.hp[3] > 0) target = 2; } if (global.chapter == 4 && i_ex(obj_sound_of_justice_enemy) && obj_sound_of_justice_enemy.phase == 2) { if (global.hp[1] > 0 && global.hp[2] < (global.maxhp[2] * 0.4)) target = 0; } if (i_ex(obj_titan_enemy) || i_ex(obj_titan_spawn_enemy)) { if ((target == 0 && (global.chararmor1[1] == 23 || global.chararmor2[1] == 23)) || (target == 1 && (global.chararmor1[2] == 23 || global.chararmor2[2] == 23)) || (target == 2 && (global.chararmor1[3] == 23 || global.chararmor2[3] == 23))) damage = round(damage * 0.5); } tdamage = damage; var oldcalculation = 0; if (target < 3) { if (oldcalculation) tdamage = ceil(tdamage - (global.battledf[target] * 3)); else tdamage =
scr_damage_calculation(tdamage, target);
chartarget = global.char[target]; if (global.charaction[target] == 10) tdamage = ceil((2 * tdamage) / 3); tdamage = ceil(tdamage *
scr_element_damage_reduction(__element, global.char[target]));
debug_message("The element is: " + string(__element)); if (tdamage < 1) ...
();
229
    }
230
    else
231
    {
232
        
scr_damage
scr_damage

function
scr_damage()
{ if (global.inv < 0) {
scr_damage_cache();
var __element = 0; if (variable_instance_exists(id, "element") && is_real(element)) __element = element; if (global.chapter == 4 && i_ex(obj_hammer_of_justice_enemy)) obj_hammer_of_justice_enemy.gothitlastturn++; if (global.chapter == 4 && i_ex(obj_sound_of_justice_enemy)) obj_sound_of_justice_enemy.gothitlastturn++; if (global.chapter == 4 && i_ex(obj_guei_enemy)) obj_guei_enemy.gothitthisturn = true; if (global.chapter == 4 && global.encounterno == 157 && !i_ex(obj_herosusie) && !i_ex(obj_heroralsei)) damage = round(damage * 0.7); if (global.chapter == 4 && i_ex(obj_jackenstein_enemy) && obj_jackenstein_enemy.scaredycat) damage = round(damage * 1.5); with (obj_mike_minigame_controller) hurt = true; if (target < 3) { var skipthis = false; if (global.chapter == 4) { if (i_ex(obj_climb_kris)) skipthis = true; } if (!skipthis) { if (global.hp[global.char[target]] <= 0) {
scr_randomtarget_old();
target = mytarget; with (global.charinstance[target]) { image_blend = c_white; darkify = 0; } } } } var __remtarget = -1; if (target == 4) { __remtarget = 4;
scr_randomtarget_old();
target = mytarget; var getList = array_length(global.char); if ((global.hp[global.char[target]] / global.maxhp[global.char[target]]) < (
scr_party_hpaverage() / 2))
{
scr_randomtarget_old();
target = mytarget; } if ((global.hp[global.char[target]] / global.maxhp[global.char[target]]) < (
scr_party_hpaverage() / 2))
{
scr_randomtarget_old();
target = mytarget; } if (target == 0 && (global.hp[global.char[target]] / global.maxhp[global.char[target]]) < 0.35) {
scr_randomtarget_old();
target = mytarget; } with (global.charinstance[target]) { image_blend = c_white; darkify = 0; } } chartarget = 3; if (global.chapter == 4 && i_ex(obj_titan_enemy) && obj_titan_enemy.forcehitralsei) { damage *= 0.5; if (global.hp[3] > 0) target = 2; } if (global.chapter == 4 && i_ex(obj_sound_of_justice_enemy) && obj_sound_of_justice_enemy.phase == 2) { if (global.hp[1] > 0 && global.hp[2] < (global.maxhp[2] * 0.4)) target = 0; } if (i_ex(obj_titan_enemy) || i_ex(obj_titan_spawn_enemy)) { if ((target == 0 && (global.chararmor1[1] == 23 || global.chararmor2[1] == 23)) || (target == 1 && (global.chararmor1[2] == 23 || global.chararmor2[2] == 23)) || (target == 2 && (global.chararmor1[3] == 23 || global.chararmor2[3] == 23))) damage = round(damage * 0.5); } tdamage = damage; var oldcalculation = 0; if (target < 3) { if (oldcalculation) tdamage = ceil(tdamage - (global.battledf[target] * 3)); else tdamage =
scr_damage_calculation(tdamage, target);
chartarget = global.char[target]; if (global.charaction[target] == 10) tdamage = ceil((2 * tdamage) / 3); tdamage = ceil(tdamage *
scr_element_damage_reduction(__element, global.char[target]));
debug_message("The element is: " + string(__element)); if (tdamage < 1) ...
();
233
        if (bouncespear > 0)
234
        {
235
            x3 = 0;
236
            hp = 0;
237
            bouncespearcon = 1;
238
            savedir = direction;
239
            sprite_index = spr_bounce_shell_squish;
240
            if (bouncespear == 1)
241
                sprite_index = spr_bounce_shell_squish2;
242
            image_angle = direction;
243
            image_index = 1;
244
            len = parryradius - 5;
245
            if (bouncespear == 1)
246
                len = parryradius - 40;
247
            if (bouncespear == 2)
248
                len = parryradius - 40;
249
            if (i_ex(obj_spearblocker))
250
                x = obj_spearblocker.x + lengthdir_x(len, direction + 180);
251
            if (i_ex(obj_spearblocker))
252
                y = obj_spearblocker.y + lengthdir_y(len, direction + 180);
253
            bouncespeartimer = 0;
254
            shakeduration = 5;
255
            hitstopbounce = 1;
256
            hurtsquish = true;
257
        }
258
        if ((bouncespear > 0 && hp < 1) || bouncespear == 0)
259
        {
260
            if (breakshield == 1)
261
                event_user(1);
262
            instance_destroy();
263
        }
264
    }
265
}
266
if (breakshield == true)
267
{
268
    with (obj_heart)
269
    {
270
        anim = instance_create(x + 10, y + 10, obj_animation);
271
        anim.sprite_index = spr_finisher_explosion;
272
        anim.image_speed = 0.5;
273
        anim.image_index = 0;
274
        anim.image_xscale = 1;
275
        anim.image_yscale = 1;
276
        color = c_black;
277
        sprite_index = spr_heart;
278
        inst = instance_create(obj_heart.x, obj_heart.y, obj_gerson_fakeheart);
279
        if (other.image_angle == 0)
280
            inst.directionhit = 0;
281
        if (other.image_angle == 90)
282
            inst.directionhit = 90;
283
        if (other.image_angle == 180)
284
            inst.directionhit = 180;
285
        if (other.image_angle == 270)
286
            inst.directionhit = 270;
287
        inst.speed = 12;
288
        inst.friction = 0.6;
289
        if (hitheart == true)
290
        {
291
            with (obj_event_manager)
292
                trigger_event(UnknownEnum.Value_1);
293
        }
294
    }
295
    with (obj_spearblocker)
296
    {
297
        snd_play(snd_queen_punched_lower_heavy);
298
        piece1 = instance_create(x + lengthdir_x(32, image_angle - 35), y + lengthdir_y(32, image_angle - 35), obj_spearblocker_piece);
299
        piece1.image_angle = image_angle;
300
        piece1.image_index = 1;
301
        piece2 = instance_create(x + lengthdir_x(32, image_angle + 35), y + lengthdir_y(32, image_angle + 35), obj_spearblocker_piece);
302
        piece2.image_angle = image_angle;
303
        piece2.image_index = 0;
304
        piece3 = instance_create(x + lengthdir_x(30, 45), y + lengthdir_y(30, 45), obj_spearblocker_piece);
305
        piece3.sprite_index = spr_green_circle_piece;
306
        piece3.image_angle = 0;
307
        piece4 = instance_create(x + lengthdir_x(30, 135), y + lengthdir_y(30, 135), obj_spearblocker_piece);
308
        piece4.sprite_index = spr_green_circle_piece;
309
        piece4.image_angle = 90;
310
        piece5 = instance_create(x + lengthdir_x(30, 225), y + lengthdir_y(30, 225), obj_spearblocker_piece);
311
        piece5.sprite_index = spr_green_circle_piece;
312
        piece5.image_angle = 180;
313
        piece6 = instance_create(x + lengthdir_x(30, 315), y + lengthdir_y(30, 315), obj_spearblocker_piece);
314
        piece6.sprite_index = spr_green_circle_piece;
315
        piece6.image_angle = 270;
316
        if (other.image_angle == 0)
317
        {
318
            piece1.vspeed = -9 - random(6);
319
            piece1.hspeed = 4 + random(2);
320
            piece2.vspeed = 5 + random(6);
321
            piece2.hspeed = 4 + random(2);
322
            piece3.vspeed = -9 - random(6);
323
            piece3.hspeed = 4 + random(2);
324
            piece4.vspeed = -9 - random(6);
325
            piece4.hspeed = 4 + random(2);
326
            piece5.vspeed = 5 + random(6);
327
            piece5.hspeed = 4 + random(2);
328
            piece6.vspeed = 5 + random(6);
329
            piece6.hspeed = 4 + random(2);
330
        }
331
        if (other.image_angle == 180)
332
        {
333
            piece1.vspeed = -9 - random(6);
334
            piece1.hspeed = -4 - random(2);
335
            piece2.vspeed = 5 + random(6);
336
            piece2.hspeed = -4 - random(2);
337
            piece3.vspeed = -9 - random(6);
338
            piece3.hspeed = -4 - random(2);
339
            piece4.vspeed = -9 - random(6);
340
            piece4.hspeed = -4 - random(2);
341
            piece5.vspeed = 5 + random(6);
342
            piece5.hspeed = -4 - random(2);
343
            piece6.vspeed = 5 + random(6);
344
            piece6.hspeed = -4 - random(2);
345
        }
346
        if (other.image_angle == 270)
347
        {
348
            piece1.vspeed = 1 - random(6);
349
            piece1.hspeed = 7 + random(4);
350
            piece2.vspeed = 1 - random(6);
351
            piece2.hspeed = -7 - random(4);
352
            piece3.vspeed = 1 + random(6);
353
            piece3.hspeed = 7 + random(4);
354
            piece4.vspeed = 1 + random(6);
355
            piece4.hspeed = -7 - random(4);
356
            piece5.vspeed = 1 - random(6);
357
            piece5.hspeed = -7 - random(4);
358
            piece6.vspeed = 1 - random(6);
359
            piece6.hspeed = 7 + random(4);
360
        }
361
        if (other.image_angle == 90)
362
        {
363
            piece1.vspeed = -9 - random(3);
364
            piece1.hspeed = 7 + random(2);
365
            piece2.vspeed = -9 - random(3);
366
            piece2.hspeed = -7 + random(2);
367
            piece3.vspeed = -9 - random(3);
368
            piece3.hspeed = 7 + random(2);
369
            piece4.vspeed = -9 - random(3);
370
            piece4.hspeed = -7 + random(2);
371
            piece5.vspeed = -9 - random(3);
372
            piece5.hspeed = -7 + random(2);
373
            piece6.vspeed = -9 - random(3);
374
            piece6.hspeed = 7 + random(2);
375
        }
376
        with (obj_heart)
377
        {
378
            color = c_black;
379
            sprite_index = spr_heart;
380
        }
381
        instance_create(x, y, obj_shake);
382
        instance_destroy();
383
    }
384
}
385
386
enum UnknownEnum
387
{
388
    Value_1 = 1
389
}