Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_homealone_dess_closet_kris_Step_0

(view raw script w/o annotations or w/e)
1
if (heart == 0)
2
    heart = instance_find(obj_homealone_heart, 0);
3
if (i_ex(heart))
4
    hearttargetx = clamp(heart.x + 26, 144, 276);
5
if (
scr_debug
scr_debug

function
scr_debug()
{ if (global.debug == 1) return 1; }
())
6
{
7
    if (keyboard_check_pressed(ord("Q")))
8
    {
9
        santaactive[0] = 1;
10
        snd_play_volume(snd_santa_laugh, 0.6);
11
    }
12
    if (keyboard_check_pressed(ord("W")))
13
    {
14
        santaactive[1] = 1;
15
        snd_play_volume(snd_santa_laugh_low_energy, 0.6);
16
    }
17
}
18
if (attackhit == 1)
19
{
20
    if (i_ex(obj_homealone_heart))
21
    {
22
        push_velocity += 8;
23
        var velocity = push_velocity;
24
        if (abs(obj_homealone_heart.x - 110) > 4 || abs(obj_homealone_heart.y - 30) > 4)
25
        {
26
            with (obj_homealone_heart)
27
                scr_obj_movetowards_point(110, 30, velocity);
28
        }
29
        else
30
        {
31
            push_timer++;
32
            if (push_timer == 1)
33
            {
34
                with (obj_homealone_heart)
35
                {
36
                    x += 2;
37
                    
scr_minishakeobj
scr_minishakeobj

function
scr_minishakeobj()
{ shakeobj = instance_create(x, y, obj_shakeobj); shakeobj.target = id; shakeobj.shakeamt = 4; shakeobj.shakereduct = 1; with (shakeobj) event_user(0); }
();
38
                }
39
            }
40
            if (push_timer >= 4)
41
            {
42
                push_timer = 0;
43
                attackhit = 0;
44
                push_velocity = 0;
45
                global.interact = 0;
46
            }
47
        }
48
    }
49
}
50
if (is_tired)
51
    exit;
52
if (kris_ready == 0)
53
{
54
    if (pickup_stick)
55
    {
56
        animate_timer++;
57
        sprite_index = spr_noellehouse_dess_kris_hockey_pickup;
58
        image_speed = 0;
59
        image_index = (animate_timer * 0.05) % 5;
60
        if (heart.x >= 120)
61
        {
62
            kris_ready = 1;
63
            animate_timer = 0;
64
        }
65
    }
66
}
67
else if (kris_ready == 1)
68
{
69
    if (pickup_stick)
70
    {
71
        animate_timer++;
72
        if (animate_timer == 1)
73
        {
74
            sprite_index = spr_noellehouse_dess_kris_hockey_pickup;
75
            image_speed = 0;
76
            image_index = 6;
77
        }
78
        if (animate_timer == 6)
79
            image_index = 7;
80
        if (animate_timer == 11)
81
        {
82
            snd_play(snd_grab);
83
            image_index = 8;
84
            stick_marker.visible = 0;
85
        }
86
        if (animate_timer == 14)
87
            image_index = 9;
88
        if (animate_timer == 17)
89
            image_index = 10;
90
        if (animate_timer == 26)
91
        {
92
            pickup_stick = false;
93
            animate_timer = 0;
94
            kris_ready = 2;
95
        }
96
    }
97
}
98
if (kris_ready < 2)
99
    exit;
