Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_battleblcon_Draw_0

(view raw script w/o annotations or w/e)
1
if (i_ex(mywriter))
2
{
3
    mywriter.depth = depth - 5;
4
    if (creator.object_index == obj_mizzle_enemy)
5
    {
6
        initwritingy = y + 4;
7
        y = creator.y + 40;
8
    }
9
    if (remmsgno != obj_writer.msgno)
10
        reformatted = 0;
11
    if (auto_length == 0)
12
    {
13
        init = 1;
14
        reformatted = 1;
15
    }
16
    if (reformatted == 0)
17
    {
18
        if (mywriter.formatted == 0)
19
        {
20
            with (mywriter)
21
                event_user(5);
22
        }
23
        if (mywriter.formatted == 1)
24
        {
25
            if (init == 0)
26
            {
27
                initwritingx = mywriter.writingx;
28
                initwritingy = mywriter.writingy;
29
                init = 1;
30
            }
31
            writingx = mywriter.writingx;
32
            writingy = mywriter.writingy;
33
            stringmax = mywriter.stringmax;
34
            hspace = mywriter.hspace;
35
            vspace = mywriter.vspace;
36
            linecount = mywriter.linecount;
37
            balloonwidth = (stringmax * hspace) + 10;
38
            balloonheight = ((linecount + 1) * vspace) + 5;
39
            if (global.lang == "ja")
40
            {
41
                var checkstring = mywriter.mystring;
42
                var spacing = mywriter.hspace;
43
                var stringlength = string_length(checkstring);
44
                var newmaxlength = 0;
45
                var currentlength = 0;
46
                for (var ii = 1; ii < (stringlength + 1); ii += 1)
47
                {
48
                    var mychar = string_char_at(checkstring, ii);
49
                    if (mychar == "&" || mychar == "\n")
50
                    {
51
                        currentlength = 0;
52
                    }
53
                    else if (mychar == "^" || mychar == "*")
54
                    {
55
                        ii++;
56
                    }
57
                    else if (mychar == "\\")
58
                    {
59
                        ii += 2;
60
                    }
61
                    else if (mychar == "/" || mychar == "%")
62
                    {
63
                    }
64
                    else if (ord(mychar) < 256 || (ord(mychar) >= 65377 && ord(mychar) <= 65439))
65
                    {
66
                        currentlength += (spacing * 0.5);
67
                    }
68
                    else
69
                    {
70
                        currentlength += spacing;
71
                    }
72
                    if (currentlength >= newmaxlength)
73
                        newmaxlength = currentlength;
74
                }
75
                balloonwidth = newmaxlength + 10;
76
            }
77
            if (side == 1)
78
            {
79
                mywriter.writingx = initwritingx - (balloonwidth + 20);
80
                mywriter.writingy = initwritingy - (balloonheight / 2);
81
                writingx = initwritingx - (balloonwidth + 20);
82
                writingy = initwritingy - (balloonheight / 2);
83
            }
84
            if (side == -1)
85
            {
86
                xoffset = 20;
87
                mywriter.writingx = initwritingx;
88
                mywriter.writingy = initwritingy - (balloonheight / 2);
89
                writingx = initwritingx;
90
                writingy = initwritingy - (balloonheight / 2);
91
            }
92
        }
93
    }
94
    if (auto_length == 0)
95
        draw_self();
96
    if (auto_length == 1 && init == 1)
97
    {
98
        blconscale = 1;
99
        if (balloonheight < 40)
100
            blconscale = 0.5;
101
        if (side == 1)
102
            draw_sprite_ext(spr_battleblcon_parts, 4, x, y, 1, blconscale, 0, c_white, 1);
103
        if (side == -1)
104
            draw_sprite_ext(spr_battleblcon_parts, 4, x - xoffset, y, -1, blconscale, 0, c_white, 1);
105
        if (side == 2)
106
            draw_sprite_ext(spr_battleblcon_parts, 6, (writingx - 6) + (balloonwidth / 2), writingy + balloonheight + 6, 1, blconscale, 0, c_white, 1);
107
        draw_set_color(c_white);
108
        var _y = 0;
109
        if (global.lang == "ja")
110
            _y = 1;
111
        ossafe_fill_rectangle(writingx - 10, (writingy - 5) + _y, writingx + balloonwidth, ((writingy + balloonheight) - 5) + _y, false);
112
        ossafe_fill_rectangle(writingx - 5, (writingy - 10) + _y, (writingx + balloonwidth) - 5, writingy + balloonheight + _y, false);
113
    }
114
    remmsgno = mywriter.msgno;
115
}