Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_rouxls_simtown_Step_0

(view raw script w/o annotations or w/e)
1
if (MyTurn == 1)
2
{
3
    if (left_p())
4
    {
5
        if (CursorX > 0)
6
            CursorX -= 1;
7
    }
8
    if (right_p())
9
    {
10
        if (CursorX < 15)
11
            CursorX += 1;
12
    }
13
    if (up_p())
14
    {
15
        if (CursorY > 0)
16
            CursorY -= 1;
17
    }
18
    if (down_p())
19
    {
20
        if (CursorY < 5)
21
            CursorY += 1;
22
    }
23
    if (button1_p())
24
    {
25
        if (TileYouCanBuild[CursorX][CursorY] == 1)
26
        {
27
            HouseCount++;
28
            TileYouCanBuild[CursorX][CursorY] = 0;
29
            TileHasHouse[CursorX][CursorY] = 1;
30
            snd_play(snd_noise);
31
            obj_rouxls_enemy.hasplayerplacedhouses = 1;
32
            repeat (21)
33
            {
34
                instance_create(base_xpos + (CursorX * 40) + irandom(40), cameray() + ((CursorY + 1) * 40) + 40 + irandom(40), obj_house_placed_effect);
35
                instance_create(base_xpos + (CursorX * 40) + irandom(40), cameray() + ((CursorY + 1) * 40) + 40 + irandom(40), obj_house_placed_effect);
36
                scr_fx_housesquare
scr_fx_housesquare

function scr_fx_housesquare(arg0, arg1, arg2) { var gr = 0; for (i = 0; i < 3; i++) { gr = instance_create(arg0, arg1, obj_fx_growsquare); gr.color = arg2; gr.alarm[0] = 1 + (i * 3); gr.depth = depth - 10; } }
(base_xpos + (CursorX * 40) + 20, cameray() + ((CursorY + 1) * 40) + 40 + 20, 255);
37
            }
38
            scr_simtown_canbuild_check
scr_simtown_canbuild_check

function scr_simtown_canbuild_check() { YourAvailableTileTotal = 0; RouxlsAvailableTileTotal = 0; GameOver = 0; for (i = 0; i < 16; i += 1) { for (j = 0; j < 6; j += 1) { TileYouCanBuild[i][j] = 0; TileRouxlsCanBuild[i][j] = 0; if (TileLand[i][j] == 1 && TileHasHouse[i][j] == 0) { if (j > 0) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j - 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j - 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (j < 5) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j + 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j + 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (TileHasHouse[i - 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i - 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; } if (TileYouCanBuild[i][j] == 1) YourAvailableTileTotal += 1; if (TileRouxlsCanBuild[i][j] == 1) RouxlsAvailableTileTotal += 1; } } if (YourAvailableTileTotal == 0) GameOver = 1; if (RouxlsAvailableTileTotal == 0) GameOver = 1; }
();
39
            if (GameOver == 1 || HouseCount >= HouseCountMax)
40
            {
41
                MyTurn = 0;
42
                TurnCon = 1;
43
                HouseCount = 0;
44
            }
45
        }
46
    }
47
}
48
if (TurnCon == 1)
49
{
50
    scr_simtown_canbuild_check
scr_simtown_canbuild_check

function scr_simtown_canbuild_check() { YourAvailableTileTotal = 0; RouxlsAvailableTileTotal = 0; GameOver = 0; for (i = 0; i < 16; i += 1) { for (j = 0; j < 6; j += 1) { TileYouCanBuild[i][j] = 0; TileRouxlsCanBuild[i][j] = 0; if (TileLand[i][j] == 1 && TileHasHouse[i][j] == 0) { if (j > 0) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j - 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j - 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (j < 5) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j + 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j + 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (TileHasHouse[i - 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i - 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; } if (TileYouCanBuild[i][j] == 1) YourAvailableTileTotal += 1; if (TileRouxlsCanBuild[i][j] == 1) RouxlsAvailableTileTotal += 1; } } if (YourAvailableTileTotal == 0) GameOver = 1; if (RouxlsAvailableTileTotal == 0) GameOver = 1; }
();
51
    if (GameOver == 1)
52
    {
53
        event_user(0);
54
        if (instance_exists(obj_rouxls_enemy))
55
        {
56
            global.mnfight = 0;
57
            global.myfight = 3;
58
            obj_rouxls_enemy.actcon = 1;
59
            obj_rouxls_enemy.acting = -1;
60
            obj_rouxls_enemy.endbattle = 1;
61
            obj_rouxls_enemy.actresult = actresult;
62
        }
63
        TurnCon = 5;
64
        MyTurn = 0;
65
        with (obj_rouxls_enemy)
66
            actcon = 1;
67
    }
68
    else
69
    {
70
        with (obj_rouxls_enemy)
71
        {
72
            msgsetloc(0, 
* Finished!Wait for inputClose Message
"* Finished!/%", "obj_rouxls_simtown_slash_Step_0_gml_93_0"
);
73
            scr_battletext_default
scr_battletext_default

function scr_battletext_default() { global.fc = 0; global.typer = 4; scr_battletext(); return battlewriter; }
();
74
            actcon = 1;
75
        }
76
        TurnCon = 5;
77
        MyTurn = 0;
78
    }
79
}
80
if (TurnCon == 2)
81
{
82
    scr_simtown_canbuild_check
scr_simtown_canbuild_check

function scr_simtown_canbuild_check() { YourAvailableTileTotal = 0; RouxlsAvailableTileTotal = 0; GameOver = 0; for (i = 0; i < 16; i += 1) { for (j = 0; j < 6; j += 1) { TileYouCanBuild[i][j] = 0; TileRouxlsCanBuild[i][j] = 0; if (TileLand[i][j] == 1 && TileHasHouse[i][j] == 0) { if (j > 0) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j - 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j - 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (j < 5) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j + 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j + 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (TileHasHouse[i - 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i - 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; } if (TileYouCanBuild[i][j] == 1) YourAvailableTileTotal += 1; if (TileRouxlsCanBuild[i][j] == 1) RouxlsAvailableTileTotal += 1; } } if (YourAvailableTileTotal == 0) GameOver = 1; if (RouxlsAvailableTileTotal == 0) GameOver = 1; }
();
83
    RouxlsWaitTimer = 0;
84
    RouxlsHousesBuilt = 0;
85
    TurnCon = 3;
86
}
87
if (TurnCon == 3)
88
{
89
    RouxlsWaitTimer += 1;
90
    if (RouxlsWaitTimer >= 10)
91
    {
92
        if (RouxlsHousesBuilt < (RouxlsHouseMax - RalseiDistract) && GameOver == 0)
93
        {
94
            found = 0;
95
            while (found == 0)
96
            {
97
                RandomHouseX = floor(random(15));
98
                RandomHouseY = floor(random(6));
99
                if (RandomHouseY == 6)
100
                    RandomHouseY = 5;
101
                if (TileRouxlsCanBuild[RandomHouseX][RandomHouseY] == 1)
102
                    found = 1;
103
            }
104
            TileYouCanBuild[RandomHouseX][RandomHouseY] = 0;
105
            TileHasHouse[RandomHouseX][RandomHouseY] = 2;
106
            scr_simtown_canbuild_check
scr_simtown_canbuild_check

function scr_simtown_canbuild_check() { YourAvailableTileTotal = 0; RouxlsAvailableTileTotal = 0; GameOver = 0; for (i = 0; i < 16; i += 1) { for (j = 0; j < 6; j += 1) { TileYouCanBuild[i][j] = 0; TileRouxlsCanBuild[i][j] = 0; if (TileLand[i][j] == 1 && TileHasHouse[i][j] == 0) { if (j > 0) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j - 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j - 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (j < 5) { for (k = 0; k < 3; k += 1) { if (TileHasHouse[(i - 1) + k][j + 1] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[(i - 1) + k][j + 1] == 2) TileRouxlsCanBuild[i][j] = 1; } } if (TileHasHouse[i - 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i - 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 1) TileYouCanBuild[i][j] = 1; if (TileHasHouse[i + 1][j] == 2) TileRouxlsCanBuild[i][j] = 1; } if (TileYouCanBuild[i][j] == 1) YourAvailableTileTotal += 1; if (TileRouxlsCanBuild[i][j] == 1) RouxlsAvailableTileTotal += 1; } } if (YourAvailableTileTotal == 0) GameOver = 1; if (RouxlsAvailableTileTotal == 0) GameOver = 1; }
();
107
            RouxlsHousesBuilt += 1;
108
            RouxlsWaitTimer = 0;
109
            repeat (21)
110
            {
111
                instance_create(camerax() + (RandomHouseX * 40) + irandom(40), cameray() + ((RandomHouseY + 1) * 40) + 40 + irandom(40), obj_house_placed_effect);
112
                instance_create(camerax() + (RandomHouseX * 40) + irandom(40), cameray() + ((RandomHouseY + 1) * 40) + 40 + irandom(40), obj_house_placed_effect);
113
                scr_fx_housesquare
scr_fx_housesquare

function scr_fx_housesquare(arg0, arg1, arg2) { var gr = 0; for (i = 0; i < 3; i++) { gr = instance_create(arg0, arg1, obj_fx_growsquare); gr.color = arg2; gr.alarm[0] = 1 + (i * 3); gr.depth = depth - 10; } }
(camerax() + (RandomHouseX * 40) + 20, cameray() + ((RandomHouseY + 1) * 40) + 40 + 20, 16711680);
114
            }
115
            snd_play(snd_noise);
116
        }
117
        else
118
        {
119
            TurnCon = 4;
120
        }
121
    }
122
}
123
if (TurnCon == 4)
124
{
125
    if (GameOver == 1)
126
    {
127
        TurnCon = 1;
128
    }
129
    else
130
    {
131
        obj_rouxls_enemy.talked = 1;
132
        TurnCon = 5;
133
        Myturn = 0;
134
        RouxlsTurn++;
135
        HouseTensionCost = 0;
136
        if (RalseiDistract == 1)
137
            RalseiDistractTwice = 1;
138
        if (RalseiDistract == 0 && RalseiDistractTwice == 1)
139
            RalseiDistractTwice = 0;
140
        RalseiDistract = 0;
141
        if (RouxlsTurn > 2)
142
            RouxlsHouseMax = 3;
143
        if (RouxlsTurn > 5)
144
            RouxlsHouseMax = 4;
145
        with (obj_rouxls_enemy)
146
        {
147
            if (buildedblockstimer < 50)
148
                buildedblockstimer = 50;
149
        }
150
    }
151
}
152
CursorIdealVisualX = CursorX * 40;
153
CursorIdealVisualY = (CursorY * 40) + 80;
154
if (CursorVisualX > CursorIdealVisualX)
155
    CursorVisualX -= 20;
156
if (CursorVisualX < CursorIdealVisualX)
157
    CursorVisualX += 20;
158
if (CursorVisualY > CursorIdealVisualY)
159
    CursorVisualY -= 20;
160
if (CursorVisualY < CursorIdealVisualY)
161
    CursorVisualY += 20;