Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_dw_church_waterfallchaser_Step_0

(view raw script w/o annotations or w/e)
1
touchradius = 20;
2
var ripcol = 255;
3
if (init == 0)
4
{
5
    if (i_ex(obj_dw_church_ripseq2))
6
    {
7
        setxy((camerax() + 640) - 70, cameray() + 240);
8
        if (global.tempflag[50] != 0)
9
        {
10
            setxy(camerax() + global.tempflag[50], cameray() + global.tempflag[51]);
11
            global.tempflag[50] = 0;
12
            global.tempflag[51] = 0;
13
        }
14
        siner = sinertarg - 2;
15
    }
16
    if (i_ex(obj_ch4_DCA04))
17
    {
18
        con = 400;
19
        depth = 5000;
20
    }
21
    init = 1;
22
}
23
if (con == 0)
24
{
25
    sinertarg = 30;
26
    depth = 500;
27
    var chasespeed = 2;
28
    var offscreen = false;
29
    var cx = camerax();
30
    if (x < cx || x > (cx + 640))
31
        offscreen = true;
32
    var cy = cameray();
33
    if (y < cy || y > (cy + 480))
34
        offscreen = true;
35
    var targ = 1049;
36
    move_towards_point(targ.x + 40, targ.y + 60, chasespeed);
37
    var lerprate = 0.1;
38
    if (x > (cx + 640))
39
        x = lerp(x, cx + 640, lerprate);
40
    if (x < cx)
41
        x = lerp(x, cx, lerprate);
42
    if (y > (cy + 480))
43
        y = lerp(y, cy + 480, lerprate);
44
    if (y < cy)
45
        y = lerp(y, cy, lerprate);
46
    if (i_ex(collision_circle(x, y, touchradius, obj_mainchara, 0, true)))
47
    {
48
        con = 0.5;
49
        scr_delay_var("con", 1, 15);
50
        image_alpha = 0;
51
        var ripcount = 6;
52
        for (var i = 0; i < ripcount; i++)
53
        {
54
            var _hhsp = lengthdir_x(2, (360 / ripcount) * i);
55
            var _vvsp = lengthdir_y(2, (360 / ripcount) * i);
56
            scr_fancy_ripple_alt(x, y, 60, ripcol, 120, 1, 14, obj_mainchara.depth + 1000, _hhsp, _vvsp, 0);
57
        }
58
        speed = 0;
59
        snd_stop(snd_hurt1);
60
        snd_play(snd_hurt1);
61
        var damagetype = 0;
62
        target = 0;
63
        if (damagetype == 0)
64
        {
65
            var maxhealth = global.maxhp[1];
66
            var curhealth = global.hp[1];
67
            if (curhealth > (maxhealth / 2))
68
                damage = 40;
69
            if (curhealth <= (maxhealth / 2))
70
                damage = 30;
71
            if (curhealth <= 50)
72
                damage = 25;
73
        }
74
        if (damagetype == 1)
75
        {
76
            var highesthp = 0;
77
            for (var i = 0; i < 4; i++)
78
            {
79
                if (global.maxhp[i] > highesthp)
80
                    highesthp = global.maxhp[i];
81
            }
82
            damage = round(highesthp / 2) + 5;
83
        }
84
        global.inv = -10;
85
        
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 }
();
86
        with (obj_darkcontroller)
87
            charcon = 1;
88
        global.interact = 1;
89
        with (obj_mainchara)
90
alarm[1]
91
        timer = 0;
92
    }
93
}
94
if (con == 1)
95
{
96
    var resettime = 15;
97
    timer++;
98
    if (timer == 1)
99
    {
100
        sinertarg = 2;
101
        
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");
102
        
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");
103
    }
104
    if (timer == (1 + resettime))
105
    {
106
        sinertarg = 30;
107
        timer = 0;
108
        con = -1;
109
        scr_delay_var("con", 0, 15);
110
        scr_delay_var("image_alpha", 1, 15);
111
    }
112
}
113
if (con == 400)
114
{
115
    move_towards_point(targx, targy, 2);
116
    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))
117
    {
118
        con = 401;
119
        speed = 0;
120
    }
121
}
122
if (con == 401)
123
{
124
    var sinamt = 40 + (sin(siner / 10) * 20);
125
    x = lerp(x, targx + (sin(siner / 30) * sinamt), 0.125);
126
    y = lerp(y, targy + (cos(siner / 30) * sinamt), 0.125);
127
}
128
siner++;
129
if ((siner % sinertarg) == 0)
130
{
131
    var hittarget = 1049;
132
    if (i_ex(obj_ch4_DCA04))
133
    {
134
        with (obj_actor)
135
        {
136
            if (name == "susie")
137
                hittarget = id;
138
        }
139
    }
140
    var _hhsp = lengthdir_x(2, point_direction(x, y, hittarget.x + 40, hittarget.y + 60));
141
    var _vvsp = lengthdir_y(2, point_direction(x, y, hittarget.x + 40, hittarget.y + 60));
142
    var targdepth = other.depth + 10;
143
    if (instance_exists(obj_dw_church_ripseq2))
144
        targdepth = layer_get_depth("WALLTILES") - 100;
145
    if (instance_exists(obj_dw_church_waterfallroom))
146
        targdepth = layer_get_depth("TILES_WALL") - 100;
147
    scr_fancy_ripple_alt(x, y, ripcol, 60, 120, 1, 14, targdepth, _hhsp, _vvsp, 0);
148
}