Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_maus_basket_Step_0

(view raw script w/o annotations or w/e)
1
if (init == 0)
2
{
3
    visible = 1;
4
    for (i = 0; i < 3; i++)
5
    {
6
        mymonster[i] = 0;
7
        if (i_ex(global.monsterinstance[i]) && global.monster[i] == 1)
8
        {
9
            mymonster[i] = global.monsterinstance[i];
10
            if (cancatch[i])
11
            {
12
                if (mymonster[i].object_index == obj_maus_enemy)
13
                    ismaus[i] = 1;
14
                if (mymonster[i].sprite_width > biggestwidth)
15
                    biggestwidth = mymonster[i].sprite_width;
16
                if (mymonster[i].sprite_height > biggestheight)
17
                    biggestheight = mymonster[i].sprite_height;
18
            }
19
        }
20
    }
21
    image_xscale = (biggestwidth / sprite_width) * 1.2;
22
    image_yscale = (biggestheight / sprite_height) * 1.2;
23
    if (image_xscale <= 1)
24
        image_xscale = 1;
25
    if (image_yscale <= 1)
26
        image_yscale = 1;
27
    siner = random(100);
28
    y = cameray() - sprite_height;
29
    x = (camerax() + (camerawidth() / 2)) - (sprite_width / 2);
30
    basketx = x;
31
    x += (sin(siner / 5) * 120);
32
    magnitude = 50;
33
    var yy = cameray();
34
    
scr_move_to_point_over_time
scr_move_to_point_over_time

function
scr_move_to_point_over_time(arg0, arg1, arg2)
{ _mmm = instance_create(x, y, obj_move_to_point); _mmm.target = id; _mmm.movex = arg0; _mmm.movey = arg1; _mmm.movemax = arg2; return _mmm; }
(x, yy + 10, 15);
35
    for (i = 0; i < 3; i++)
36
    {
37
        if (mymonster[i] != 0)
38
        {
39
            monstersiner[i] = i * 4;
40
            monsterhit[i] = 0;
41
            mymonster[i].__baskety = cameray() + 100 + (70 * i);
42
            if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 1)
43
                mymonster[i].__baskety = cameray() + 240;
44
            if (cancatch[i])
45
            {
46
                monsterx[i] = camerax() + (camerawidth() / 2) + (sprite_width / 2);
47
                mymonster[i].__monsterx = monsterx[i] - (sin(monstersiner[i] / 7) * magnitude);
48
                with (mymonster[i])
49
                {
50
                    
scr_rememberxy
scr_rememberxy

function
scr_rememberxy()
{ ___myrememberx = x; ___myremembery = y; }
();
51
                    if (instance_exists(obj_mauswheel_enemy))
52
                        
scr_move_to_point_over_time
scr_move_to_point_over_time

function
scr_move_to_point_over_time(arg0, arg1, arg2)
{ _mmm = instance_create(x, y, obj_move_to_point); _mmm.target = id; _mmm.movex = arg0; _mmm.movey = arg1; _mmm.movemax = arg2; return _mmm; }
(__monsterx, y, 15);
53
                    else
54
                        
scr_move_to_point_over_time
scr_move_to_point_over_time

function
scr_move_to_point_over_time(arg0, arg1, arg2)
{ _mmm = instance_create(x, y, obj_move_to_point); _mmm.target = id; _mmm.movex = arg0; _mmm.movey = arg1; _mmm.movemax = arg2; return _mmm; }
(__monsterx, __baskety, 15);
55
                }
56
            }
57
            if (cancatch[i] == 0)
58
            {
59
                monsterx[i] = camerax() + camerawidth() + 200;
60
                with (mymonster[i])
61
                {
62
                    
scr_rememberxy
scr_rememberxy

function
scr_rememberxy()
{ ___myrememberx = x; ___myremembery = y; }
();
63
                    var xx = camerax() + camerawidth() + sprite_width;
64
                    
scr_move_to_point_over_time
scr_move_to_point_over_time

function
scr_move_to_point_over_time(arg0, arg1, arg2)
{ _mmm = instance_create(x, y, obj_move_to_point); _mmm.target = id; _mmm.movex = arg0; _mmm.movey = arg1; _mmm.movemax = arg2; return _mmm; }
(xx, y, 15);
65
                }
66
            }
67
            monsterhitbox[i] = instance_create((mymonster[i].x + (sprite_width / 2)) - 20, mymonster[i].y + sprite_height, obj_act_hitbox);
68
            monsterhitbox[i].image_xscale = 2;
69
            if (mymonster[i].object_index == obj_tasque_enemy)
70
                monsterhitbox[i].image_xscale = 6;
71
            monsterhitbox[i].image_yscale = 0.5;
72
            monsterhitbox[i].visible = false;
73
            monsterhitbox[i].which = i;
74
            monsterhitbox[i].parentid = mymonster[i];
75
        }
76
    }
77
    dropped = 0;
78
    sineradd = 0;
79
    con = 1;
80
    alarm[4]
 = 16;
gml_Object_obj_maus_basket_Alarm_4.gml

con += 1;
81
    init = 1;
