Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_darkshape_centipede_head_Create_0

(view raw script w/o annotations or w/e)
1
event_inherited();
2
grazed = 1;
3
grazepoints = 0;
4
shrink_sprite = spr_darkshape_directed_head;
5
with (obj_darkshape_manager)
6
    basic_shapes = false;
7
destroyonhit = false;
8
float_timer = 0;
9
individuality = irandom(100);
10
shakeme = false;
11
segment_distance = 12;
12
tracking_val *= 1.15;
13
blob_size = 0;
14
halfdrop = false;
15
guide = -4;
16
scalefactor = 1;
17
image_xscale = 1;
18
image_yscale = 1;
19
speedup = false;
20
segment_max = 3;
21
segment_length = 40;
22
myspeed = 0;
23
speed_remainder = 0;
24
segment_list = ds_list_create();
25
point_list = ds_list_create();
26
centipath = path_add();
27
path_set_kind(centipath, true);
28
path_set_closed(centipath, false);
29
ds_list_add(segment_list, id);
30
31
chase_centipede = function()
32
{
33
    var hxx = obj_heart.x + 10;
34
    var hyy = obj_heart.y + 10;
35
    float_timer += 1;
36
    var hx = hxx;
37
    var hy = hyy;
38
    path_clear_points(centipath);
39
    for (var a = 0; a < ds_list_size(point_list); a++)
40
    {
41
        var point_arr = ds_list_find_value(point_list, a);
42
        path_add_point(centipath, point_arr[0], point_arr[1], 1);
43
    }
44
    if (alarm[7])
45
        light = 1;
46
    if (!alarm[7])
47
    {
48
        for (var a = 0; a < ds_list_size(segment_list); a++)
49
        {
50
            var cur_segment = ds_list_find_value(segment_list, a);
51
            var cur_size = max(1, ds_list_size(segment_list) - 1);
52
            with (cur_segment)
53
            {
54
                var new_x = path_get_x(other.centipath, (1 / cur_size) * ds_list_find_index(other.segment_list, id));
55
                var new_y = path_get_y(other.centipath, (1 / cur_size) * ds_list_find_index(other.segment_list, id));
56
                x = new_x;
57
                y = new_y;
58
                if (object_index == obj_darkshape_centipede_segment)
59
                {
60
                    if (guide != -4)
61
                    {
62
                        direction = point_direction(x, y, guide.x, guide.y);
63
                        image_angle = direction;
64
                    }
65
                }
66
            }
67
        }
68
    }
69
    if (!alarm[7])
70
    {
71
        myspeed = 4.25 + (sin(timer * 0.1125) * 2.125);
72
        if (myspeed < 2.5)
73
        {
74
            speedup = false;
75
        }
76
        else if (!speedup)
77
        {
78
            snd_play(snd_screenshake_bc, 1.5, 0.35);
79
            with (obj_darkshape_centipede_head)
80
                speedup = true;
81
        }
82
    }
83
    if (!alarm[7])
84
    {
85
        if (i_ex(obj_heart))
86
        {
87
            if (point_distance(x, y, hxx, hyy) < (obj_darkshape_light_aura.radius + 8))
88
            {
89
                var light_ratio = 0.013 * (0.5 - light);
90
                light = 
scr_approach
scr_approach

function
scr_approach(arg0, arg1, arg2)
{ if (arg0 < arg1) { arg0 += arg2; if (arg0 > arg1) return arg1; } else { arg0 -= arg2; if (arg0 < arg1) return arg1; } return arg0; }
(light, 1, 0.013 + light_ratio);
91
                if (!irandom(2))
92
                {
93
                    with (instance_create_depth(x + random_range(-12, 12), y + random_range(-12, 12), depth + 2, obj_particle_generic))
94
                    {
95
                        image_blend = c_white;
96
                        direction = point_direction(obj_heart.x + 10, obj_heart.y + 10, x, y);
97
                        speed = 1 + random(3);
98
                        shrink_rate = 0.2;
99
                    }
100
                }
101
            }
102
            else
103
            {
104
                var light_ratio = 0.003 * (0.5 - light);
105
                light = 
scr_approach
scr_approach

function
scr_approach(arg0, arg1, arg2)
{ if (arg0 < arg1) { arg0 += arg2; if (arg0 > arg1) return arg1; } else { arg0 -= arg2; if (arg0 < arg1) return arg1; } return arg0; }
(light, 0, 0.003 + light_ratio);
106
            }
107
            var anglediff = angle_difference(direction, point_direction(x, y, hx, hy));
108
            direction -= clamp(sign(anglediff) * (tracking_val / (myspeed * 1.8)), -abs(anglediff), abs(anglediff));
109
            image_angle = direction;
110
        }
111
    }
112
};
113
114
check_death = function()
115
{
116
    if (alarm[7])
117
        exit;
118
    if (light > 0.25 && !halfdrop)
119
    {
120
        halfdrop = true;
121
        if (blob_size)
122
        {
123
            with (instance_create_depth(x, y, depth + 1, obj_bulletparent))
124
            {
125
                image_angle = 0;
126
                image_xscale = 0.0625;
127
                image_yscale = 0.0625;
128
                
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("image_xscale", image_xscale, image_xscale * 3, 4);
129
                
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("image_yscale", image_yscale, image_yscale * 3, 4);
130
                sprite_index = spr_finisher_explosion;
131
                image_index = 2;
132
                image_speed = 1;
133
                
scr_script_delayed
scr_script_delayed

function
scr_script_delayed()
{ var __scriptdelay = instance_create(0, 0, obj_script_delayed); __scriptdelay.script = argument[0]; __scriptdelay.alarm[0] = argument[1]; __scriptdelay.target = id; for (var __i = 0; __i < (argument_count - 2); __i++) __scriptdelay.script_arg[__i] = argument[__i + 2]; __scriptdelay.arg_count = argument_count - 2; return __scriptdelay; }
(instance_destroy, 5);
134
            }
135
            with (instance_create_depth(x, y, depth + 1, obj_darkshape_greenblob))
136
            {
137
                max_speed = 6 + irandom(2);
138
                size = 1;
139
                prime_me();
140
            }
141
            blob_size = 
scr_approach
scr_approach

function
scr_approach(arg0, arg1, arg2)
{ if (arg0 < arg1) { arg0 += arg2; if (arg0 > arg1) return arg1; } else { arg0 -= arg2; if (arg0 < arg1) return arg1; } return arg0; }
(blob_size, 0, 1);
142
        }
143
    }
144
    if (light == 1)
145
    {
146
        if (instance_number(obj_darkshape_centipede_head) == 1)
147
            global.turntimer = 70;
148
        else if (global.turntimer < 70)
149
            global.turntimer += 70;
150
        snd_play_pitch(snd_spearappear_choppy, 0.65);
151
        shakeme = true;
152
        myspeed *= 0;
153
        xscale *= 2;
154
        yscale *= 2;
155
        with (
scr_afterimage_grow
scr_afterimage_grow

function
scr_afterimage_grow()
{ afterimage = instance_create(x, y, obj_afterimage_grow); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; afterimage.image_alpha = image_alpha; return afterimage; }
())
156
        {
157
            sprite_index = other.shrink_sprite;
158
            image_index = other.image;
159
            fade *= 2;
160
            xrate *= 0.5;
161
            yrate *= 0.5;
162
        }
163
        for (var b = 1; b < ds_list_size(segment_list); b++)
164
        {
165
            var cur_segment = ds_list_find_value(segment_list, b);
166
            cur_segment.shakeme = true;
167
            cur_segment.autolight = true;
168
            cur_segment.alarm[8] = b * 2;
169
            with (cur_segment)
170
                speed = point_distance(x, y, xprevious, yprevious) * 0;
171
        }
172
        alarm[7]
 = 20;
gml_Object_obj_darkshape_centipede_head_Alarm_7.gml

with (instance_create_depth(x, y, depth + 1, obj_darkshape_greenblob)) { size = other.blob_size; prime_me(); } for (var b = 1; b < ds_list_size(segment_list); b++) { var cur_segment = ds_list_find_value(segment_list, b); cur_segment.alarm[7] = b * 4; } instance_destroy();
173
    }
174
};
175
176
ds_list_insert(point_list, 0, [x, y]);