Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_mizzle_spotlight_controller_b_Create_0

(view raw script w/o annotations or w/e)
1
x = 
scr_get_box
scr_get_box

function
scr_get_box(arg0)
{ switch (arg0) { case 0: return obj_growtangle.x + (obj_growtangle.sprite_width * 0.5); break; case 1: return obj_growtangle.y - (obj_growtangle.sprite_height * 0.5); break; case 2: return obj_growtangle.x - (obj_growtangle.sprite_width * 0.5); break; case 3: return obj_growtangle.y + (obj_growtangle.sprite_height * 0.5); break; case 4: return obj_growtangle.x; break; case 5: return obj_growtangle.y; break; return false; } }
(4);
2
y = 
scr_get_box
scr_get_box

function
scr_get_box(arg0)
{ switch (arg0) { case 0: return obj_growtangle.x + (obj_growtangle.sprite_width * 0.5); break; case 1: return obj_growtangle.y - (obj_growtangle.sprite_height * 0.5); break; case 2: return obj_growtangle.x - (obj_growtangle.sprite_width * 0.5); break; case 3: return obj_growtangle.y + (obj_growtangle.sprite_height * 0.5); break; case 4: return obj_growtangle.x; break; case 5: return obj_growtangle.y; break; return false; } }
(5);
3
max_radius = 140;
4
spotlight_radius = 1.5707963267948966;
5
counter = 0;
6
counter_speed = 1;
7
counter_speed_goal = choose(-2, 2);
8
alert = false;
9
spot_rate = 0.1;
10
timer = 0;
11
sameattack = 0;
12
eye_power = 0;
13
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("counter_speed", counter_speed_goal * 0.5, counter_speed_goal, 24);
14
var _dir = 28;
15
var _len = 150;
16
for (var aa = 0; aa < 5; aa++)
17
    instance_create(x + lengthdir_x(_len, _dir + (30 * aa)), y + lengthdir_y(_len, _dir + (30 * aa)), obj_mizzle_spotlight_eye);
18
spotlight[0] = instance_create(x, y, obj_mizzle_spotlight);
19
spotlight[1] = instance_create(x, y, obj_mizzle_spotlight);
20
spotlight[2] = instance_create(x, y, obj_mizzle_spotlight);
21
22
spotlight_set_goal = function(arg0, arg1, arg2, arg3, arg4)
23
{
24
    scr_lerp_var_instance(id, "spotlight_radius", spotlight_radius, spotlight_radius + arg2, arg4);
25
    scr_lerp_var_instance(id, "counter_speed", counter_speed, arg3, arg4);
26
    if (eye_power == 0)
27
    {
28
        scr_lerp_var_instance(id, "x", x, arg0, arg4, 1, "out");
29
        scr_lerp_var_instance(id, "y", y, arg1, arg4, 1, "out");
30
    }
31
};
32
33
update_spotlights = function()
34
{
35
    if (!alert)
36
    {
37
        if (eye_power == 0)
38
        {
39
            for (var aa = 0; aa < 3; aa++)
40
            {
41
                spotlight[aa].x = x + lengthdir_x(sin(spotlight_radius) * max_radius, counter + (120 * aa));
42
                spotlight[aa].y = y + lengthdir_y(sin(spotlight_radius) * max_radius, counter + (120 * aa));
43
            }
44
        }
45
        else if (eye_power == 1)
46
        {
47
            for (var aa = 0; aa < 3; aa++)
48
            {
49
                spotlight[aa].x = x + (sin(timer * 0.02) * 30) + lengthdir_x(110 + (sin(spotlight_radius) * 10), counter + (120 * aa));
50
                spotlight[aa].y = y + (cos(timer * 0.027) * 30) + lengthdir_y(110 + (sin(spotlight_radius) * 10), counter + (120 * aa));
51
            }
52
        }
53
        else
54
        {
55
            for (var aa = 0; aa < 3; aa++)
56
            {
57
                spotlight[aa].x = x + lengthdir_x(120, counter + (120 * aa));
58
                spotlight[aa].y = y + lengthdir_y(120, counter + (120 * aa));
59
            }
60
        }
61
    }
62
    else
63
    {
64
        with (obj_mizzle_spotlight)
65
        {
66
            x = 
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; }
(x, obj_heart.x + 10, clamp(abs(x - (obj_heart.x + 10)) * other.spot_rate, 3, 10));
67
            y = 
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; }
(y, obj_heart.y + 10, clamp(abs(y - (obj_heart.y + 10)) * other.spot_rate, 3, 10));
68
        }
69
        spot_rate = 
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; }
(spot_rate, 1, 0.025);
70
    }
71
};
72
73
set_info = function()
74
{
75
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == sameattack)
76
        eye_power = 0;
77
    else
78
        eye_power = 
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() - sameattack;
79
    if (i_ex(obj_balthizard_enemy) && 
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 3)
80
        eye_power = 1;
81
    if (i_ex(obj_balthizard_enemy) && 
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == 2)
82
        eye_power = 1;
83
    if (
scr_monsterpop
scr_monsterpop

function
scr_monsterpop()
{ return global.monster[0] + global.monster[1] + global.monster[2]; }
() == sameattack)
84
    {
85
        with (obj_mizzle_spotlight)
86
        {
87
            image_xscale -= ((3 - other.sameattack) * 0.15);
88
            image_yscale -= ((3 - other.sameattack) * 0.15);
89
        }
90
    }
91
    update_spotlights();
92
};
93
94
update_spotlights();
95
alarm[0]
 = 32;
gml_Object_obj_mizzle_spotlight_controller_b_Alarm_0.gml

var frames; if (eye_power == 0) frames = 45 - ((3 - sameattack) * 7); else frames = 30; spotlight_set_goal(
scr_get_box(4) + irandom_range(-40, 40), 
scr_get_box(5) + irandom_range(-40, 40), 1.5707963267948966, counter_speed_goal, frames);
alarm[1]
 = frames;