Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_noelle_city_traffic_2_Step_0

(view raw script w/o annotations or w/e)
1
if (mycater == 0)
2
{
3
    with (obj_caterpillarchara)
4
    {
5
        if (name == "noelle")
6
            other.mycater = id;
7
    }
8
}
9
if (idealPositionProgress < 1)
10
{
11
    idealPositionProgress += 0.08;
12
    if (idealPositionProgress > 1)
13
        idealPositionProgress = 1;
14
}
15
with (obj_mainchara)
16
{
17
    if (place_meeting(x, y, obj_traffic_road_trigger))
18
    {
19
        if (other.stickToKris == false)
20
            other.idealPositionProgress = 0;
21
        other.stickToKris = true;
22
    }
23
    else
24
    {
25
        if (other.stickToKris == true)
26
            other.idealPositionProgress = 0;
27
        other.stickToKris = false;
28
    }
29
}
30
if (stickToKris == true)
31
{
32
    if (room != room_dw_city_traffic_3)
33
    {
34
        idealX = obj_mainchara.x - 4;
35
        idealY = obj_mainchara.y + 30;
36
        if (room == room_dw_city_traffic_1)
37
            idealY = clamp(idealY, 0, 262);
38
        if (room == room_dw_city_traffic_2)
39
            idealY = clamp(idealY, 0, 222);
40
    }
41
    if (room == room_dw_city_traffic_3)
42
    {
43
        with (obj_mainchara)
44
        {
45
            if (y > yprevious)
46
                other.pos = "down";
47
            if (y < yprevious)
48
                other.pos = "up";
49
        }
50
        if (pos != prevpos)
51
            idealPositionProgress = 0;
52
        if (pos == "up")
53
        {
54
            idealX = obj_mainchara.x - 4;
55
            idealY = obj_mainchara.y + 30;
56
        }
57
        if (pos == "down")
58
        {
59
            idealX = obj_mainchara.x - 4;
60
            idealY = obj_mainchara.y - 30;
61
        }
62
        prevpos = pos;
63
    }
64
    x = lerp(x, idealX, idealPositionProgress);
65
    y = lerp(y, idealY, idealPositionProgress);
66
    image_speed = 0;
67
    image_index = obj_mainchara.image_index;
68
    if (xprevious > x)
69
        sprite_index = spr_noelle_cower_left;
70
    if (xprevious < x)
71
        sprite_index = spr_noelle_cower_right;
72
}
73
if (stickToKris == false)
74
{
75
    if (place_meeting(x, y, obj_triggervolume))
76
    {
77
        y -= 8;
78
    }
79
    else
80
    {
81
        with (mycater)
82
        {
83
            x = other.x;
84
            y = other.y;
85
            visible = true;
86
            
scr_caterpillar_interpolate
scr_caterpillar_interpolate

function
scr_caterpillar_interpolate()
{ _newfacing =
scr_facing_letter_to_number(
scr_get_cardinal_direction(point_direction(x, y, obj_mainchara.x, obj_mainchara.y)));
remx[0] = obj_mainchara.x; remy[0] = obj_mainchara.y; facing[0] = _newfacing; for (_iaia = target; _iaia > 0; _iaia -= 1) { remx[_iaia] = lerp(obj_mainchara.x, x, _iaia / target); if (global.darkzone == 1) remy[_iaia] = lerp(obj_mainchara.y, y + 16, _iaia / target); else remy[_iaia] = lerp(obj_mainchara.y, y + 6, _iaia / target); facing[_iaia] = _newfacing; } }
();
87
        }
88
        instance_destroy();
89
    }
90
}
91
scr_depth
scr_depth

function
scr_depth()
{ depth = 100000 - ((y * 10) + (sprite_height * 10)); }
();