Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_susiezilla_zombie_Step_0

(view raw script w/o annotations or w/e)
1
if (hurtCon == 0)
2
{
3
    if (attackcon == 0)
4
    {
5
        var a = 1;
6
        if (sprite_index == spr_susiezilla_zombie_giantsword)
7
            a = 2;
8
        repeat (a)
9
        {
10
            if (abs(obj_susiezilla.x - x) > 50)
11
            {
12
                if (obj_susiezilla.x < x)
13
                {
14
                    image_index = 0;
15
                    if (!collision_rectangle(x - 20 - 4, y, x + 20, y - 20, obj_interactable, false, true))
16
                        x -= 4;
17
                }
18
                else
19
                {
20
                    image_index = 1;
21
                    if (!collision_rectangle(x - 20, y, x + 20 + 4, y - 20, obj_interactable, false, true))
22
                        x += 4;
23
                }
24
            }
25
            if (abs(obj_susiezilla.y - y) > 25 && distance_to_object(obj_susiezilla) < 100)
26
            {
27
                if (obj_susiezilla.y < y)
28
                {
29
                    if (!collision_rectangle(x - 20, y, x + 20, y - 20 - 2, obj_interactable, false, true))
30
                        y -= 2;
31
                }
32
                else if (!collision_rectangle(x - 20 - 4, y + 2, x + 20, y - 20, obj_interactable, false, true))
33
                {
34
                    y += 2;
35
                }
36
            }
37
        }
38
        if (abs(obj_susiezilla.y - y) > 25 || abs(obj_susiezilla.x - x) > 50)
39
        {
40
        }
41
        else if (latched == 0)
42
        {
43
            var zombie_attacking = false;
44
            if (sprite_index == spr_susiezilla_zombie_giantsword)
45
            {
46
                for (var i = 0; i < instance_number(obj_susiezilla_zombie); i++)
47
                {
48
                    zombie[i] = instance_find(obj_susiezilla_zombie, i);
49
                    if (zombie[i].attackcon == 1)
50
                        zombie_attacking = true;
51
                }
52
                if (zombie_attacking == false)
53
                    attackcon = 1;
54
            }
55
            else if (zombie_attacking == false)
56
            {
57
                attackcon = 3;
58
            }
59
        }
60
    }
61
    if (attackcon == 3)
62
    {
63
        attacktimer++;
64
        if (attacktimer == 1)
65
            redflashtimer = 11;
66
        if (attacktimer == 11)
67
        {
68
            snd_stop(snd_hitcar_little);
69
            snd_play_pitch(snd_hitcar_little, 1.3);
70
            image_index = 11;
71
            vspeed = -8 - random(3);
72
            gravity = 0.8 + (random(5) / 10);
73
            if (obj_susiezilla.x < x)
74
                hspeed = -3 - random(2);
75
            else
76
                hspeed = 3 + random(2);
77
        }
78
        if (attacktimer > 26 && y > savey && vspeed > 0)
79
        {
80
            snd_play(snd_bump);
81
            hspeed = 0;
82
            vspeed = 0;
83
            gravity = 0;
84
            
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); }
();
85
        }
86
        if (attacktimer == 56)
87
        {
88
            snd_play(snd_wing);
89
            
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); }
();
90
        }
91
        if (attacktimer == 86)
92
        {
93
            snd_play(snd_wing);
94
            
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); }
();
95
        }
96
        if (attacktimer >= 90)
97
        {
98
            image_index = 0;
99
            attackcon = 0;
100
            attacktimer = 0;
101
        }
102
        if (point_distance(x, y - 20, obj_susiezilla.x, obj_susiezilla.y - 50) < 36 && attackcon == 3 && vspeed != 0 && hp > 0)
103
        {
104
            instance_create(obj_susiezilla.x, obj_susiezilla.y - 20, obj_susiezilla_enemy_hitbox);
105
            event_user(0);
106
            anim = instance_create(x, y - 16, obj_animation);
107
            anim.sprite_index = spr_coaster_explosion;
108
            anim.image_speed = 0.5;
109
            anim.depth = -99999999;
110
        }
111
    }
112
    if (attackcon == 1)
