File: code.lua

package info (click to toggle)
fillets-ng-data 0.6.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 73,664 kB
  • ctags: 2,328
  • sloc: makefile: 46
file content (276 lines) | stat: -rw-r--r-- 9,833 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276

-- -----------------------------------------------------------------
-- Init
-- -----------------------------------------------------------------
local function prog_init()
    initModels()
    sound_playMusic("music/rybky05.ogg")
    local pokus = getRestartCount()


    -- -------------------------------------------------------------
    local function prog_init_room()
        local pom1, pom2, pomb1, pomb2 = 0, 0, false, false

        if pokus < 3 then
            room.mzaval = 0
        elseif random(pokus) < 4 then
            room.mzaval = 0
        else
            room.mzaval = 1
        end
        room.vzaval = 0
        room.nezvladnu = 0
        room.lastu = 0
        room.matr = 0
        room.rozhovor = 500 + random(500 + pokus * 42)
        room.snm = 0
        room.nezv = 0
        room.uz = 0
        if random(pokus + 1) > 3 then
            room.chud = 1
        else
            room.chud = 0
        end
        room.vymena = 0
        room.pomv = 0

        return function()
            if no_dialog() then
                if isReady(small) and isReady(big) then
                    if room.mzaval == 0 and small.X > 43 and not small:isLeft() then
                        if random(game_getCycles()) < 100 then
                            addm(4, "uts-m-otresy")
                        end
                        room.mzaval = 1
                    end
                    if room.vzaval == 0 and big.X > 43 and not big:isLeft() then
                        if random(3 + pokus) < 4 then
                            addv(2, "uts-v-projet0")
                        else
                            addv(2, "uts-v-projet1")
                        end
                        room.vzaval = 1
                        room.mzaval = 1
                    end
                    if room.lastu == 0 and big.X < 7 and lastura.X < 3 and lastura.Y == 11 then
                        room.lastu = 1
                        addm(11, "uts-m-lastura")
                    end
                    if room.rozhovor <= game_getCycles() then
                        room.rozhovor = room.rozhovor + 6666 + random(pokus * 42)
                        addv(10, "uts-v-koraly")
                        if pokus < 4 or random(6) > 0 then
                            addm(10, "uts-m-tvorove")
                        end
                        if pokus == 1 or random(4) > 0 then
                            addv(10, "uts-v-mikroskop")
                            addm(10, "uts-m-zivocich")
                            if random(3) > 0 then
                                addm(10, "uts-m-zelvy")
                            end
                            if random(3) > 0 then
                                addm(10, "uts-m-batyskaf")
                            end
                        end
                    end
                    if room.snm == 0 and matrace.X == 37 and (snek1.X > 40 and snek1.Y == 6 or snek2.X > 40 and snek2.Y == 6) then
                        room.snm = 1
                        addm(0, "uts-m-snek")
                    end
                    if room.nezv == 0 and (snek1.Y == 13 or snek2.Y == 13) then
                        room.nezv = 1
                        addm(2, "uts-m-nezvedneme")
                    end
                    if room.uz == 0 and (dvere.X > snek1.X or dvere.X > snek2.X) and dvere.Y == 10 then
                        room.uz = 1
                        addv(6, "uts-v-konecne")
                        if random(pokus + room.chud * 6) < 4 then
                            addm(7, "uts-m-chudak")
                        end
                        room.chud = 1
                    end
                    if room.chud == 0 and (snek1.dir ~= dir_no or snek2.dir ~= dir_no) and random(100) == 1 then
                        room.chud = 1
                        addm(5, "uts-m-chudak")
                    end
                    if room.vymena == 0 and matrace.X > 15 and matrace.X < 21 and xdist(matrace, snek1) == 0 and xdist(matrace, snek2) == 0 then
                        pomb1 = snek1.Y + 1 == snek2.Y and snek2.Y + 1 == matrace.Y
                        pomb2 = snek2.Y + 1 == snek1.Y and snek1.Y + 1 == matrace.Y
                        if pomb1 or pomb2 then
                            if room.pomv == 0 then
                                room.pomv = 1
                                room.vymena = 20 + random(300 + pokus)
                            else
                                room.pomv = 2
                            end
                        end
                    end
                    if room.pomv == 2 then
                        room.vymena = -1
                        room.pomv = 0
                        addv(5, "uts-v-poradi")
                    end
                end
                if room.vymena > 0 then
                    room.vymena = room.vymena - 1
                end
                if room.matr == 0 and isReady(small) and dist(small, matrace) < 2 then
                    room.matr = 1
                    addm(7, "uts-m-matrace")
                end
                if room.nezvladnu == 0 and small:isOut() and isReady(big) and lastura.X == 11 then
                    room.nezvladnu = 1
                    addv(20, "uts-v-sam")
                end
            end
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_lastura()
        return function()
            local anim_table = {
                [0] = function()
                    if random(100) == 1 then
                        lastura.afaze = 1
                    end
                end,
                [1] = function() 
                    if random(10) == 1 then
                        lastura.afaze = random(5)
                    end
                end,
                [5] = function()
                    lastura.afaze = 4
                end,
                [6] = function()
                    if random(10) == 1 then
                        lastura.afaze = random(2) + 2
                    end
                end,
            }
            anim_table[2] = anim_table[1]
            anim_table[3] = anim_table[1]
            anim_table[4] = anim_table[1]

            switch(lastura.afaze)(anim_table)

            switch(lastura.dir){
                [dir_up] = function()
                    lastura.afaze = 5
                end,
                [dir_down] = function()
                    lastura.afaze = 0
                end,
                [dir_left] = function()
                    lastura.afaze = 6
                end,
                [dir_right] = function()
                    lastura.afaze = 1
                end,
            }
            lastura:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_snek1()
        return function()
            switch(snek1.afaze){
                [0] = function()
                    if snek1.dir ~= dir_no then
                        snek1.afaze = 1
                    elseif random(50) == 1 then
                        snek1.afaze = 2
                    end
                end,
                [1] = function()
                    if snek1.dir == dir_no and random(15) == 1 then
                        snek1.afaze = 2
                    end
                end,
                [2] = function()
                    local choice = random(20)
                    if choice == 1 then
                        snek1.afaze = 1
                    elseif 2 <= choice and choice <= 4 then
                        snek1.afaze = 3
                    end
                end,
                [3] = function()
                    if random(5) == 1 then
                        snek1.afaze = 0
                    end
                end,
            }
            snek1:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_snek2()
        return function()
            switch(snek2.afaze){
                [0] = function()
                    if snek2.dir ~= dir_no then
                        snek2.afaze = 1
                    elseif random(50) == 1 then
                        snek2.afaze = 2
                    end
                end,
                [1] = function()
                    if snek2.dir == dir_no and random(15) == 1 then
                        snek2.afaze = 2
                    end
                end,
                [2] = function()
                    local choice = random(20)
                    if choice == 1 then
                        snek2.afaze = 1
                    elseif 2 <= choice and choice <= 4 then
                        snek2.afaze = 3
                    end
                end,
                [3] = function()
                    if random(5) == 1 then
                        snek2.afaze = 0
                    end
                end,
            }
        end
    end

    -- --------------------
    local update_table = {}
    local subinit
    subinit = prog_init_room()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_lastura()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_snek1()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_snek2()
    if subinit then
        table.insert(update_table, subinit)
    end
    return update_table
end
local update_table = prog_init()


-- -----------------------------------------------------------------
-- Update
-- -----------------------------------------------------------------
function prog_update()
    for key, subupdate in pairs(update_table) do
        subupdate()
    end
end