Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_dw_church_waterfallchaser_churchc_Step_0

(view raw script w/o annotations or w/e)
1
touchradius = 20;
2
var ripcol = 255;
3
if (init == 0)
4
{
5
    init = 1;
6
    con = 2;
7
}
8
if (con == 0)
9
{
10
    timer++;
11
    var speedup = clamp(((timer / 90) * timer) / 90, 0, 1);
12
    sinertarg = 30 - lerp(0, 28, speedup);
13
    depth = 500;
14
    var chasespeed = lerp(-1, 11, speedup);
15
    var offscreen = false;
16
    var cx = camerax();
17
    if (x < cx || x > (cx + 640))
18
        offscreen = true;
19
    var cy = cameray();
20
    if (y < cy || y > (cy + 480))
21
        offscreen = true;
22
    if (offscreen)
23
        chasespeed = 24;
24
    var targ = 1049;
25
    var player_in_light = 
scr_in_light
scr_in_light

function
scr_in_light(arg0 = self, arg1 = 0, arg2 = 0)
{ var _inLight = false; _inLight = collision_point(arg0.x + arg1, arg0.y + arg2, obj_light_collider, true, true); return _inLight != -4; }
(1214, 10, 10);
26
    if (player_in_light)
27
    {
28
        siner = random_range(0, 48);
29
        sinertarg = 9999;
30
        x = startx;
31
        y = starty;
32
        vspeed = 0;
33
        hspeed = 0;
34
        timer = 0;
35
        con = 2;
36
        exit;
37
    }
38
    move_towards_point(targ.x + 40, targ.y + 60, chasespeed);
39
    if (i_ex(collision_circle(x, y, touchradius, obj_mainchara, 0, true)))
40
    {
41
        con = 0.5;
42
        scr_delay_var("con", 1, 15);
43
        image_alpha = 0;
44
        var ripcount = 6;
45
        for (var i = 0; i < ripcount; i++)
46
        {
47
            var ripple = instance_create(x, y, obj_church_ripple);
48
            with (ripple)
49
            {
50
                ripplecount = 1;
51
                ripplethicc = 6;
52
                lifetime = 60;
53
                alpha = 2;
54
                dodraw = false;
55
                color = ripcol;
56
                maxsize = 120;
57
                depth = obj_mainchara.depth + 1000;
58
                direction = (360 / ripcount) * i;
59
                speed = 2;
60
            }
61
        }
62
        speed = 0;
63
        snd_stop(snd_hurt1);
64
        snd_play(snd_hurt1);
65
        var highesthp = 0;
66
        for (var i = 0; i < 4; i++)
67
        {
68
            if (global.maxhp[i] > highesthp)
69
                highesthp = global.maxhp[i];
70
        }
71
        var target = 0;
72
        damage = round(highesthp / 2) + 5;
73
        with (obj_dw_church_waterfallchaser_churchc)
74
        {
75
            if (con == 0)
76
                con = 1;
77
        }
78
        global.inv = -10;
79
        
scr_damage_all_overworld
scr_damage_all_overworld

function
scr_damage_all_overworld()
{ if (global.inv < 0) { gameover = 1; if (global.char[0] != 0 && global.hp[global.char[0]] > 1) gameover = 0; if (global.char[1] != 0 && global.hp[global.char[1]] > 1) gameover = 0; if (global.char[2] != 0 && global.hp[global.char[2]] > 1) gameover = 0; if (gameover == 1) { with (obj_event_manager) trigger_event(UnknownEnum.Value_1);
scr_gameover();
}
scr_damage_cache();
remdamage = damage; remtarget = target; if (!instance_exists(obj_shake)) instance_create(0, 0, obj_shake); with (obj_dmgwriter) killactive = 1; snd_stop(snd_hurt1); snd_play(snd_hurt1); for (ti = 0; ti < 3; ti += 1) { global.inv = -1; damage = remdamage; target = ti; tdamage = damage; with (global.charinstance[target]) { hurt = 1; hurttimer = 0; } hpdiff = tdamage; if (hpdiff >= global.hp[global.char[target]]) hpdiff = global.hp[global.char[target]] - 1; d_cancel = 0; if (hpdiff <= 1) { if (global.hp[global.char[target]] <= 0) { hpdiff = 0; d_cancel = 1; } else { hpdiff = 1; } } if (d_cancel == 0) { doomtype = -1; global.hp[global.char[target]] -= hpdiff; if ((instance_exists(global.charinstance[target]) && global.charinstance[target].visible == true) || i_ex(obj_climb_kris)) { dmgwriter = instance_create(x, y, obj_dmgwriter); dmgwriter.damage = hpdiff; dmgwriter.type = doomtype; if (i_ex(obj_climb_kris)) { dmgwriter.x = obj_climb_kris.x; dmgwriter.y = obj_climb_kris.y; dmgwriter.ystart = obj_climb_kris.y; dmgwriter.depth = obj_climb_kris.depth - 100; if (obj_climb_kris.onrotatingtower == true) dmgwriter.x = camerax() + (camerawidth() / 2); } else { dmgwriter.x = global.charinstance[target].x; dmgwriter.y = (global.charinstance[target].y + global.charinstance[target].myheight) - 24; } } if (global.hp[global.char[target]] < 1) global.hp[global.char[target]] = 1; } } scr_damage_check(); target = remtarget; global.inv = global.invc * 40; } } enum UnknownEnum { Value_1 = 1 }
();
80
        with (obj_darkcontroller)
81
            charcon = 1;
82
        global.interact = 1;
83
        with (obj_mainchara)
84
alarm[1]
85
        timer = 0;
86
    }
87
}
88
if (con == 1)
89
{
90
    var resettime = 15;
91
    timer++;
92
    if (timer == 1)
93
    {
94
        sinertarg = 2;
95
        
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; }
("x", x, camerax() + 640, resettime, 2, "out");
96
        
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; }
("y", y, cameray(), resettime, 2, "out");
97
    }