113
    {
114
        attacktimer++;
115
        if (attacktimer == 1)
116
        {
117
            if (image_index == 0)
118
                image_index = 7;
119
            else
120
                image_index = 9;
121
            redflashtimer = 11;
122
        }
123
        if (attacktimer == 11)
124
        {
125
            snd_stop(snd_motor_upper_quick);
126
            snd_play_pitch(snd_motor_upper_quick, 1.3);
127
            if (image_index == 7)
128
            {
129
                image_index = 8;
130
                hspeed = -12;
131
                friction = 2;
132
            }
133
            else
134
            {
135
                image_index = 10;
136
                hspeed = 12;
137
                friction = 2;
138
            }
139
            hitbox = instance_create(x, y, obj_susiezilla_enemy_hitbox);
140
            hitbox.sprite_index = sprite_index;
141
            hitbox.image_xscale = image_xscale;
142
            hitbox.image_index = 0;
143
            hitbox.hit_direction = -1;
144
        }
145
        if (attacktimer > 11 && attacktimer < 13)
146
            hitbox.x = x;
147
        if (attacktimer > 11 && hspeed == 0)
148
        {
149
            hspeed = 0;
150
            friction = 0;
151
            if (image_index == 8)
152
                image_index = 0;
153
            else
154
                image_index = 1;
155
            attackcon = 0;
156
            attacktimer = 0;
157
        }
158
    }
159
    if (attackcon == 2)
160
    {
161
        attacktimer++;
162
        if (attacktimer == 1)
163
        {
164
            snd_stop(snd_hitcar_little);
165
            snd_play_pitch(snd_hitcar_little, 1.3);
166
            image_index = 11;
167
            vspeed = -11;
168
            gravity = 1;
169
            hspeed = random(2) * -1;
170
            savey = y - 18;
171
        }
172
        if (attacktimer > 1 && y > savey && vspeed > 0)
173
        {
174
            hspeed = 0;
175
            vspeed = 0;
176
            gravity = 0;
177
        }
178
        if (attacktimer > 30)
179
        {
180
            attacktimer = 2;
181
            obj_susiezilla.health_count -= 10;
182
            
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); }
();
183
        }
184
    }
185
}
186
if (hurtCon == 1)
187
{
188
    recoil += (recoilSpeed * recoilDir);
189
    recoilSpeed -= 1;
190
    if (sign(recoil) != recoilDir)
191
    {
192
        recoil = 0;
193
        hurtCon = 0;
194
        recoilSpeed = 0;
195
        image_index = 0;
196
    }
197
}
198
if (fall_speed != 0 || height > 0)
199
{
200
    height -= fall_speed;
201
    fall_speed += 1;
202
    if (height <= 0)
203
    {
204
        height = 0;
205
        if (bounce_count < 1)
206
            fall_speed *= -0.5;
207
        else
208
            fall_speed = 0;
209
        bounce_count++;
210
        snd_stop(snd_bump);
211
        snd_play(snd_bump);
212
        vspeed = 0;
213
    }
214
}
215
if (hurtCon == 2)
216
{
217
    if (fall_speed > 0)
218
    {
219
        image_index = 5 + reverse_image;
220
        hurtCon = 3;
221
        shadow.image_xscale *= 1;
222
    }
223
}
224
if (hurtCon == 3 && height == 0 && fall_speed == 0)
225
{
226
    alarm[0]
 = 10;
gml_Object_obj_susiezilla_zombie_Alarm_0.gml

hurtCon++;
227
    hurtCon = 4;
228
    hspeed = 0;
229
}
230
if (hurtCon == 5)
231
{
232
    fader++;
233
    if ((fader % 2) == 1)
234
        visible = false;
235
    else
236
        visible = true;
237
    if (fader == 15)
238
    {
239
        var fx = instance_create(x - 24, y - 50, obj_animation);
240
        fx.sprite_index = spr_explosion_round;
241
        fx.image_speed = 0.5;
242
        fx.depth = obj_susiezilla.depth - 20;
243
        audio_stop_sound(snd_explosion_firework);
244
        snd_play_pitch(snd_explosion_firework, 1.1 + random(0.4));
245
    }
246
    if (fader >= 20)
247
        instance_destroy();
248
}