100
if (mode == 0)
101
{
102
    if (heart.y >= 44 && heart.x >= 120 && !(heart.x <= 160 && heart.y >= 50) && abs(x - hearttargetx) < 30 && santaactive[0] == 0 && santaactive[1] == 0)
103
    {
104
        attackjump = 1;
105
        if (heart.y >= 62)
106
            attackjump = 0;
107
        walkcon = -1;
108
        mode = 1;
109
        attackcon = 0;
110
        attacktimer = 0;
111
        speed = 0;
112
        gravity = 0;
113
        friction = 0;
114
    }
115
    if (attacktired > 0)
116
        attacktired -= 0.1;
117
    if (walkcon == 0)
118
    {
119
        sprite_index = spr_noellehouse_dess_kris_walk_left;
120
        walktimer++;
121
        if (santaactive[0] || santaactive[1])
122
            walktimer = walkthreshold;
123
        if (walktimer >= walkthreshold)
124
        {
125
            santawalk = -1;
126
            if (santaactive[0] == 1)
127
            {
128
                walktargetx = santax[0];
129
                santawalk = 0;
130
            }
131
            else if (santaactive[1] == 1)
132
            {
133
                walktargetx = santax[1];
134
                santawalk = 1;
135
            }
136
            else if (x >= heart.x)
137
            {
138
                walktargetx = heart.x - (4 + irandom(18));
139
            }
140
            else
141
            {
142
                walktargetx = heart.x + (4 + irandom(18));
143
            }
144
            walkcon = 1;
145
            var _distance = x - walktargetx;
146
            hspeed = -(_distance / 10);
147
            if (santawalk < 0)
148
                hspeed = clamp(hspeed, -6, 6);
149
            image_speed = abs(hspeed / 8);
150
            walktimer = irandom(3);
151
            if (santawalk >= 0)
152
                walktimer = 0;
153
            image_index = 1;
154
        }
155
    }
156
    if (walkcon == 1)
157
    {
158
        var finishedwalking = 0;
159
        walktimer++;
160
        if (walktimer >= 11)
161
            finishedwalking = 1;
162
        if (santawalk < 0 && abs(x - hearttargetx) > 30)
163
            finishedwalking = 0;
164
        if ((x <= 140 && hspeed < 0) || (x >= 280 && hspeed > 0))
165
        {
166
            finishedwalking = 1;
167
        }
168
        else if (x <= 140 || x >= 280)
169
        {
170
            if (walktimer >= 11)
171
                finishedwalking = 1;
172
        }
173
        if (finishedwalking)
174
        {
175
            hspeed = 0;
176
            image_speed = 0;
177
            image_index = 0;
178
            walktimer = irandom(10);
179
            walkcon = 0;
180
            if (santawalk >= 0)
181
            {
182
                santatimer = 0;
183
                walktimer = 0;
184
                mode = 2;
185
            }
186
        }
187
    }
188
}
189
if (mode == 1)
190
{
191
    if (attackcon == 0)
192
    {
193
        sprite_index = spr_noellehouse_dess_kris_hockey_swing_left;
194
        image_speed = 0;
195
        image_index = 0;
196
        attacktargetx = hearttargetx;
197
        var _distance = x - attacktargetx;
198
        if (abs(_distance) < 4)
199
        {
200
            attackcon = 2;
201
        }
202
        else
203
        {
204
            hspeed = -(_distance / 6);
205
            attackcon = 1;
206
            vspeed = -3;
207
            gravity = 1;
208
        }
209
    }
210
    if (attackcon == 1)
211
    {
212
        attacktimer++;
213
        if (attacktimer >= 6)
214
        {
215
            if (attackjump == 0)
216
            {
217
                friction = 2;
218
            }
219
            else
220
            {
221
                vspeed = -6 - random(1);
222
                gravity = 1;
223
                hspeed = -2;
224
            }
225
            attackcon = 2;
226
            attacktimer = 0;
227
        }
228
    }
229
    if (attackcon == 2)
230
    {
231
        attacktimer++;
232
        if (attacktimer >= 4)
233
        {
234
            attackcon = 3;
235
            attacktimer = 0;
236
            if (attackjump == 0)
237
            {
238
                hspeed = -7;
239
                friction = 1;
240
            }
241
        }
242
    }
243
    if (attackcon == 3)
244
    {
245
        if (attacktimer == 0)
246
            snd_play(snd_swing);
247
        if (gravity == 0)
248
            friction = 1;
249
        image_index += 0.5;
250
        if (image_index > 3)
251
            image_index = 3;
252
        if (image_index >= 1 && image_index < 2)
253
        {
254
            var hitHeart = 0;
255
            if (collision_rectangle(x - 10, y - 14, x + 32, y + 32, heart, 1, 1))
256
                hitHeart = 1;
257
            if (collision_rectangle(x - 22, y, x + 32, y + 20, heart, 1, 1))
258
                hitHeart = 1;
259
            if (collision_rectangle(x - 16, y - 6, x + 2, y + 2, heart, 1, 1))
260
                hitHeart = 1;
261
            if (hitHeart == 1)
262
            {
263
                if (attackhit == 0)
264
                {
265
                    attackhit = 1;
266
                    snd_play(snd_hurt1);
267
                    hearthits++;
268
                    if (hearthits == 1 || hearthits == 5 || hearthits == 10 || hearthits == 20 || hearthits == 30)
269
                        global.lhp--;
270
                    global.interact = 1;
271
                    var d = obj_homealone_heart.depth;
272
                    obj_homealone_heart.depth = 30000;
273
                    with (obj_homealone_heart)
274
                        scr_delay_var("depth", d, 18);
275
                    with (obj_event_manager)
276
                        trigger_event(UnknownEnum.Value_0, UnknownEnum.Value_8, UnknownEnum.Value_937);
277
                }
278
            }
279
        }
280
        attacktimer++;
281
        if (attacktimer >= (17 + attacktired))
282
        {
283
            attacktimer = 0;
284
            mode = 0;
285
            attack_number++;
286
            walkcon = 0;
287
            attackcon = 0;
288
            friction = 0;
289
            gravity = 0;
290
            speed = 0;
291
            if (attacktired < 10)
292
                attacktired++;
293
            attackhit = 0;
294
        }
295
    }
296
}
297
if (mode == 2)
298
{
299
    cringe = false;
300
    notice = false;
301
    sprite_index = spr_noellehouse_dess_kris_reach_stick;
302
    if (santawalk == 1)
303
        sprite_index = spr_noellehouse_dess_kris_hockey_mid_stand_left;
304
    image_speed = 0.1;
305
    santatimer++;
306
    var targetTime = 50;
307
    if (santawalk == 1)
308
        targetTime = 70;
309
    if (santatimer >= targetTime)
310
    {
311
        var type = santawalk;
312
        with (obj_homealone_dancing_santa_mini)
313
        {
314
            if (santa_type == type && is_active)
315
            {
316
                turn_on = false;
317
alarm[0]
318
            }
319
        }
320
        snd_play(snd_noise);
321
        santaactive[santawalk] = 0;
322
        santatimer = 0;
323
        mode = 0;
324
        walkcon = 0;
325
        walktimer = walkthreshold;
326
        image_index = 0;
327
        image_speed = 0;
328
    }
329
}
330
if (notice && vspeed == 0)
331
{
332
    var _emote = 
scr_marker
scr_marker

function
scr_marker(arg0, arg1, arg2)
{ thismarker = instance_create(arg0, arg1, obj_marker); with (thismarker) { sprite_index = arg2; image_speed = 0; } return thismarker; }
(x + 10, y - 10, spr_exc);
333
    
scr_doom
scr_doom

function
scr_doom(arg0 = id, arg1)
{ with (instance_create_depth(0, 0, 0, obj_doom)) { alarm[0] target = arg0; persistent = arg0.persistent; } }
(_emote, 31);
334
    notice = false;
335
    notice_mode = true;
336
    cringe_mode = false;
337
    notice_timer = 90;
338
    global.interact = 0;
339
    mode = -1;
340
    sprite_index = spr_noellehouse_dess_kris_notice;
341
    image_index = 0;
342
    image_speed = 0;
343
    hspeed = 0;
344
    
scr_shakeobj
scr_shakeobj

function
scr_shakeobj()
{ var _shakeobj = instance_create(x, y, obj_shakeobj); _shakeobj.target = id; if (argument_count >= 1) { if (i_ex(argument0)) _shakeobj.target = argument0; } if (argument_count >= 2) { if (argument1 != -1) _shakeobj.shakeamt = argument1; } if (argument_count >= 3) { if (argument2 != -1) _shakeobj.shakereduct = argument2; } with (_shakeobj) event_user(0); }
();
345
}
346
if (notice_mode)
347
{
348
    notice_timer--;
349
    if (notice_timer <= 0)
350
    {
351
        notice_mode = false;
352
        reset();
353
    }
354
}
355
if (cringe)
356
{
357
    var _emote = 
scr_marker
scr_marker

function
scr_marker(arg0, arg1, arg2)
{ thismarker = instance_create(arg0, arg1, obj_marker); with (thismarker) { sprite_index = arg2; image_speed = 0; } return thismarker; }
(x + 10, y - 10, spr_exc);
358
    
scr_doom
scr_doom

function
scr_doom(arg0 = id, arg1)
{ with (instance_create_depth(0, 0, 0, obj_doom)) { alarm[0] target = arg0; persistent = arg0.persistent; } }
(_emote, 31);
359
    cringe = false;
360
    cringe_mode = true;
361
    hspeed = 0;
362
    notice_mode = false;
363
    global.interact = 0;
364
    notice_timer = 90;
365
    mode = -1;
366
    sprite_index = spr_noellehouse_dess_kris_cringe;
367
    image_index = 0;
368
    image_speed = 0;
369
    
scr_shakeobj
scr_shakeobj

function
scr_shakeobj()
{ var _shakeobj = instance_create(x, y, obj_shakeobj); _shakeobj.target = id; if (argument_count >= 1) { if (i_ex(argument0)) _shakeobj.target = argument0; } if (argument_count >= 2) { if (argument1 != -1) _shakeobj.shakeamt = argument1; } if (argument_count >= 3) { if (argument2 != -1) _shakeobj.shakereduct = argument2; } with (_shakeobj) event_user(0); }
();
370
}
371
if (cringe_mode)
372
{
373
    notice_timer--;
374
    if (notice_timer <= 0)
375
    {
376
        cringe_mode = false;
377
        reset();
378
    }
379
}
380
if (tired_mode && attackhit == 0)
381
{
382
    if (attack_number >= 5)
383
    {
384
        tired_mode = false;
385
        is_tired = true;
386
        mode = -1;
387
        global.interact = 0;
388
        sprite_index = spr_noellehouse_dess_kris_hockey_tired;
389
        image_index = 0;
390
        image_speed = 0.1;
391
        hspeed = 0;
392
        
scr_shakeobj
scr_shakeobj

function
scr_shakeobj()
{ var _shakeobj = instance_create(x, y, obj_shakeobj); _shakeobj.target = id; if (argument_count >= 1) { if (i_ex(argument0)) _shakeobj.target = argument0; } if (argument_count >= 2) { if (argument1 != -1) _shakeobj.shakeamt = argument1; } if (argument_count >= 3) { if (argument2 != -1) _shakeobj.shakereduct = argument2; } with (_shakeobj) event_user(0); }
();
393
    }
394
}
395
396
enum UnknownEnum
397
{
398
    Value_0,
399
    Value_8 = 8,
400
    Value_937 = 937
401
}