Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_susiezilla_singlescreen_karatenna_Step_0

(view raw script w/o annotations or w/e)
1
depth = 10000 - y;
2
if (i_ex(obj_tenna_enemy))
3
    depth = 1000 - y;
4
with (obj_susiezilla_gamecontroller)
5
{
6
    var sourcedude = other.id;
7
    if (gameover)
8
    {
9
        other.speed = 0;
10
        other.image_speed = 0;
11
        with (obj_script_delayed)
12
        {
13
            if (target == sourcedude)
14
                instance_destroy();
15
        }
16
        with (obj_lerpvar)
17
        {
18
            if (target == sourcedude)
19
                instance_destroy();
20
        }
21
        other.gameover = true;
22
        exit;
23
    }
24
}
25
bobble++;
26
if (canhit == true && !i_ex(myhitbox))
27
{
28
    myhitbox = instance_create(x, y, obj_susiezilla_activehitbox);
29
    myhitbox.sprite_index = spr_whitepx;
30
    myhitbox_xoffset = -24;
31
    myhitbox_yoffset = -64;
32
    myhitbox.image_yscale = 48;
33
    myhitbox.image_xscale = 40;
34
    myhitbox.depth = depth - 20;
35
    myhitbox.image_blend = c_yellow;
36
    myhitbox.daddy = id;
37
    myhitbox.visible = false;
38
}
39
if (i_ex(myhitbox))
40
{
41
    if (!canhit || ropeheight != 0)
42
        safe_delete(myhitbox);
43
}
44
if (hitstop <= 0)
45
{
46
    fakevspeed += fakegravity;
47
    fakeheight += fakevspeed;
48
    if (fakeheight >= maxheight)
49
    {
50
        fakevspeed = 0;
51
        fakeheight = maxheight;
52
        if (abs(hspeed) < 6)
53
            canhit = 0;
54
    }
55
    if (fakeheight < maxheight || state == states.dead)
56
        friction = 0;
57
    else
58
        friction = fric_var;
59
    if (state == states.idle)
60
    {
61
        state_timer++;
62
        if (state_timer == 1)
63
        {
64
            if (i_ex(obj_susiezilla_player) && state != states.dead)
65
            {
66
                if (obj_susiezilla_player.myxcenter < x)
67
                    facing = 0;
68
                else
69
                    facing = 1;
70
            }
71
            lx = 0;
72
            rx = 1280;
73
            with (obj_susiezilla_gamecontroller)
74
            {
75
                lx = xorig;
76
                rx = xorig + width;
77
            }
78
            if (facing == 0)
79
                desx = clamp(obj_susiezilla_player.myxcenter + 40, lx + 20, rx - 20);
80
            else
81
                desx = clamp(obj_susiezilla_player.myxcenter - 40, lx + 20, rx - 20);
82
            desy = clamp(obj_susiezilla_player.myycenter + 58 + irandom_range(-24, 24), 200, 384);
83
            if (point_distance(x, y, desx, desy) <= 8)
84
            {
85
                desx = x;
86
                desy = y;
87
            }
88
        }
89
        if (state_timer > 0)
90
        {
91
            scr_obj_movetowards_point(desx, desy, clamp(point_distance(x, y, desx, desy) * 0.25, 0, 8));
92
            if (point_distance(x, y, desx, desy) < 1)
93
            {
94
                remfacing = facing;
95
                speed *= 0.99;
96
                state = states.flash;
97
                state_timer = 0;
98
            }
99
        }
100
    }
101
    if (state == states.flash)
102
    {
103
        facing = remfacing;
104
        flash--;
105
        if (state_timer == 0)
106
        {
107
            image_index = 0;
108
            image_speed = 0;
109
            flash = 10;
110
            snd_stop(snd_swing);
111
            snd_play_pitch(snd_swing, 1.6);
112
        }
113
        if (state_timer == 10)
114
        {
115
            if (facing == 1)
116
                hspeed = -8;
117
            else
118
                hspeed = 8;
119
        }
120
        if (state_timer == 14)
121
        {
122
            flash = 0;
123
            kickactive = true;
124
            ds_list_clear(hit_list);
125
            state_timer = -1;
126
            sprite_index = s_kick;
127
            if (facing == 1)
128
                hspeed = 18;
129
            else
130
                hspeed = -18;
131
            friction = 0.35;
132
            state = states.kick;
133
            state_timer = 0;
134
        }
135
        state_timer++;
136
    }
137
    if (state == states.kick)
138
    {
139
        facing = remfacing;
140
        state_timer++;
141
        if (state_timer == 8)
142
            kickactive = false;
143
        if (state_timer >= 23)
144
        {
145
            state = states.jump;
146
            state_timer = 0;
147
            hopcount = 0 - irandom(2);
148
            sprite_index = s_idle;
149
            image_speed = 0.25;
150
            if (facing == 0)
151
                direction = irandom_range(-45, 45);
152
            else
153
                direction = irandom_range(135, 225);
154
            speed = irandom_range(4, 8);
155
            fakevspeed = -8;
156
        }
157
    }
158
    if (state == states.jump)
159
    {
160
        state_timer++;
161
        if (state_timer == timertarg1 && hspeed == 0)
162
        {
163
            hspeed = 4;
164
            friction = 0.5;
165
            fakevspeed = -3 - irandom(1);
166
            timertarg1 = 30 + irandom_range(-2, 2);
167
            hopcount++;
168
        }
169
        if (state_timer >= timertarg2 && hspeed == 0)
170
        {
171
            hspeed = -4;
172
            friction = 0.5;
173
            state_timer = 0;
174
            fakevspeed = -3 - irandom(1);
175
            timertarg2 = 60 + irandom_range(-2, 2);
176
            hopcount++;
177
        }
178
        if (fakeheight == maxheight && hspeed == 0)
179
        {
180
            if (obj_susiezilla_player.myxcenter < x)
181
                facing = 0;
182
            else
183
                facing = 1;
184
        }
185
        if (hopcount >= attacktime)
186
        {
187
            hspeed = 0;
188
            friction = 0;
189
            fakevspeed = 0;
190
            state = states.idle;
191
            state_timer = 0;
192
        }
193
    }
194
    if (state == states.dead && state_timer == 0)
195
    {
196
        state_timer++;
197
        if (abs(hspeed) > 8)
198
        {
199
            snd_stop(snd_punchmed);
200
            snd_play_pitch(snd_punchmed, 0.65);
201
            for (var i = 0; i < 4; i++)
202
            {
203
                dust = 
scr_dark_marker
scr_dark_marker

function
scr_dark_marker(arg0, arg1, arg2)
{ thismarker = instance_create(arg0, arg1, obj_marker); with (thismarker) { sprite_index = arg2; image_speed = 0; image_xscale = 2; image_yscale = 2; } return thismarker; }
((x - 20) + (i * 10), y, spr_dust1);
204
                dust.depth = depth - 10;
205
                dust.vspeed = -4 - irandom(2) - (abs(hspeed) / 4);
206
                dust.gravity = 0.5;
207
                dust.image_speed = 0.5;
208
                dust.image_xscale = 2 + random_range(-0.2, 0);
209
                dust.image_xscale = dust.image_yscale;
210
                
scr_doom
scr_doom

function
scr_doom(arg0, arg1)
{ with (instance_create_depth(0, 0, 0, obj_doom)) { alarm[0] target = arg0; } }
(dust, 10);
211
                dust.hspeed = -4 + (i * 2) + (hspeed / 8);
212
                dust.friction = 0.85;
213
            }
214
        }
215
        else
216
        {
217
            snd_stop(snd_punchmed);
218
            snd_play_pitch(snd_punchmed, 0.8);
219
        }
220
    }
221
    if (kickactive)
222
    {
223
        var tempmask = obj_susiezilla_player.mask_index;
224
        obj_susiezilla_player.mask_index = spr_susiezilla_susie_hit_mask;
225
        var _hit = ds_list_create();
226
        var kickscale = polar_facing(facing);
227
        collision_rectangle_list(x - (40 + (-24 * kickscale)), y + 14, x + (40 + (24 * kickscale)), y - 22, obj_susiezilla_player, false, true, _hit, false);
228
        obj_susiezilla_player.mask_index = tempmask;
229
        for (a = 0; a < ds_list_size(_hit); a++)
230
        {
231
            if (ds_list_find_index(hit_list, ds_list_find_value(_hit, a).id) != -1)
232
                continue;
233
            ds_list_add(hit_list, ds_list_find_value(_hit, a).id);
234
            ds_list_find_value(_hit, a).take_hit(facing, damage, knockback);
235
            snd_stop(snd_punchmed);
236
            snd_play_pitch(snd_punchmed, 0.75);
237
        }
238
        ds_list_destroy(_hit);
239
    }
240
    var lx = 0;
241
    var rx = 1280;
242
    var ly = 0;
243
    with (obj_susiezilla_gamecontroller)
244
    {
245
        lx = xorig;
246
        rx = xorig + width;
247
        ly = yorig;
248
    }
249
    if (x <= (lx + 10))
250
    {
251
        x = lx + 10;
252
        hspeed = -hspeed / 2;
253
    }
254
    if (x >= (rx - 10))
255
    {
256
        x = rx - 10;
257
        hspeed = -hspeed / 2;
258
    }
259
    if (y <= (ly + 200))
260
    {
261
        y = ly + 200;
262
        vspeed = -vspeed / 2;
263
    }
264
    hitdir = direction;
265
    hitspeed = speed;
266
}
267
hitstop--;
268
if (hitstop == 0)
269
{
270
    canhit = 1;
271
    speed = memspeed;
272
    direction = memdir;
273
    fakegravity = 1;
274
    hitstop = -1;
275
}
276
if (hitstop > 0)
277
{
278
    kickactive = false;
279
    flash = 0;
280
}
281
if (abs(hspeed) > fastestspeed)
282
    fastestspeed = abs(hspeed);
283
myxcenter = x - 6;
284
myycenter = (y - 34) + fakeheight;