Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_tm_whip_animation_Step_0

(view raw script w/o annotations or w/e)
1
if (init == 0)
2
{
3
    whipball.quizmode = quizmode;
4
    if (quizmode)
5
        whipball.active = false;
6
    whipball.damage = damage;
7
    whipball.target = target;
8
    whipball.element = 6;
9
    init = 1;
10
    depth = global.monsterinstance[creator].depth;
11
    if (quizmode)
12
        state = -1;
13
}
14
if (quizloop && state == -1)
15
{
16
    quizloop = false;
17
    state = 0;
18
}
19
if (state == -1)
20
{
21
    if (lastState != -1)
22
    {
23
        timer = 0;
24
        attacktimer = 0;
25
        visible = 0;
26
        global.monsterinstance[creator].visible = 1;
27
        lastState = -1;
28
    }
29
    exit;
30
}
31
if (lastState == -1 && state != -1)
32
{
33
    visible = 1;
34
    global.monsterinstance[creator].visible = 0;
35
    lastState = state;
36
}
37
truetimer++;
38
if (state == 2)
39
    attacktimer = 45;
40
else
41
    attacktimer += animSpeed;
42
if (state == 0 && attacktimer >= 20)
43
    attacktimer = 19;
44
if (attacktimer == 5)
45
{
46
    if (!quizmode)
47
    {
48
        targetx = obj_heart.x + 8;
49
        targety = obj_heart.y + 8;
50
    }
51
    whipball.origx = targetx;
52
    whipball.origy = targety;
53
    attackoffset += 45;
54
}
55
if (zapping && (zaptimer % 5) < 1 && (quizmode || zaptimer < 15))
56
{
57
    var rotation = attackoffset;
58
    if (difficulty == 1)
59
        rotation += ((zaptimer / 5) * 15 * ((attackoffset == 45) ? -1 : 1));
60
    var balldirection = 0;
61
    if (rotateCracker)
62
    {
63
        var handx = x + xOffset[1];
64
        var handy = y + yOffset[1];
65
        balldirection = point_direction(targetx, targety, handx, handy);
66
    }
67
    if (!quizmode)
68
    {
69
        var loop = (difficulty == 1) ? 8 : 4;
70
        for (i = 0; i < loop; i++)
71
        {
72
            var d = instance_create(targetx, targety, obj_regularbullet);
73
            d.speed = 0.1;
74
            d.friction = -0.5;
75
            d.sprite_index = spr_tm_zap_bullet;
76
            d.timepoints = 0;
77
            d.direction = rotation + (((difficulty == 1) ? 45 : 90) * i) + balldirection;
78
            d.image_angle = d.direction + 90;
79
            d.damage = damage;
80
            d.element = 6;
81
            d.target = target;
82
        }
83
    }
84
    if (!quizmode && zaptimer >= 15)
85
        zapping = false;
86
}
87
if (zapping != whipball.active && !quizmode)
88
    whipball.active = zapping;
89
if (state == 2)
90
{
91
    if (!zapping)
92
        zaptimer = 0;
93
    else
94
        zaptimer += animSpeed;
95
}
96
if (state != lastState)
97
{
98
    if (state == 3)
99
    {
100
        zapping = false;
101
        zaptimer = 0;
102
        attacktimer = 56;
103
    }
104
    lastState = state;
105
}
106
if (state == 3 && attacktimer >= 59)
107
{
108
    timer = animConst;
109
    state = looping ? 5 : 4;
110
    lastState = 4;
111
}
112
if (state == 4 && attacktimer >= 65)
113
{
114
    whipball.dodraw = 0;
115
    if (!quizmode)
116
    {
117
        targetx = obj_heart.x + 8;
118
        targety = obj_heart.y + 8;
119
    }
120
    whipball.origx = targetx;
121
    whipball.origy = targety;
122
    if (quizmode && !quizloop)
123
    {
124
        state = -1;
125
    }
126
    else
127
    {
128
        if (quizloop)
129
            quizloop = false;
130
        state = 0;
131
        lastState = 0;
132
    }
133
    attacktimer = 5;
134
    attackoffset += 45;
135
}
136
if (state == 5 && attacktimer >= 65)
137
    whipball.dodraw = 0;