98
    if (timer == (1 + resettime))
99
    {
100
        sinertarg = 30;
101
        timer = 0;
102
        con = -1;
103
        scr_delay_var("con", 0, 15);
104
        scr_delay_var("image_alpha", 1, 15);
105
    }
106
}
107
if (con == 2)
108
{
109
    timer++;
110
    sinertarg = 50;
111
    if (siner == 49)
112
    {
113
        x = random_range(startx - 20, startx + 20);
114
        y = random_range(starty - 20, starty + 20);
115
    }
116
    var offscreen = false;
117
    var cx = camerax();
118
    if (x < cx || x > (cx + 640))
119
        offscreen = true;
120
    var cy = cameray();
121
    if (y < cy || y > (cy + 480))
122
        offscreen = true;
123
    var player_in_light = 
scr_in_light
scr_in_light

function
scr_in_light(arg0 = self, arg1 = 0, arg2 = 0)
{ var _inLight = false; _inLight = collision_point(arg0.x + arg1, arg0.y + arg2, obj_light_collider, true, true); return _inLight != -4; }
(1214, 10, 10);
124
    if (!player_in_light && !offscreen)
125
    {
126
        con = 0;
127
        timer = 0;
128
    }
129
}
130
if (con == 400)
131
{
132
    move_towards_point(targx, targy, 2);
133
    if (
scr_checklocation
scr_checklocation

function
scr_checklocation(arg0 = id, arg1, arg2, arg3 = 0)
{ if (!i_ex(arg0)) { debug_message("target instance does not exist"); return false; } if (abs(arg0.x - arg1) <= arg3 && abs(arg0.y - arg2) <= arg3) return true; else return false; }
(undefined, targx, targy, 2))
134
    {
135
        con = 401;
136
        speed = 0;
137
    }
138
}
139
if (con == 401)
140
{
141
    var sinamt = 40 + (sin(siner / 10) * 20);
142
    x = lerp(x, targx + (sin(siner / 30) * sinamt), 0.125);
143
    y = lerp(y, targy + (cos(siner / 30) * sinamt), 0.125);
144
}
145
siner++;
146
if (siner >= sinertarg)
147
{
148
    siner = 0;
149
    var target = 1049;
150
    var speedd = 2;
151
    if (i_ex(obj_ch4_DCA04))
152
    {
153
        with (obj_actor)
154
        {
155
            if (name == "susie")
156
                target = id;
157
        }
158
    }
159
    if (con == 2)
160
        speedd = 0;
161
    var ripple = instance_create(x, y, obj_church_ripple);
162
    with (ripple)
163
    {
164
        ripplecount = 1;
165
        ripplethicc = 6;
166
        lifetime = 60;
167
        alpha = 2;
168
        dodraw = false;
169
        color = ripcol;
170
        maxsize = 120;
171
        depth = other.depth + 10;
172
        direction = point_direction(x, y, target.x + 40, target.y + 60);
173
        speed = speedd;
174
    }
175
}