82
}
83
if (init == 1)
84
{
85
    if (con == 2)
86
    {
87
        for (i = 0; i < 3; i++)
88
        {
89
            if (mymonster[i] > 0)
90
                mymonster[i].x = monsterx[i];
91
        }
92
        con = 3;
93
    }
94
    if (con == 3)
95
    {
96
        if (sineradd < 0.8)
97
            sineradd += 0.05;
98
        if (dropped == 0)
99
        {
100
            siner += sineradd;
101
            x = basketx + (sin(siner / 5) * 120);
102
            if (button3_p())
103
            {
104
                dropped = 1;
105
                vspeed = 16;
106
                gravity = 1;
107
                snd_play(snd_wallclaw);
108
            }
109
        }
110
        if (magnitude < 100)
111
            magnitude += 5;
112
        for (i = 0; i < 3; i++)
113
        {
114
            if (mymonster[i] > 0)
115
            {
116
                if (caught[i] == 1)
117
                {
118
                    mymonster[i].y = y - 5;
119
                    mymonster[i].x = lerp(mymonster[i].x, x, 0.1);
120
                }
121
                if (monsterhit[i] == 0)
122
                {
123
                    monstersiner[i] += sineradd;
124
                    if (cancatch[i] == 1)
125
                        mymonster[i].x = monsterx[i] - (sin(monstersiner[i] / 7) * magnitude);
126
                    monsterhitbox[i].y = mymonster[i].y + sprite_height;
127
                    monsterhitbox[i].x = (mymonster[i].x + (sprite_width / 2)) - 20;
128
                    if (ismaus[i] == 1)
129
                        monsterhitbox[i].x = (mymonster[i].x + (sprite_width / 2)) - 40;
130
                    if (mymonster[i].object_index == obj_tasque_enemy)
131
                    {
132
                        monsterhitbox[i].x = (mymonster[i].x + (sprite_width / 2)) - 68;
133
                        monsterhitbox[i].y = (mymonster[i].y + sprite_height) - 22;
134
                    }
135
                }
136
            }
137
        }
138
        if (dropped == 1)
139
        {
140
            if (y >= ((cameray() + 300) - sprite_height))
141
            {
142
                gravity = 0;
143
                vspeed = 0;
144
                con = 4;
145
                alarm[4]
 = 15;
gml_Object_obj_maus_basket_Alarm_4.gml

con += 1;
146
            }
147
        }
148
    }
149
}
150
if (con == 5)
151
{
152
    caughttotal = 0;
153
    for (i = 0; i < 3; i++)
154
    {
155
        if (mymonster[i] > 0)
156
        {
157
            with (mymonster[i])
158
                
scr_move_to_rememberxy
scr_move_to_rememberxy

function
scr_move_to_rememberxy(arg0)
{
scr_move_to_point_over_time(___myrememberx, ___myremembery, arg0);
}
(15);
159
            if (monsterhit[i] == 1)
160
            {
161
                caughttotal++;
162
                if (instance_exists(obj_mauswheel_enemy))
163
                    
scr_mercyadd
scr_mercyadd

function
scr_mercyadd(arg0, arg1)
{ global.mercymod[arg0] += arg1; if (global.mercymod[arg0] < 0) global.mercymod[arg0] = 0; if (global.mercymod[arg0] >= 100) global.mercymod[arg0] = 100; var _playsound = 1; if (arg1 <= 0) _playsound = 0; if (i_ex(obj_dmgwriter)) { with (obj_dmgwriter) { if (type == 5) _playsound = 0; } } if (_playsound) { var _pitch = 0.8; if (arg1 < 99) _pitch = 1; if (arg1 <= 50) _pitch = 1.2; if (arg1 <= 25) _pitch = 1.4; snd_play_x(snd_mercyadd, 0.8, _pitch); } __mercydmgwriter = instance_create(global.monsterx[arg0], (global.monstery[arg0] + 20) - (global.hittarget[arg0] * 20), obj_dmgwriter); __mercydmgwriter.damage = arg1; __mercydmgwriter.type = 5; global.hittarget[arg0]++; }
(i, 5);
164
                else
165
                    
scr_mercyadd
scr_mercyadd

function
scr_mercyadd(arg0, arg1)
{ global.mercymod[arg0] += arg1; if (global.mercymod[arg0] < 0) global.mercymod[arg0] = 0; if (global.mercymod[arg0] >= 100) global.mercymod[arg0] = 100; var _playsound = 1; if (arg1 <= 0) _playsound = 0; if (i_ex(obj_dmgwriter)) { with (obj_dmgwriter) { if (type == 5) _playsound = 0; } } if (_playsound) { var _pitch = 0.8; if (arg1 < 99) _pitch = 1; if (arg1 <= 50) _pitch = 1.2; if (arg1 <= 25) _pitch = 1.4; snd_play_x(snd_mercyadd, 0.8, _pitch); } __mercydmgwriter = instance_create(global.monsterx[arg0], (global.monstery[arg0] + 20) - (global.hittarget[arg0] * 20), obj_dmgwriter); __mercydmgwriter.damage = arg1; __mercydmgwriter.type = 5; global.hittarget[arg0]++; }
(i, 100);
166
            }
167
        }
168
    }
169
    if (caughttotal == 0)
170
    {
171
        with (maker)
172
            actfailure = 1;
173
    }
174
    if (trappingX)
175
    {
176
        if (caughttotal < 
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
())
177
        {
178
            with (maker)
179
                actfailure = 1;
180
        }
181
    }
182
    with (maker)
183
        actcon = 12;
184
    with (obj_act_hitbox)
185
        instance_destroy();
186
    vspeed = -16;
187
    con = 6;
188
}
189
if (con == 6)
190
{
191
    if (y <= -200)
192
    {
193
        instance_destroy();
194
        with (obj_mauswheel_enemy)
195
        {
196
            idlesprite = spr_mauswheel_idle;
197
            x -= 60;
198
            y -= 66;
199
        }
200
        with (obj_maus_trapping_fake_idle)
201
            instance_destroy();
202
    }
203
}