Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_growtangle_electric_Step_0

(view raw script w/o annotations or w/e)
1
if (grazed == 1)
2
{
3
    grazetimer += 1;
4
    if (grazetimer >= 30)
5
    {
6
        grazetimer = 0;
7
        grazed = 0;
8
    }
9
}
10
if (instance_exists(obj_growtangle))
11
{
12
    if (con == 0)
13
    {
14
        timer++;
15
        if (type == 1)
16
        {
17
            plugxend = -23;
18
            plugx = lerp(plugx, plugxend, 0.2);
19
        }
20
        else
21
        {
22
            plugxend = 0;
23
            plugx = lerp(plugx, plugxend, 0.15);
24
        }
25
        plugalpha = lerp(plugalpha, 1, 0.1);
26
        if (timer >= 15 && timer <= 25)
27
        {
28
            obj_growtangle.x = obj_growtangle.xstart + random_range((-35 + timer) / 2, (35 - timer) / 2);
29
            obj_growtangle.y = obj_growtangle.ystart + random_range((-35 + timer) / 2, (35 - timer) / 2);
30
        }
31
        if (timer >= 15)
32
        {
33
            plugalpha = 1;
34
            plugx = plugxend;
35
            image_alpha += 0.1;
36
            if (image_alpha >= 1)
37
                active = 1;
38
            else
39
                active = 0;
40
        }
41
        if (timer >= 25)
42
        {
43
            con = 1;
44
            timer = 0;
45
            plugx = 0;
46
        }
47
    }
48
    if (con == 1)
49
    {
50
        timer++;
51
        shottimer++;
52
        if (type == 0)
53
            moveamount = sin(timer / 20) * amplitude;
54
        if (type == 1)
55
            moveamount = 1;
56
        shotthreshold = 8;
57
        if (type == 1)
58
            shotthreshold = 15;
59
        if (shottimer >= shotthreshold)
60
        {
61
            shottimer = 0;
62
            lightning = instance_create(-100, y, obj_growtangle_spark);
63
            with (lightning)
64
            {
65
                
scr_bullet_init
scr_bullet_init

function
scr_bullet_init()
{ grazed = 0; grazetimer = 0; destroyonhit = 1; target = 0; inv = 60; damage = 10; element = 0; grazepoints = 1; timepoints = 1; active = 1; updateimageangle = 0; }
();
66
                destroyonhit = 1;
67
            }
68
            if (speedmode == 1)
69
            {
70
                wx = lengthdir_x(obj_growtangle.sprite_width / 2, image_angle);
71
                wy = lengthdir_y(obj_growtangle.sprite_width / 2, image_angle);
72
                if (moveamount > 0)
73
                {
74
                    lightning.x = x + xx + wx;
75
                    lightning.y = y + yy + wy;
76
                    lightning.gravity_direction = 180 + image_angle;
77
                }
78
                if (moveamount < 0)
79
                {
80
                    lightning.x = (x + xx) - wx;
81
                    lightning.y = y + yy + wy;
82
                    lightning.gravity_direction = image_angle;
83
                }
84
                lightning.direction = lightning.gravity_direction + 180;
85
                lightning.speed = 5 + random(1);
86
                lightning.depth = depth - 5;
87
                if (type == 1)
88
                    lightning.speed = 6 + random(1);
89
                with (lightning)
90
                    motion_add(direction + choose(90, 270), random(1.5));
91
            }
92
            lightning.gravity = 0.3;
93
            lightning.image_xscale = 1.5;
94
            lightning.image_yscale = 1.5;
95
            with (lightning)
96
            {
97
                if (instance_exists(obj_queen_enemy))
98
                    damage = global.monsterat[obj_queen_enemy.myself] * 5;
99
            }
100
            
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; arg0.element = element; } }
(lightning);
101
            lightning.active = 1;
102
            lightning.sprite_index = spr_growtangle_elecbullet;
103
        }
104
        if (timer >= 150)
105
        {
106
            if (amplitude > 0)
107
                amplitude -= 2;
108
        }
109
        else
110
        {
111
            amplitude = lerp(amplitude, maxamplitude, 0.1);
112
        }
113
        if (type == 0)
114
            obj_growtangle.x = obj_growtangle.xstart + moveamount;
115
        if (type == 1)
116
        {
117
            moveamount = sin(timer / 20) * amplitude;
118
            obj_growtangle.x = obj_growtangle.xstart + moveamount;
119
            obj_growtangle.image_angle += 1.9565217391304348;
120
        }
121
        if (amplitude <= 0 && timer >= 230 && global.turntimer > 2)
122
            global.turntimer = 2;
123
    }
124
    x = obj_growtangle.x - xx;
125
    y = obj_growtangle.y - yy;
126
    image_xscale = obj_growtangle.image_xscale;
127
    image_yscale = obj_growtangle.image_yscale;
128
    image_angle = obj_growtangle.image_angle;
129
}
130
else
131
{
132
    instance_destroy();
133
}