Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj____Other_25

(view raw script w/o annotations or w/e)
1
spdtimer++;
2
if (spdtimer > 60 && spdtimer < 180)
3
    spd = lerp(5, 2, (spdtimer - 60) / 120);
4
if (spdtimer >= 180)
5
    spd = 2;
6
if (state == "init")
7
{
8
    image_index += 0.25;
9
    if (image_index >= 5)
10
    {
11
        image_index = 0;
12
        sprite_index = spr___;
13
        state = "move";
14
        active_hitbox = true;
15
    }
16
}
17
if (state == "move" && hurttimer == 0)
18
{
19
    if (movecon == 0)
20
    {
21
        if (move_type == 0)
22
        {
23
            movedir = choose(0, 1, 2, 3);
24
            repeat (4)
25
            {
26
                if (movedir == 0 && place_meeting(x + 32, y, obj_board_solid))
27
                    movedir = 1;
28
                if (movedir == 1 && place_meeting(x, y - 32, obj_board_solid))
29
                    movedir = 2;
30
                if (movedir == 2 && place_meeting(x - 32, y, obj_board_solid))
31
                    movedir = 3;
32
                if (movedir == 3 && place_meeting(x, y + 32, obj_board_solid))
33
                    movedir = 0;
34
            }
35
            movecon = 1;
36
        }
37
        if (move_type == 1)
38
        {
39
            is_moving = true;
40
            var x_cell = floor(obj_mainchara_board.x / global.cell_size);
41
            var y_cell = floor((obj_mainchara_board.y + 18) / global.cell_size);
42
            var position_x = (x_cell * global.cell_size) + (global.cell_size / 2);
43
            var position_y = (y_cell * global.cell_size) + (global.cell_size / 2);
44
            mp_grid_path(global.grid, path, x + 16, y + 16, position_x, position_y, false);
45
            if (spdtimer < 60)
46
                path_start(path, 3.8, path_action_stop, false);
47
            else if (spdtimer < 120)
48
                path_start(path, 3, path_action_stop, false);
49
            else
50
                path_start(path, 2, path_action_stop, false);
51
            movecon = 1;
52
        }
53
    }
54
    if (movecon == 1)
55
    {
56
        movetimer++;
57
        if (move_type == 0)
58
        {
59
            var stop = 0;
60
            repeat (spd)
61
            {
62
                if (stop == 0)
63
                {
64
                    if (movedir == 0)
65
                    {
66
                        x += 1;
67
                        image_index = 1;
68
                    }
69
                    if (movedir == 1)
70
                    {
71
                        y -= 1;
72
                        image_index = 2;
73
                    }
74
                    if (movedir == 2)
75
                    {
76
                        x -= 1;
77
                        image_index = 3;
78
                    }
79
                    if (movedir == 3)
80
                    {
81
                        y += 1;
82
                        image_index = 0;
83
                    }
84
                    if (movedir == 0 || movedir == 2)
85
                    {
86
                        if ((x % 32) == 0)
87
                        {
88
                            movecon = 0;
89
                            movetimer = 0;
90
                            stop = 1;
91
                        }
92
                    }
93
                    if (movedir == 1 || movedir == 3)
94
                    {
95
                        if ((y % 32) == 0)
96
                        {
97
                            movecon = 0;
98
                            movetimer = 0;
99
                            stop = 1;
100
                        }
101
                    }
102
                }
103
            }
104
            if ((stop == 1 && i_ex(obj_shadow_mantle_enemy) && obj_shadow_mantle_enemy.dashcon == 0) || (i_ex(obj_shadow_mantle_enemy) && obj_shadow_mantle_enemy.hp < 5))
105
            {
106
                var any_enemy_pathing = false;
107
                for (var i = 0; i < instance_number(obj___); i += 1)
108
                {
109
                    enemy[i] = instance_find(obj___, i);
110
                    if (enemy[i].move_type == 1)
111
                        any_enemy_pathing = true;
112
                }
113
                if (any_enemy_pathing == false)
114
                    move_type = 1;
115
            }
116
        }
117
        if (move_type == 1)
118
        {
119
            is_moving_timer++;
120
            if (is_moving_timer >= 8)
121
            {
122
                var x_cell = floor((x + 16) / global.cell_size);
123
                var y_cell = floor((y + 16) / global.cell_size);
124
                x = x_cell * global.cell_size;
125
                y = y_cell * global.cell_size;
126
                movecon = 0;
127
                movetimer = 0;
128
                is_moving_timer = 0;
129
                is_moving = false;
130
                path_end();
131
                speed = 0;
132
                if (i_ex(obj_shadow_mantle_enemy) && obj_shadow_mantle_enemy.dashcon > 0)
133
                    move_type = 0;
134
            }
135
        }
136
    }
137
}
138
scr_depth_board
scr_depth_board

function
scr_depth_board()
{ depth = 1000000 - ((y * 10) + ((sprite_height - sprite_yoffset) * 10)); } function scr_board_depth() {
scr_depth_board();
}
();
139
alivetimer++;
140
if (alivetimer >= 300 && state != "disappear")
141
{
142
    state = "disappear";
143
    sprite_index = spr___appear;
144
    image_index = 5;
145
    active_hitbox = false;
146
    snd_stop(snd_board_unsummon);
147
    snd_play(snd_board_unsummon);
148
    path_end();
149
    movecon = 0;
150
    movetimer = 0;
151
    is_moving_timer = 0;
152
    is_moving = false;
153
    speed = 0;
154
}
155
if (state == "disappear")
156
{
157
    active_hitbox = false;
158
    image_index -= 0.25;
159
    var drop_rate = 5;
160
    if (obj_mainchara_board.myhealth < 8)
161
        drop_rate += 25;
162
    if (obj_mainchara_board.myhealth < 3)
163
        drop_rate += 20;
164
    drop_rate += (global.shadow_mantle_losses * 2);
165
    if (drop_rate > 80)
166
        drop_rate = 80;
167
    if (image_index == 1 && hitdir > -1 && obj_shadow_mantle_enemy.darkcandydrop == false && irandom(100) < drop_rate && global.shadow_mantle_losses > 0)
168
    {
169
        if (global.shadow_mantle_losses < 7)
170
            obj_shadow_mantle_enemy.darkcandydrop = true;
171
        instance_create_depth(x, y, obj_mainchara_board.depth - 1000, obj_board_heal_pickup);
172
    }
173
    if (image_index < 0)
174
        instance_destroy();
175
}
176
if (place_meeting(x, y, obj_board_swordhitbox) && hurttimer == 0 && state != "disappear")
177
{
178
    path_end();
179
    hurttimer = 12;
180
    snd_stop(snd_board_damage);
181
    snd_play(snd_board_damage);
182
    active_hitbox = false;
183
    hitdir = obj_mainchara_board.facing;
184
    hit = 1;
185
}
186
if (place_meeting(x, y, obj_board_solid))
187
{
188
    x = xprevious;
189
    y = yprevious;
190
    speed = 0;
191
    path_end();
192
}
193
if (damagecon == 1)
194
{
195
    damagetimer++;
196
    if (damagetimer == 1)
197
    {
198
        path_end();
199
        is_moving = false;
200
        is_moving_timer = 0;
201
        speed = 0;
202
        move_type = 0;
203
        movecon = 0;
204
        movetimer = 0;
205
    }
206
    if (damagetimer == 40)
207
    {
208
        damagetimer = 0;
209
        damagecon = 0;
210
        active_hitbox = true;
211
    }
212
}
213
if (hit == 1)
214
    active_hitbox = false;