Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_traffic_car_Step_0

(view raw script w/o annotations or w/e)
1
scr_depth
scr_depth

function
scr_depth()
{ depth = 100000 - ((y * 10) + (sprite_height * 10)); }
();
2
if (walkdir == "down" && y >= (room_height + 30))
3
    endme = 1;
4
if (walkdir == "right" && x >= (room_width + (sprite_width * 2)))
5
    endme = 1;
6
if (walkdir == "left" && x <= (0 - (sprite_width * 2)))
7
    endme = 1;
8
if (place_meeting(x, y, obj_solidenemy_2))
9
    endme = 1;
10
if ((global.interact == 0 || i_ex(obj_cutscene_master)) && active == 1)
11
{
12
    if (alwayswalking == 1)
13
        walking = 1;
14
    if (walkdir == "down")
15
    {
16
        if (walking == 0)
17
            y += myspeed;
18
        if (walking == 1)
19
        {
20
            if (alwayswalking == 0)
21
                y += (myspeed / 4);
22
        }
23
        if (alwayswalking == 1)
24
            y += myspeed;
25
    }
26
    if (walkdir == "left")
27
    {
28
        if (walking == 0)
29
            x -= myspeed;
30
        if (walking == 1)
31
            x -= (myspeed / 4);
32
    }
33
    if (walkdir == "right")
34
    {
35
        if (walking == 0)
36
            x += myspeed;
37
        if (walking == 1)
38
            x += (myspeed / 4);
39
    }
40
}
41
if (touchcon == 1)
42
{
43
    with (obj_traffic_switch)
44
    {
45
        if (room == room_dw_mansion_traffic)
46
        {
47
            if (timefactor < 45)
48
                timefactor++;
49
        }
50
    }
51
    touchtimer = 0;
52
    spintimer = 0;
53
    touchcon = 2;
54
    snd_play(snd_cardrive);
55
    with (obj_mainchara)
56
        image_alpha = 0.5;
57
    if (instance_exists(obj_noelle_city_traffic_2) && instance_exists(obj_caterpillarchara))
58
    {
59
        obj_caterpillarchara.x = obj_noelle_city_traffic_2.x;
60
        obj_caterpillarchara.y = obj_noelle_city_traffic_2.y;
61
        if (obj_caterpillarchara.name == "noelle")
62
            obj_caterpillarchara.sprite_index = spr_noelle_shocked_dw;
63
        with (obj_noelle_city_traffic_2)
64
            instance_destroy();
65
    }
66
    with (obj_caterpillarchara)
67
    {
68
        if (image_alpha >= 0.5)
69
            image_alpha = 0.5;
70
    }
71
    global.facing = 0;
72
    
scr_move_to_charmarker
scr_move_to_charmarker

function
scr_move_to_charmarker(arg0, arg1, arg2)
{ var __myid = id; __arg0 = arg0; if (arg0 == "last" || arg0 == -1) { with (obj_charmarker) { if (lastmarker == 1) __myid.__arg0 = group; } } if (instance_exists(obj_charmarker)) obj_charmarker.__arg0 = __arg0; __marker[0] = -1; __marker[1] = -1; __marker[2] = -1; with (obj_charmarker) { if (group == __arg0 && char == 0) __myid.__marker[0] = id; if (group == __arg0 && char == 1) __myid.__marker[1] = id; if (group == __arg0 && char == 2) __myid.__marker[2] = id; } if (__marker[0] != -1 && __marker[1] == -1) __marker[1] = __marker[0]; if (__marker[1] != -1 && __marker[2] == -1) __marker[2] = __marker[1]; if (instance_exists(obj_mainchara) && __marker[0] != -1 && arg1 == 0) { obj_mainchara.__marker = __marker[0]; with (obj_mainchara) { fun = 1; __mover =
scr_move_to_point_over_time(__marker.x, __marker.goal_y_pos, arg2);
__mover.charmarker = 1; } } for (__ii = 0; __ii < 2; __ii++) { if (i_ex(global.cinstance[__ii]) && __marker[__ii + 1] != -1) { global.cinstance[__ii].__marker = __marker[__ii + 1]; with (global.cinstance[__ii]) { fun = 1; follow = 0; goaly = __marker.goal_y_pos; if (name == "susie") { if (global.darkzone == 1) goaly -= 16; if (global.darkzone == 0) goaly -= 6; } else { goaly -= 12; } __mover =
scr_move_to_point_over_time(__marker.x, goaly, arg2);
__mover.charmarker = 2; } } } }
(-1, 0, 30);
73
}
74
if (touchcon == 2)
75
{
76
    touchtimer++;
77
    spintimer++;
78
    if (spintimer >= 4)
79
    {
80
        if (global.facing == 2)
81
            global.facing = 3;
82
        if (global.facing == 1)
83
            global.facing = 2;
84
        if (global.facing == 0)
85
            global.facing = 1;
86
        else if (global.facing == 3)
87
            global.facing = 0;
88
        spintimer = 0;
89
    }
90
    if (touchtimer >= 30)
91
    {
92
        touchtimer = 0;
93
        touchcon = 0;
94
        with (obj_mainchara)
95
            image_alpha = 1;
96
        with (obj_caterpillarchara)
97
        {
98
            if (image_alpha == 0.5)
99
                image_alpha = 1;
100
        }
101
        global.facing = 0;
102
        global.interact = 0;
103
    }
104
}
105
buffer--;
106
if (
scr_debug
scr_debug

function
scr_debug()
{ return 0; }
())
107
{
108
}
109
if (active == 0 && madeblock == 0)
110
{
111
    myblock = instance_create(bbox_left, bbox_top, obj_soliddark);
112
    myblock.image_xscale = (bbox_right - bbox_left) / 40;
113
    myblock.image_yscale = (bbox_bottom - bbox_top) / 40;
114
    madeblock = 1;
115
}
116
if (active == 1 && madeblock == 1)
117
{
118
    with (myblock)
119
        instance_destroy();
120
    madeblock = 0;
121
}
122
if (place_meeting(x, y, obj_carTurner))
123
{
124
    if (turned == 0)
125
    {
126
        car = instance_create(x, y, obj_traffic_car);
127
        with (car)
128
        {
129
            myspeed = other.myspeed;
130
            walkdir = "right";
131
            remspeed = other.remspeed;
132
            group = other.group;
133
            walking = other.walking;
134
            active = other.active;
135
            touchcon = other.touchcon;
136
            touchtimer = other.touchtimer;
137
            speedadjust = 1;
138
            turned = 1;
139
        }
140
        if (madeblock == 1)
141
        {
142
            with (myblock)
143
                instance_destroy();
144
        }
145
        endme = 1;
146
    }
147
}
148
if (endme == 1)
149
{
150
    active = 0;
151
    visible = 0;
152
    if (touchcon == 0)
153
    {
154
        if (madeblock)
155
        {
156
            with (myblock)
157
                instance_destroy();
158
        }
159
        instance_destroy();
160
    }
161
}
162
if (speedadjust)
163
{
164
    var chardist = distance_to_object(obj_mainchara);
165
    if (chardist >= 200)
166
        idealspeed = 24;
167
    if (chardist < 200)
168
        idealspeed = max(chardist / 16, 10);
169
    myspeed = 
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; }
(myspeed, idealspeed, 1);
170
    var carcheck = instance_place(x, y, obj_traffic_car);
171
    if (carcheck != -4)
172
    {
173
        if (carcheck.freshness > freshness)
174
        {
175
            y -= 12;
176
            myspeed -= 12;
177
            myspeed = clamp(myspeed, 0, 24);
178
        }
179
    }
180
}