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 (331 lines) | stat: -rw-r--r-- 11,926 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331

-- -----------------------------------------------------------------
-- 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

        room.vzperac = 0
        room.blbecek = 0
        room.neprojedu = 0
        room.orybe = 0
        room.kecy = 0
        room.potvurka = 0
        room.onetopyrovi = 0

        return function()
            if isReady(small) and isReady(big) and no_dialog() then
                if look_at(small, netopyr) and small.Y > 17 and small.Y < 22 and room.vzperac == 0 and (netopyr.afaze == 2 or netopyr.afaze == 3) and random(100) < 4 then
                    addm(random(20), "jes-m-netopyr")
                    addv(random(5), "jes-v-tojo")
                    room.vzperac = 1
                elseif look_at(small, blbec) and dist(small, blbec) < 3 and room.blbecek == 0 and random(100) < 2 then
                    addm(random(5), "jes-m-tvor")
                    room.blbecek = 1
                elseif big.X == 3 and big.Y == 15 and tycka.X == 10 and tycka.Y == 15 and room.neprojedu == 0 and random(100) < 3 then
                    addv(0, "jes-v-uzke")
                    room.neprojedu = 1
                elseif look_at(small, rybka) and tycka.X == 10 and tycka.Y == 17 and random(100) < 30 and room.orybe == 0 then
                    room.orybe = 1
                    addm(random(5), "jes-m-ryba")
                    addv(random(5), "jes-v-kamen")
                elseif random(1000) < 3 and room.kecy == 0 then
                    switch(random(3)){
                        [0] = function()
                            addv(random(5), "jes-v-gral")
                        end,
                        [1] = function()
                            addv(random(5), "jes-v-gral")
                            addm(random(5), "jes-m-deprese")
                        end,
                        [2] = function()
                            addv(random(5), "jes-v-gral")
                            addm(random(5), "jes-m-deprese")
                            addv(random(5), "jes-v-nevim")
                        end,
                    }
                    room.kecy = 1
                elseif room.kecy == 1 and big.Y > 19 and random(100) < 30 then
                    addm(random(5), "jes-m-takvidis")
                    room.kecy = 2
                elseif room.potvurka == 0 and random(100) < 5 and look_at(small, das) and dist(small, das) < 4 then
                    switch(random(3)){
                        [0] = function()
                            addm(1, "jes-m-potvora0")
                        end,
                        [1] = function()
                            addm(1, "jes-m-potvora1")
                        end,
                        [2] = function()
                            addm(1, "jes-m-potvora2")
                        end,
                    }
                    switch(random(3)){
                        [0] = function()
                            addv(random(5), "jes-v-potvora0")
                        end,
                        [1] = function()
                            addv(random(5), "jes-v-potvora1")
                        end,
                        [2] = function()
                            addv(random(5), "jes-v-potvora2")
                        end,
                    }
                    room.potvurka = 1
                elseif room.onetopyrovi == 0 and look_at(small, netopyr) and dist(small, netopyr) < 4 and random(1000) < 2 then
                    room.onetopyrovi = 1
                    addm(1, "jes-m-netopyr0")
                    switch(random(3)){
                        [0] = function()
                            addv(random(5), "jes-v-netopyr0")
                        end,
                        [1] = function()
                            addv(random(5), "jes-v-netopyr1")
                        end,
                        [2] = function()
                            addv(random(5), "jes-v-netopyr2")
                        end,
                    }
                    switch(random(3)){
                        [0] = function()
                            addm(random(5), "jes-m-netopyr1")
                        end,
                        [1] = function()
                            addm(random(5), "jes-m-netopyr2")
                        end,
                        [2] = function()
                            addm(random(5), "jes-m-netopyr3")
                        end,
                    }
                elseif room.potvurka == 1 and das.X == 17 and das.Y == 7 and random(1000) < 4 then
                    switch(random(2)){
                        [0] = function()
                            addv(random(5), "jes-v-nechut0")
                        end,
                        [1] = function()
                            addv(random(5), "jes-v-nechut1")
                        end,
                    }
                    room.potvurka = 2
                end
            end
        end
    end

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

        netopyr.kridla = -(1 * (random(200) + 20))
        netopyr.oci = 0
        netopyr.vzpira = 0

        return function()
            if netopyr.oci == 0 and random(100) < 30 then
                netopyr.oci = 1
            elseif random(100) < 60 then
                netopyr.oci = 0
            end
            if tycka.X == 10 and tycka.Y == 15 and vaza.X == 18 and vaza.Y == 16 and netopyr.X == 18 and netopyr.Y == 19 then
                if netopyr.kridla < 0 then
                    netopyr.kridla = netopyr.kridla + 1
                elseif netopyr.kridla == 0 and netopyr.vzpira < 7 and tycka.X == 10 and tycka.Y == 15 and vaza.X == 18 and vaza.Y == 16 and netopyr.X == 18 and netopyr.Y == 19 then
                    netopyr.afaze = netopyr.oci + 2
                    netopyr.vzpira = netopyr.vzpira + 1
                elseif netopyr.vzpira >= 7 and netopyr.kridla == 0 then
                    netopyr.vzpira = 0
                    netopyr.kridla = -(1 * (random(300) + 5))
                    netopyr.afaze = netopyr.oci
                end
            else
                netopyr.afaze = netopyr.oci
            end
            netopyr:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_tycka()
        return function()
            if netopyr.afaze == 2 or netopyr.afaze == 3 then
                tycka.afaze = 1
            else
                tycka.afaze = 0
            end
            tycka:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_das()
        return function()
            switch(das.afaze){
                [1] = function()
                    if random(100) < 10 then
                        das.afaze = 6
                    else
                        das.afaze = das.afaze + 1
                    end
                end,
                [5] = function()
                    das.afaze = 0
                end,
                [8] = function()
                    das.afaze = 5
                end,
                default = function()
                    das.afaze = das.afaze + 1
                end,
            }
            das:updateAnim()
        end
    end

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

        blbec.faze = 0
        blbec.udivenej = 0

        return function()
            if math.mod(game_getCycles(), 2) == 0 then
                switch(blbec.faze){
                    [0] = function()
                        blbec.faze = blbec.faze + 1
                    end,
                    [1] = function()
                        blbec.faze = blbec.faze + 1
                    end,
                    [2] = function()
                        blbec.faze = 0
                    end,
                }
            end
            if blbec.dir ~= dir_no then
                blbec.udivenej = random(100) + 30
            end
            if blbec.udivenej > 0 then
                blbec.udivenej = blbec.udivenej - 1
                if random(100) < 20 then
                    blbec.afaze = 3 * blbec.faze + 1
                else
                    blbec.afaze = 3 * blbec.faze + 2
                end
            else
                blbec.afaze = 3 * blbec.faze
            end
            blbec:updateAnim()
        end
    end

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

        rybka.faze = -random(200) - 100

        return function()
            switch(rybka.faze){
                [1] = function()
                    rybka.afaze = 2
                    if random(100) < 25 then
                        rybka.faze = rybka.faze + 1
                    end
                end,
                [2] = function()
                    rybka.afaze = 1
                    rybka.faze = rybka.faze + 1
                end,
                [3] = function()
                    rybka.afaze = 3
                    if random(100) < 25 then
                        rybka.faze = rybka.faze + 1
                    end
                end,
                [4] = function()
                    rybka.afaze = 1
                    if random(100) < 15 then
                        rybka.faze = 1
                    else
                        rybka.faze = -random(200) - 100
                    end
                end,
                default = function()
                    if rybka.faze >= -10 and rybka.faze <= 0 then
                        rybka.afaze = 1
                        rybka.faze = rybka.faze + 1
                    else
                        rybka.afaze = 0
                        rybka.faze = rybka.faze + 1
                    end
                end
            }
            rybka:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_vaza()
        return function()
            if netopyr.afaze == 2 or netopyr.afaze == 3 then
                vaza.afaze = 1
            else
                vaza.afaze = 0
            end
            vaza:updateAnim()
        end
    end

    -- --------------------
    local update_table = {}
    local subinit
    subinit = prog_init_room()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_netopyr()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_tycka()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_das()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_blbec()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_rybka()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_vaza()
    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