Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_teacup_bullet_Step_0

(view raw script w/o annotations or w/e)
1
if (cupDistanceFromCenter == 0)
2
    cupDistanceFromCenter = master.cupDistanceFromCenter;
3
circleX = lengthdir_x(cupDistanceFromCenter, spin);
4
circleY = lengthdir_y(cupDistanceFromCenter * 0.5, spin);
5
fakedepth = circleY / 16;
6
x = xstart + circleX;
7
if (bouncing)
8
    ystart = master.y;
9
y = (ystart + circleY) - bounceCurrent;
10
depth = master.depth - master.depthSeparation - circleY - 5;
11
if (obj_teacup.state == 5)
12
    spin += spinrate;
13
var _cutOffBonus = 0;
14
if (hitType == 5)
15
{
16
    spin = -master.spin + offsetAngle + 25;
17
    ystart += 4;
18
    depth = master.depth - 400;
19
    _cutOffBonus = 16;
20
}
21
sizefactor = fakedepth / 8;
22
image_xscale = 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; }
(image_xscale, 2 + sizefactor, 0.05);
23
image_yscale = image_xscale;
24
blendo = 0.3 - (sizefactor / 2);
25
if (blendo < 0)
26
    blendo = 0;
27
image_blend = merge_color(colClose, colFar, blendo);
28
cutOff = (y + sprite_height) - sprite_yoffset - ((master.y - _cutOffBonus) + circleY);
29
cutOff = max(cutOff, 0);
30
if (cutOff > sprite_height)
31
{
32
    if (hitType == 5)
33
    {
34
        with (master)
35
        {
36
            teaFilled += 0.05;
37
            swallownoise = 1;
38
        }
39
    }
40
    else
41
    {
42
        with (master)
43
            wooshnoise = 1;
44
    }
45
    instance_destroy();
46
}
47
if (hitType == 3)
48
{
49
    if (cutOff > 0 && bouncesLeft > 0 && !bouncing)
50
    {
51
        with (master)
52
            bouncenoise = 1;
53
        bouncesLeft--;
54
        bouncing = true;
55
        bounceHeight = 128;
56
        bounceTime = 1;
57
        bounceCurrent = 0;
58
        bounceProgress = (1/15) / bounceTime;
59
    }
60
    if (bouncing)
61
    {
62
        bounceProgress += ((1/30) / bounceTime);
63
        bounceCurrent = abs(sin(bounceProgress * pi) * bounceHeight);
64
        if (bounceProgress >= 1)
65
        {
66
            with (master)
67
                bouncenoise = 1;
68
            bouncesLeft--;
69
            bounceProgress--;
70
            if (bouncesLeft < 0)
71
            {
72
                bouncing = false;
73
                bounceCurrent = 0;
74
            }
75
        }
76
    }
77
}
78
if ((ystart - bounceCurrent) > (master.y - bulletHitHeight) && (cutOff / sprite_height) < groundForgiveness)
79
{
80
    var _cupChar = master.cup_char;
81
    for (var i = 0; i < master.partySize; i++)
82
    {
83
        if (master.bulletsApplyToAll || i == 0)
84
        {
85
            if (abs(angle_difference(spin, _cupChar[i].spin)) < bulletCollisionAngle)
86
            {
87
                debugHitThisFrame = true;
88
                switch (hitType)
89
                {
90
                    case 0:
91
                    case 3:
92
                    case 4:
93
                        target = 0;
94
                        global.inv = -1;
95
                        global.charinstance[0] = obj_mainchara;
96
                        global.charinstance[1] = global.cinstance[0];
97
                        global.charinstance[2] = global.cinstance[1];
98
                        for (var __j = 0; __j < 3; __j++)
99
                        {
100
                            if (i_ex(global.charinstance[__j]))
101
                            {
102
                                if (instance_exists(obj_teacup.cup_char[__j]))
103
                                {
104
                                    global.charinstance[__j].x = obj_teacup.cup_char[__j].x;
105
                                    global.charinstance[__j].y = obj_teacup.cup_char[__j].y;
106
                                }
107
                            }
108
                        }
109
                        with (obj_darkcontroller)
110
                            charcon = 1;
111
                        global.heartx = global.charinstance[0].x - camerax();
112
                        global.hearty = global.charinstance[0].y - cameray();
113
                        scr_damage_all_overworld
scr_damage_all_overworld

function scr_damage_all_overworld() { if (global.inv < 0) { scr_damage_cache(); remdamage = damage; remtarget = target; if (!instance_exists(obj_shake)) instance_create(0, 0, obj_shake); with (obj_dmgwriter) killactive = 1; snd_stop(snd_hurt1); snd_play(snd_hurt1); for (ti = 0; ti < 3; ti += 1) { global.inv = -1; damage = remdamage; target = ti; tdamage = damage; with (global.charinstance[target]) { hurt = 1; hurttimer = 0; } hpdiff = tdamage; if (hpdiff >= global.hp[global.char[target]]) hpdiff = global.hp[global.char[target]] - 1; d_cancel = 0; if (hpdiff <= 1) { d_cancel = 1; hpdiff = 0; } if (d_cancel == 0) { doomtype = -1; global.hp[global.char[target]] -= hpdiff; if (global.charinstance[target].visible == true) { dmgwriter = instance_create(global.charinstance[target].x, (global.charinstance[target].y + global.charinstance[target].myheight) - 24, obj_dmgwriter); dmgwriter.damage = hpdiff; dmgwriter.type = doomtype; } } if (global.hp[global.char[target]] < 1) global.hp[global.char[target]] = 1; } scr_damage_check(); gameover = 1; if (global.char[0] != 0 && global.hp[global.char[0]] > 2) gameover = 0; if (global.char[1] != 0 && global.hp[global.char[1]] > 2) gameover = 0; if (global.char[2] != 0 && global.hp[global.char[2]] > 2) gameover = 0; if (gameover == 1) scr_gameover(); target = remtarget; global.inv = global.invc * 40; } }
();
114
                        with (obj_shake)
115
                            instance_destroy();
116
                        with (obj_teacup)
117
                            shaketimer = 5;
118
                        break;
119
                    case 1:
120
                        image_blend = c_white;
121
                        with (master)
122
                        {
123
                            if (theScore == 0)
124
                                myPitch = 1;
125
                            snd_pitch(snd_play(snd_booster), myPitch);
126
                            riseSpeedBoost += other.boostAmount;
127
                            theScore++;
128
                            tutorialRide = false;
129
                            myPitch *= 1.05946;
130
                        }
131
                        if (room == room_dw_cyber_teacup_final)
132
                        {
133
                            with (obj_teacup_scoreboard)
134
                                theScore++;
135
                        }
136
                        break;
137
                    case 2:
138
                        break;
139
                    case 5:
140
                        break;
141
                }
142
                if (hitType != 5)
143
                {
144
                    with (instance_create_depth(x, y, depth, obj_teacup_bullet_dead))
145
                    {
146
                        sprite_index = other.sprite_index;
147
                        image_index = other.image_index;
148
                        image_speed = other.image_speed;
149
                        image_xscale = other.image_xscale + 0.2;
150
                        image_yscale = other.image_yscale + 0.2;
151
                        image_alpha = other.image_alpha;
152
                        image_blend = other.image_blend;
153
                        spriteWidthRoot = other.spriteWidthRoot;
154
                        spriteHeightRoot = other.spriteHeightRoot;
155
                        cutOff = other.cutOff;
156
                        master = other.master;
157
                        posY = y - master.y;
158
                    }
159
                    instance_destroy();
160
                }
161
            }
162
        }
163
    }
164
}
165
if (eatMe && hitType == 5)
166
{
167
    var _col = collision_point(x, y, obj_markercup, false, false);
168
    if (_col != -4 && _col.sprite_index == spr_teacup_susie_tea)
169
        instance_destroy();
170
}