Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_climb_water_Step_0

(view raw script w/o annotations or w/e)
1
movetimer++;
2
totaltimer++;
3
if (watertype == 2)
4
{
5
    if (totaltimer < 15)
6
        movetimer -= (1 - ((1/15) * totaltimer));
7
}
8
if (falldir == 0)
9
    drawy = (movetimer / moverate) * 40;
10
if (falldir == 1)
11
    drawx = (movetimer / moverate) * 40;
12
if (falldir == 2)
13
    drawy = -(movetimer / moverate) * 40;
14
if (falldir == 3)
15
    drawx = -(movetimer / moverate) * 40;
16
if (movetimer >= moverate)
17
{
18
    movetimer = 0;
19
    if (falldir == 0)
20
        y += 40;
21
    if (falldir == 1)
22
        x += 40;
23
    if (falldir == 2)
24
        y -= 40;
25
    if (falldir == 3)
26
        x -= 40;
27
    drawx = 0;
28
    drawy = 0;
29
    tilecount++;
30
    if (watertype == 0)
31
    {
32
        if (tilecount == (tilelimit - 1))
33
            image_alpha = 0.5;
34
        if (tilecount >= tilelimit)
35
            instance_destroy();
36
    }
37
    if (watertype == 1 || watertype == 2)
38
    {
39
        if (y > (endy + 10))
40
            instance_destroy();
41
    }
42
}
43
if (y >= (cameray() + 740))
44
    instance_destroy();
45
if (!triggered && i_ex(obj_climb_kris) && global.interact == 0)
46
{
47
    var topy = clamp(y + drawy, ystart, endy);
48
    var boty = clamp((y - 40) + (image_yscale * 40) + drawy, ystart, endy);
49
    var kris = 0;
50
    var width = 40;
51
    var yoff = 8;
52
    if (watertype == 2)
53
        width = 12;
54
    if (watertype == 2)
55
        yoff = 14 * image_yscale;
56
    var adjustment = 0;
57
    if (watertype == 1 && i_ex(obj_rotating_tower_controller_new))
58
        adjustment = 40;
59
    if (watertype == 2)
60
        adjustment = 20;
61
    if ((boty - (topy + yoff)) > 8)
62
        kris = collision_rectangle(x + adjustment + 8, topy + yoff, (x + adjustment + width) - 8, boty - 8, obj_climb_kris, 0, 0);
63
    if (i_ex(kris))
64
    {
65
        with (kris)
66
        {
67
            if (fallingcon == 0 && (neutralcon == 1 || jumpchargecon >= 1))
68
            {
69
                if (variable_instance_exists(other, "falldir"))
70
                    falldir = other.falldir;
71
                fallingcon = 1;
72
                fallingtimer = other.fallingtimer;
73
                cancelcon = 1;
74
                if (other.bad)
75
                {
76
                    damage = other.damage;
77
                    damagecon = 1;
78
                }
79
                other.triggered = 1;
80
                if (other.sndplayed == 0)
81
                {
82
                    other.sndplayed = 1;
83
                    snd_play(motor_upper_2, 1, 1);
84
                    snd_play_delay(motor_upper_2, 1, 0.6, 0.75);
85
                }
86
            }
87
        }
88
    }
89
}