Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_elnina_bouncingbullet_Step_0

(view raw script w/o annotations or w/e)
1
if (image_alpha < 1)
2
    image_alpha += 0.1;
3
var touchedbottom = 0;
4
var bottomy;
5
if (i_ex(obj_growtangle))
6
{
7
    var _sprite_width = 150;
8
    var _sprite_height = 150;
9
    var width = sprite_width / 4;
10
    var leftx = (obj_growtangle.x - (_sprite_width / 2)) + width;
11
    var rightx = (obj_growtangle.x + (_sprite_width / 2)) - width;
12
    bottomy = (obj_growtangle.y + (_sprite_height / 2)) - (sprite_height / 2);
13
    if (x < leftx)
14
    {
15
        hspeed = abs(hspeed);
16
        x += 2;
17
    }
18
    if (x > rightx)
19
    {
20
        hspeed = -abs(hspeed);
21
        x -= 2;
22
    }
23
    if (y > bottomy)
24
    {
25
        vspeed = -abs(vspeed) * 1.5;
26
        y -= 2;
27
        touchedbottom = 1;
28
    }
29
    x = clamp(x, leftx, rightx);
30
}
31
if (vspeed < 8)
32
    vspeed += 0.5;
33
if (abs(hspeed) > 6)
34
    hspeed *= 0.95;
35
bounce_buffer--;
36
if (touchedbottom && image_blend != c_white && image_blend != c_ltgray)
37
{
38
    if (difficulty >= 2)
39
    {
40
        snd_stop(snd_error);
41
        snd_play_x(snd_error, 0.6, 2);
42
        snd_play_x(snd_error, 0.6, 1.5 + random(0.2));
43
        var angleoffset = random_range(-20, 20);
44
        var bulletamount = 5;
45
        var baseangle = 90;
46
        var spread = 42;
47
        for (var i = 0; i < bulletamount; i++)
48
        {
49
            var mybullet = instance_create(x, bottomy + 8, obj_regularbullet);
50
            mybullet.sprite_index = spr_shutta_lightning;
51
            mybullet.speed = 1;
52
            mybullet.friction = -0.1;
53
            mybullet.depth = depth + 10;
54
            mybullet.direction = (baseangle - (spread * 2)) + (spread * i) + angleoffset;
55
            mybullet.image_angle = mybullet.direction;
56
            mybullet.image_speed = 0.25;
57
            mybullet.image_yscale = 0.5;
58
            scr_lerp_var_instance(mybullet, "image_alpha", 5, 0, 60, 0);
59
            with (mybullet)
60
                
scr_var_delay
scr_var_delay

function
scr_var_delay(arg0, arg1, arg2)
{
scr_script_delayed(scr_var, arg2, arg0, arg1);
} function scr_var_delayed(arg0, arg1, arg2) {
scr_script_delayed(scr_var, arg2, arg0, arg1);
} function scr_delay_var(arg0, arg1, arg2) {
scr_script_delayed(scr_var, arg2, arg0, arg1);
}
("active", 0, 50);
61
            
scr_doom
scr_doom

function
scr_doom(arg0 = id, arg1)
{ with (instance_create_depth(0, 0, 0, obj_doom)) { alarm[0] target = arg0; persistent = arg0.persistent; } }
(mybullet, 60);
62
            
scr_bullet_inherit
scr_bullet_inherit

function
scr_bullet_inherit(arg0)
{ if (i_ex(arg0)) { if (damage != -1) arg0.damage = damage; if (grazepoints != -1) arg0.grazepoints = grazepoints; if (timepoints != -1) arg0.timepoints = timepoints; if (inv != -1) arg0.inv = inv; if (target != -1) arg0.target = target; if (grazed != -1) arg0.grazed = 0; if (grazetimer != -1) arg0.grazetimer = 0; if (object_index == obj_dbulletcontroller) { arg0.creatorid = creatorid; arg0.creator = creator; } arg0.element = element; } }
(mybullet);
63
        }
64
        var shrinkmarker = 
scr_marker
scr_marker

function
scr_marker(arg0, arg1, arg2)
{ thismarker = instance_create(arg0, arg1, obj_marker); with (thismarker) { sprite_index = arg2; image_speed = 0; } return thismarker; }
(x, bottomy + 8, spr_ball_30);
65
        shrinkmarker.depth = depth + 9;
66
        shrinkmarker.image_xscale = 1;
67
        shrinkmarker.image_yscale = 1;
68
        
scr_doom
scr_doom

function
scr_doom(arg0 = id, arg1)
{ with (instance_create_depth(0, 0, 0, obj_doom)) { alarm[0] target = arg0; persistent = arg0.persistent; } }
(shrinkmarker, 20);
69
        
scr_lerpvar_instance
scr_lerpvar_instance

function
scr_lerpvar_instance()
{ __lerpvar = instance_create(0, 0, obj_lerpvar); __lerpvar.target = argument[0]; __lerpvar.varname = argument[1]; __lerpvar.pointa = argument[2]; __lerpvar.pointb = argument[3]; __lerpvar.maxtime = argument[4]; if (argument_count >= 6) __lerpvar.easetype = argument[5]; if (argument_count >= 7) __lerpvar.easeinout = argument[6]; return __lerpvar; } function scr_lerp_var_instance() { if (argument_count >= 6) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5);
else if (argument_count >= 7) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5, argument6);
else return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4);
} function scr_lerp_instance_var() { if (argument_count >= 6) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5);
else if (argument_count >= 7) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5, argument6);
else return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4);
}
(shrinkmarker, "image_xscale", 1, 0, 20, -1, "out");
70
        
