Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_kikky_Step_0

related scripts: Create_0Draw_0Step_0

(view raw script w/o annotations or w/e)
1
var _dentaltoy = 0;
2
var _negative = 0;
3
if (i_ex(obj_dentalchew))
4
{
5
    _dentaltoy = 1;
6
    if (target == -1 || !i_ex(target))
7
        target = instance_find(obj_dentalchew, 0);
8
}
9
if (_dentaltoy)
10
{
11
    big_timer = 0;
12
    if (!i_ex(target))
13
    {
14
        speed = 0;
15
        _dentaltoy = 0;
16
    }
17
    else if (instance_number(true))
18
    {
19
        for (i = 0; i < instance_number(obj_dentalchew); i++)
20
        {
21
            var _o = instance_find(obj_dentalchew, i);
22
            if (_o.action != 2)
23
                target = _o;
24
        }
25
    }
26
}
27
big_timer++;
28
if (big_timer == 900)
29
{
30
    snd_play(snd_kikkyexplosion);
31
    sprite_index = spr_kikky_bigtummy;
32
    speed = 0;
33
    kikky_has_a_big_tummy = 1;
34
}
35
if (active)
36
    happiness = 
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; }
(happiness, -99999, 1);
37
if (happiness < 0 && !_dentaltoy)
38
{
39
    _negative = 1;
40
    speed = 0;
41
}
42
if (_negative)
43
{
44
    shake_timer++;
45
    if (shake_timer > 20)
46
    {
47
        xx = irandom_range(2, 4) * choose(1, -1) * vibration;
48
        yy = irandom_range(2, 4) * choose(1, -1) * vibration;
49
    }
50
    if (shake_timer > 25)
51
    {
52
        xx = 0;
53
        yy = 0;
54
        shake_timer = irandom_range(-10, 0);
55
    }
56
    vibration_timer++;
57
    if (vibration_timer >= 60 && vibration < 1)
58
    {
59
        vibration_timer = 0;
60
        vibration += 0.1;
61
    }
62
    meow_timer++;
63
    if (meow_timer > (meow_max - meow_cutoff))
64
    {
65
        if (meow_sfx != -1 && happiness > -600)
66
            snd_stop(snd_meow);
67
        meow_sfx = snd_play(snd_meow, undefined, random_range(0.3, 0.6));
68
        meow_timer = 0;
69
        meow_max = irandom_range(40, 80);
70
    }
71
    if (happiness < -600)
72
    {
73
        meow_cutoff_timer++;
74
        if (meow_cutoff_timer > 59)
75
        {
76
            meow_cutoff_timer = 0;
77
            meow_cutoff = 
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; }
(meow_cutoff, 60, 1);
78
        }
79
    }
80
}
81
else
82
{
83
    vibration = 0;
84
    meow_cutoff = 0;
85
    meow_cutoff_timer = 0;
86
}
87
if (sprite_index == spr_kikky_bigtummy && speed > 0)
88
{
89
    sprite_index = spr_kikky_walk;
90
    kikky_has_a_big_tummy = 0;
91
}
92
if (!kikky_has_a_big_tummy && !_dentaltoy && !_negative)
93
{
94
    timer++;
95
    if (speed == 0)
96
    {
97
        if (timer > reset)
98
        {
99
            hspeed = choose(1, -1) * spd;
100
            reset = irandom_range(1, 8) * 30;
101
            timer = 0;
102
        }
103
    }
104
    else if (timer > reset)
105
    {
106
        hspeed = 0;
107
        reset = irandom_range(1, 4) * 30;
108
        timer = 0;
109
    }
110
}
111
if (hit_dental_toy)
112
{
113
    sprite_index = spr_kikky_attack;
114
    timer++;
115
    if (timer > 30)
116
    {
117
        with (target)
118
            instance_destroy();
119
        hit_dental_toy = 0;
120
        sprite_index = spr_kikky_walk;
121
    }
122
}
123
else if (_dentaltoy)
124
{
125
    if (i_ex(target) && target.action == 1)
126
    {
127
        motion_set(point_direction(x, y, target.x, target.y), 8);
128
        if (point_distance(x, y, target.x, target.y) < 20)
129
        {
130
            timer = 0;
131
            hit_dental_toy = 1;
132
            image_speed = 1;
133
            speed = 0;
134
            with (obj_kikky)
135
                happiness = 100;
136
            active = 1;
137
            snd_play(snd_kikkycan);
138
            var _id = id;
139
            with (target)
140
            {
141
                action = 2;
142
                image_xscale = choose(1, -1);
143
                motion_set(point_direction(_id.x, _id.y, x, y), 12);
144
            }
145
        }
146
    }
147
}
148
if (speed > 0)
149
    image_xscale = sign(hspeed);
150
if (image_xscale == 0)
151
    image_xscale = choose(1, -1);
152
if (!hit_dental_toy)
153
    image_speed = abs(hspeed) / 2;
154
if (x < 80)
155
{
156
    x = 80;
157
    hspeed = -hspeed;
158
}
159
if (x > 540)
160
{
161
    x = 540;
162
    hspeed = -hspeed;
163
}
164
if (y < 40)
165
{
166
    y = 40;
167
    vspeed = -vspeed;
168
}
169
if (y > 250)
170
{
171
    y = 250;
172
    vspeed = -vspeed;
173
}