Undertale script viewer

← back to main script listing

gml_Object_obj_battlecontroller_Draw_0

(view raw script w/o annotations or w/e)
1
if (global.turntimer > 0)
2
{
3
    depth = -1000;
4
    draw_set_color(c_red);
5
    global.turntimer -= 1;
6
}
7
if (instance_exists(obj_uborder))
8
{
9
    depth = 5;
10
    draw_set_color(c_black);
11
    if (drawrect == 1)
12
        ossafe_fill_rectangle(obj_uborder.x + 5, obj_uborder.y + 5, obj_rborder.x, obj_dborder.y);
13
}
14
if (background_color != c_white && drawbinfo == 1)
15
    script_execute(scr_binfowrite);
16
if (global.bmenuno == 1 && global.myfight == 0 && global.mnfight == 0)
17
{
18
    var maxwidth = 0;
19
    for (var i = 0; i < 3; i++)
20
    {
21
        if (global.monster[i] == 1)
22
        {
23
            var name = global.monstername[i];
24
            var width;
25
            if (global.language == "ja")
26
            {
27
                width = 0;
28
                for (var j = 1; j <= strlen(name); j++)
29
                {
30
                    var ch = ord(string_char_at(name, j));
31
                    if (ch == 32 || ch >= 65377)
32
                        width += 13;
33
                    else if (ch < 8192)
34
                        width += 16;
35
                    else
36
                        width += 26;
37
                }
38
            }
39
            else
40
            {
41
                width = strlen(name) * 16;
42
            }
43
            if (width > maxwidth)
44
                maxwidth = width;
45
        }
46
    }
47
    xwrite = 190 + maxwidth;
48
    for (var i = 0; i < 3; i++)
49
    {
50
        if (global.monster[i] == 1 && !instance_exists(obj_sansb))
51
        {
52
            draw_set_color(c_red);
53
            var lineheight = 32;
54
            var y_start = 280;
55
            if (global.language == "ja")
56
                lineheight = 36;
57
            draw_rectangle(xwrite, y_start + (i * lineheight), xwrite + 100, y_start + (i * lineheight) + 16, false);
58
            draw_set_color(c_lime);
59
            draw_rectangle(xwrite, y_start + (i * lineheight), xwrite + ((global.monsterhp[i] / global.monstermaxhp[i]) * 100), y_start + (i * lineheight) + 16, false);
60
        }
61
    }
62
}
63
if (global.language == "ja" && global.bmenuno >= 3 && global.bmenuno < 4 && global.myfight == 0 && global.mnfight == 0)
64
{
65
    var first = (global.bmenuno - 3) * 8;
66
    scr_setfont
scr_setfont

var newfont = argument0; if (global.language == "ja") { if (newfont == fnt_main) newfont = fnt_ja_main; if (newfont == fnt_maintext) newfont = fnt_ja_maintext; if (newfont == fnt_plain) newfont = fnt_ja_plain; } draw_set_font(newfont);
(fnt_main);
67
    draw_set_color(c_white);
68
    var xx = global.idealborder[0] + 20;
69
    var yy = global.idealborder[2] + 20;
70
    var lineheader = 
*
scr_gettext
scr_gettext

var text_id = argument[0]; var text = ds_map_find_value(global.text_data_en, text_id); if (is_undefined(text)) text = ""; if (global.language == "ja") { var loc_text = ds_map_find_value(global.text_data_ja, text_id); if (!is_undefined(loc_text)) text = loc_text; } for (var i = 1; i <= (string_length(text) - 3); i++) { if (string_copy(text, i, 2) == "\[" && string_char_at(text, i + 3) == "]") { var sel = string_char_at(text, i + 2); var replace; if (sel == "C") replace = global.charname; else if (sel == "G") replace = string(global.gold); else if (sel == "I") replace = global.itemname[global.menucoord[1]]; else if (sel == "1" && argument_count > 1) replace = argument[1]; else if (sel == "2" && argument_count > 2) replace = argument[2]; else if (sel == "3" && argument_count > 3) replace = argument[3]; else if (sel == "4" && argument_count > 4) replace = argument[4]; else if (sel == "5" && argument_count > 5) replace = argument[5]; else if (sel == "6" && argument_count > 6) replace = argument[6]; else if (sel == "7" && argument_count > 7) replace = argument[7]; else if (sel == "8" && argument_count > 8) replace = argument[8]; else if (sel == "9" && argument_count > 9) replace = argument[9]; else replace = ""; var before = string_copy(text, 1, i - 1); var after = string_copy(text, i + 4, string_length(text)); text = before + replace + after; i += (string_length(replace) - 1); } } return text;
("item_menub_header")
;
71
    for (var i = 0; i < 3 && global.item[first + i] != 0; i++)
72
        draw_text(xx, yy + (i * 36), lineheader + global.itemnameb[first + i]);
73
    var num_items = 8;
74
    while (num_items > 0 && global.item[num_items - 1] == 0)
75
        num_items--;
76
    if (num_items > 3)
77
    {
78
        xx = global.idealborder[1] - 30;
79
        yy = floor((global.idealborder[2] + global.idealborder[3]) / 2) - (5 * (2 + num_items));
80
        var arrow_yofs = round(min((obj_time.time % 30) / 30, 0.5) * 6);
81
        if (first > 0)
82
            draw_sprite(spr_bitem_ja_arrow, 0, xx, yy - arrow_yofs);
83
        yy += 10;
84
        for (var i = 0; i < num_items; i++)
85
        {
86
            var spr;
87
            if ((first + global.bmenucoord[3]) == i)
88
                spr = 45;
89
            else
90
                spr = 44;
91
            draw_sprite(spr, 0, xx, yy);
92
            yy += 10;
93
        }
94
        if ((first + 3) < num_items)
95
            draw_sprite_ext(spr_bitem_ja_arrow, 0, xx, yy + 10 + arrow_yofs, 1, -1, 0, c_white, 1);
96
    }
97
}