Deltarune script viewer

← back to main script listing

gml_Object_obj_finalchain_ch1_Step_0

(view raw script w/o annotations or w/e)
1
if (chaincon == 0)
2
{
3
    if (chain_noise == 0)
4
    {
5
        chainsound = snd_loop_ch1(snd_chain_extend_ch1);
6
        chain_noise = 1;
7
    }
8
    if (sons < 40)
9
    {
10
        sons += 1;
11
        son[sons] = instance_create_ch1(x, y, obj_chainpiece_ch1);
12
        son[sons].image_blend = c_red;
13
    }
14
    if (x <= obj_nonsolid_growtangle_ch1.x)
15
    {
16
        if (chain_noise == 1)
17
        {
18
            chain_noise = 2;
19
            snd_stop_ch1(chainsound);
20
            snd_play_ch1(snd_locker_ch1);
21
            snd_play_ch1(snd_screenshake_ch1);
22
        }
23
        box = obj_nonsolid_growtangle_ch1;
24
        x = obj_nonsolid_growtangle_ch1.x;
25
        y = obj_nonsolid_growtangle_ch1.y;
26
        speed = 0;
27
        chaincon = 1;
28
        shakeamt = 16;
29
        remx = obj_heart_ch1.x;
30
        remy = obj_heart_ch1.y;
31
        remx_box = obj_nonsolid_growtangle_ch1.x;
32
        remy_box = obj_nonsolid_growtangle_ch1.y;
33
        chaincon = 2.1;
34
        with (obj_growtangle_ch1)
35
            megakeep = 1;
36
    }
37
}
38
if (chaincon == 2.1)
39
{
40
    obj_nonsolid_growtangle_ch1.x = remx_box;
41
    obj_nonsolid_growtangle_ch1.y = remy_box;
42
    shakedir = random(360);
43
    xshake = lengthdir_x(shakeamt, shakedir);
44
    yshake = lengthdir_y(shakeamt, shakedir);
45
    obj_nonsolid_growtangle_ch1.x += xshake;
46
    obj_nonsolid_growtangle_ch1.y += yshake;
47
    shakeamt -= 2;
48
    if (shakeamt <= 0)
49
    {
50
        chaincon = 2.2;
51
        obj_nonsolid_growtangle_ch1.x = remx_box;
52
        obj_nonsolid_growtangle_ch1.y = remy_box;
53
    }
54
}
55
if (chaincon == 2.2)
56
{
57
    xx = __view_get(e__VW.XView, 0) + 320;
58
    yy = __view_get(e__VW.YView, 0) + 160;
59
    yy_2 = __view_get(e__VW.YView, 0);
60
    chaincon = 2.3;
61
    if (type >= 1)
62
    {
63
        spike = instance_create_ch1(x, y, obj_regularbullet_permanent_ch1);
64
        scr_bullet_inherit_ch1
scr_bullet_inherit_ch1

function scr_bullet_inherit_ch1(arg0) { if (instance_exists(arg0)) { arg0.damage = damage; arg0.grazepoints = grazepoints; arg0.timepoints = timepoints; arg0.inv = inv; arg0.target = target; arg0.grazed = 0; arg0.grazetimer = 0; } }
(spike);
65
        spike.image_speed = 0;
66
        spike.active = 0;
67
        with (obj_regularbullet_ch1)
68
            basealpha = 0;
69
        spike.image_alpha = 0;
70
        spike.mask_index = box.sprite_index;
71
        spike.sprite_index = spr_battlebg_spikes_ch1;
72
        spikemake = 1;
73
        spike.image_xscale = box.image_xscale * 0.96;
74
        spike.image_yscale = box.image_yscale * 0.96;
75
    }
76
    if (type <= 1)
77
    {
78
        for (i = 0; i < 5; i += 1)
79
        {
80
            for (j = 0; j < 5; j += 1)
81
            {
82
                bul[i][j] = instance_create_ch1((xx - 150) + (i * 70), yy_2 + 20 + (j * 70), obj_regularbullet_permanent_ch1);
83
                bul[i][j].sprite_index = spr_spadebullet_ch1;
84
                bul[i][j].basealpha = 0;
85
                bul[i][j].active = 0;
86
                bul[i][j].image_angle = 90;
87
                bul[i][j].image_xscale = 0.5;
88
                bul[i][j].image_yscale = 0.5;
89
                bul[i][j].neveractive = 1;
90
                scr_bullet_inherit_ch1
scr_bullet_inherit_ch1

function scr_bullet_inherit_ch1(arg0) { if (instance_exists(arg0)) { arg0.damage = damage; arg0.grazepoints = grazepoints; arg0.timepoints = timepoints; arg0.inv = inv; arg0.target = target; arg0.grazed = 0; arg0.grazetimer = 0; } }
(bul[i][j]);
91
            }
92
        }
93
        bulletpoint = 1;
94
    }
95
}
96
if (chaincon == 2.3)
97
{
98
    with (obj_regularbullet_ch1)
99
        basealpha += 0.04;
100
    if (spikemake == 1)
101
    {
102
        box.image_xscale += 0.005;
103
        box.image_yscale += 0.005;
104
        spike.image_xscale += 0.005;
105
        spike.image_yscale += 0.005;
106
        if (type == 1)
107
        {
108
            box.image_xscale += 0.01;
109
            box.image_yscale += 0.01;
110
            spike.image_xscale += 0.01;
111
            spike.image_yscale += 0.01;
112
        }
113
    }
114
    gotimer += 1;
115
    if (gotimer >= 30)
116
    {
117
        chaincon = 3;
118
        gotimer = 0;
119
        xx = __view_get(e__VW.XView, 0) + 320;
120
        yy = __view_get(e__VW.YView, 0) + 160;
121
        pointx = xx;
122
        pointy = yy;
123
        with (obj_regularbullet_ch1)
124
            active = 1;
125
    }
126
}
127
if (chaincon == 3)
128
{
129
    if (movecon == 0 && ended == 0)
130
    {
131
        if (mytimer > (maxtimer - 10))
132
            ended = 1;
133
    }
134
    if (movecon == 0 && ended == 0)
135
    {
136
        speed = 0;
137
        pointdist = 0;
138
        mind = 100;
139
        maxd = 130;
140
        if (type == 0)
141
        {
142
            maxd = 110;
143
            movetime = 30;
144
        }
145
        if (type >= 1)
146
            maxd = 140;
147
        if (type == 3 || type == 4)
148
            maxd = 120;
149
        if (type == 5)
150
        {
151
            maxd = 130;
152
            movetime = 30;
153
        }
154
        while (pointdist < mind || pointdist > maxd)
155
        {
156
            pointx = (xx + random(140)) - random(140);
157
            pointy = (yy + random(120)) - random(120);
158
            pointdist = point_distance(x, y, pointx, pointy);
159
        }
160
        target = instance_create_ch1(pointx, pointy, obj_chainpiece_ch1);
161
        target.sprite_index = spr_heartoutline_ch1;
162
        target.depth = 30;
163
        move_towards_point(pointx, pointy, pointdist / movetime);
164
        movetimer = 0;
165
        movecon = 1;
166
        chainnoise = snd_loop_ch1(snd_chain_extend_ch1);
167
    }
168
    if (movecon == 1 && ended == 0)
169
    {
170
        movetimer += 1;
171
        if (movetimer > movetime)
172
        {
173
            x = pointx;
174
            y = pointy;
175
            movecon = 2;
176
            speed = 0;
177
            movetimer = 0;
178
        }
179
    }
180
    if (movecon == 2 && ended == 0)
181
    {
182
        maxmove = 20;
183
        if (type == 1)
184
            maxmove = 22;
185
        if (type == 2)
186
            maxmove = 16;
187
        if (type == 3)
188
            maxmove = 7;
189
        if (type == 4)
190
            maxmove = 3;
191
        if (type == 5)
192
            maxmove = 22;
193
        movetimer += 1;
194
        if (movetimer >= maxmove)
195
        {
196
            with (target)
197
                instance_destroy();
198
            movecon = 0;
199
            snd_stop_ch1(chainnoise);
200
        }
201
    }
202
}
203
if (chaincon >= 0)
204
{
205
    kingx[0] = x;
206
    kingy[0] = y;
207
    for (i = 40; i > 0; i -= 1)
208
    {
209
        kingx[i] = kingx[i - 1];
210
        kingy[i] = kingy[i - 1];
211
    }
212
    for (i = 0; i <= sons; i += 1)
213
    {
214
        son[i].x = kingx[i];
215
        son[i].y = kingy[i];
216
        son[i].image_angle = direction;
217
    }
218
    if (chaincon >= 3)
219
    {
220
        obj_nonsolid_growtangle_ch1.x = kingx[sons];
221
        obj_nonsolid_growtangle_ch1.y = kingy[sons];
222
    }
223
}
224
if (bulletpoint == 1)
225
{
226
    with (obj_regularbullet_ch1)
227
    {
228
        if (sprite_index == spr_spadebullet_ch1)
229
        {
230
            image_angle = point_direction(x, y, obj_heart_ch1.x + 8, obj_heart_ch1.y + 8);
231
            pointdist = point_distance(x, y, obj_heart_ch1.x + 8, obj_heart_ch1.y + 8);
232
            if (pointdist > 80)
233
                neveractive -= 0.02;
234
            if (neveractive > 0)
235
                active = 0;
236
            else
237
                active = 1;
238
            alphafactor = 0.7;
239
            activefactor = 1 - neveractive;
240
            if (activefactor > 1)
241
                activefactor = 1;
242
            if (pointdist > 80)
243
            {
244
                alphafactor = 1.7 - ((pointdist * 1) / 80);
245
                if (alphafactor < 0)
246
                    alphafactor = 0;
247
            }
248
            image_alpha = (0.3 + alphafactor) * basealpha * activefactor;
249
            if (image_xscale < 0.68 && obj_finalchain_ch1.ended == 0)
250
            {
251
                image_xscale += 0.0005;
252
                image_yscale += 0.0005;
253
            }
254
            else
255
            {
256
                active = 0;
257
                basealpha -= 0.1;
258
                obj_finalchain_ch1.ended = 1;
259
            }
260
        }
261
    }
262
}
263
if (spikemake == 1)
264
{
265
    spike.image_alpha += 0.04;
266
    spike.x = box.x;
267
    spike.y = box.y;
268
    if (ended == 1)
269
    {
270
        if (spike.image_alpha >= 1)
271
            spike.image_alpha = 1;
272
        spike.image_alpha -= 0.14;
273
    }
274
}
275
if (ended == 1)
276
{
277
    endtimer += 1;
278
    if (endtimer >= 10)
279
    {
280
        snd_stop_ch1(snd_chain_extend_ch1);
281
        with (obj_chainpiece_ch1)
282
            instance_destroy();
283
        with (obj_regularbullet_ch1)
284
            instance_destroy();
285
        with (obj_chainking_ch1)
286
            instance_destroy();
287
        global.turntimer = 3;
288
        instance_destroy();
289
    }
290
}
291
if (spikemake == 1)
292
{
293
    if (instance_exists(spike))
294
    {
295
        if (spike.grazed == 1)
296
        {
297
            if (timerbonus == 0)
298
            {
299
                mytimer += 2;
300
                timerbonus = 1;
301
            }
302
            grazetimer += 1;
303
            if (grazetimer >= 15)
304
            {
305
                timerbonus = 0;
306
                grazetimer = 0;
307
                spike.grazed = 0;
308
            }
309
        }
310
    }
311
}
312
mytimer += 1;
313
image_angle = direction;
314
315
enum e__VW
316
{
317
    XView,
318
    YView,
319
    WView,
320
    HView,
321
    Angle,
322
    HBorder,
323
    VBorder,
324
    HSpeed,
325
    VSpeed,
326
    Object,
327
    Visible,
328
    XPort,
329
    YPort,
330
    WPort,
331
    HPort,
332
    Camera,
333
    SurfaceID
334
}