scr_lerpvar_instance
scr_lerpvar_instance

function
scr_lerpvar_instance()
{ __lerpvar = instance_create(0, 0, obj_lerpvar); __lerpvar.target = argument[0]; __lerpvar.varname = argument[1]; __lerpvar.pointa = argument[2]; __lerpvar.pointb = argument[3]; __lerpvar.maxtime = argument[4]; if (argument_count >= 6) __lerpvar.easetype = argument[5]; if (argument_count >= 7) __lerpvar.easeinout = argument[6]; return __lerpvar; } function scr_lerp_var_instance() { if (argument_count >= 6) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5);
else if (argument_count >= 7) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5, argument6);
else return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4);
} function scr_lerp_instance_var() { if (argument_count >= 6) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5);
else if (argument_count >= 7) return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4, argument5, argument6);
else return
scr_lerpvar_instance(argument0, argument1, argument2, argument3, argument4);
}
(shrinkmarker, "image_yscale", 1, 0, 20, -1, "out");
71
    }
72
}
73
if (difficulty == 3)
74
{
75
    if (instance_number(object_index) < 2)
76
    {
77
        if (bounce_count < 56)
78
        {
79
            var newball = instance_create(obj_growtangle.x, cameray() + 20, object_index);
80
            newball.depth = depth + 1;
81
            newball.difficulty = 2;
82
            
scr_bullet_inherit
scr_bullet_inherit

function
scr_bullet_inherit(arg0)
{ if (i_ex(arg0)) { if (damage != -1) arg0.damage = damage; if (grazepoints != -1) arg0.grazepoints = grazepoints; if (timepoints != -1) arg0.timepoints = timepoints; if (inv != -1) arg0.inv = inv; if (target != -1) arg0.target = target; if (grazed != -1) arg0.grazed = 0; if (grazetimer != -1) arg0.grazetimer = 0; if (object_index == obj_dbulletcontroller) { arg0.creatorid = creatorid; arg0.creator = creator; } arg0.element = element; } }
(newball);
83
        }
84
    }
85
    if (instance_number(object_index) < 3)
86
    {
87
        if (bounce_count < 36)
88
        {
89
            var newball = instance_create(obj_growtangle.x, cameray() + 20, object_index);
90
            newball.depth = depth + 1;
91
            newball.sprite_index = spr_lamp_bullet;
92
            newball.difficulty = 0;
93
            newball.image_blend = c_ltgray;
94
            
scr_bullet_inherit
scr_bullet_inherit

function
scr_bullet_inherit(arg0)
{ if (i_ex(arg0)) { if (damage != -1) arg0.damage = damage; if (grazepoints != -1) arg0.grazepoints = grazepoints; if (timepoints != -1) arg0.timepoints = timepoints; if (inv != -1) arg0.inv = inv; if (target != -1) arg0.target = target; if (grazed != -1) arg0.grazed = 0; if (grazetimer != -1) arg0.grazetimer = 0; if (object_index == obj_dbulletcontroller) { arg0.creatorid = creatorid; arg0.creator = creator; } arg0.element = element; } }
(newball);
95
        }
96
    }
97
}
98
if (difficulty == 2)
99
{
100
    if (instance_number(object_index) < 2)
101
    {
102
        if (bounce_count < 10)
103
        {
104
            var newball = instance_create(obj_growtangle.x, cameray() + 20, object_index);
105
            newball.depth = depth + 1;
106
            newball.difficulty = 0;
107
            newball.image_blend = c_ltgray;
108
            
scr_bullet_inherit
scr_bullet_inherit

function
scr_bullet_inherit(arg0)
{ if (i_ex(arg0)) { if (damage != -1) arg0.damage = damage; if (grazepoints != -1) arg0.grazepoints = grazepoints; if (timepoints != -1) arg0.timepoints = timepoints; if (inv != -1) arg0.inv = inv; if (target != -1) arg0.target = target; if (grazed != -1) arg0.grazed = 0; if (grazetimer != -1) arg0.grazetimer = 0; if (object_index == obj_dbulletcontroller) { arg0.creatorid = creatorid; arg0.creator = creator; } arg0.element = element; } }
(newball);
109
        }
110
    }
111
}