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 (321 lines) | stat: -rw-r--r-- 9,884 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

-- -----------------------------------------------------------------
-- Init
-- -----------------------------------------------------------------
local function prog_init()
    initModels()
    sound_playMusic("music/rybky07.ogg")
    local pokus = getRestartCount()
    local roompole = createArray(2)


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

        room.cas = random(100) + 10
        room.zakaz = 0

        return function()
            pom2 = 99
            if no_dialog() and isReady(small) and isReady(big) then
                if room.cas > 0 then
                    room.cas = room.cas - 1
                else
                    room.cas = random(1000) + 600
                    pom1 = roompole[1]
                    if math.mod(pom1, 4) == 2 then
                        if room.zakaz == 1 then
                            pom1 = pom1 + 1
                        end
                    end
                    pom2 = math.mod(pom1, 4)
                    pom1 = pom1 + 1
                    pom1 = math.mod(pom1, 4)
                    roompole[1] = pom1
                end
            end
            switch(pom2){
                [0] = function()
                    addm(7, "kni-m-svicny")
                    if pokus < 3 or random(3) > 0 then
                        addv(7, "kni-v-ber")
                    end
                end,
                [1] = function()
                    addv(7, "kni-v-prolezt")
                    addm(7, "kni-m-tloustka")
                    addv(7, "kni-v-padavko")
                    addm(7, "kni-m-hromado")
                    adddel(7)
                    planBusy(big, true)
                    addv(1, "kni-v-vypni")
                    planBusy(big, false)
                end,
                [2] = function()
                    addm(7, "kni-m-hrncirstvi")
                    addv(7, "kni-v-amforstvi")
                    addm(7, "kni-m-amfornictvi")
                end,
                [3] = function()
                    addm(7, "kni-m-mise")
                    addv(7, "kni-v-proc")
                    addm(7, "kni-m-cetky")
                    adddel(14)
                    planBusy(small, true)
                    addm(1, "kni-m-kramy")
                    planBusy(small, false)
                end,
            }
        end
    end

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

        universal.co = 0
        universal.kdo = 0
        local treasures = {}
        for i = 0, 2 do
            treasures[i] = getModelsTable()[universal.index + i]
        end

        return function()
            if universal.co == 0 then
                switch(random(10)){
                    [1] = function()
                        universal.co = 1
                    end,
                    [2] = function()
                        universal.co = 8
                    end,
                }
                if universal.co ~= 0 then
                    universal.kdo = random(3)
                end
            elseif isRange(universal.co, 1, 3) then
                treasures[universal.kdo].afaze = universal.co
                universal.co = universal.co + 1
            elseif isRange(universal.co, 4, 6) then
                treasures[universal.kdo].afaze = 7 - universal.co
                universal.co = universal.co + 1
            elseif isRange(universal.co, 8, 9) then
                treasures[universal.kdo].afaze = universal.co - 4
                universal.co = universal.co + 1
            elseif isRange(universal.co, 10, 11) then
                treasures[universal.kdo].afaze = 15 - universal.co
                universal.co = universal.co + 1
            else
                treasures[universal.kdo].afaze = 0
                universal.co = 0
            end
            treasures[universal.kdo]:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_big()
        return function()
            if big.Y < 18 then
                room.zakaz = 1
            end
        end
    end

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

        pc2.stav = 0

        return function()
            if pc2.stav > 0 then
                pc2.stav = pc2.stav - 1
            else
                pc2.stav = random(300) + 50
            end
            if isRange(pc2.stav, 2, 3) then
                pc2.afaze = pc2.afaze - 1
            elseif isRange(pc2.stav, 6, 7) then
                pc2.afaze = pc2.afaze + 1
            elseif pc2.stav == 8 then
                if random(2) == 1 then
                    pc2.afaze = 0
                else
                    pc2.afaze = 3
                end
            end
            pc2:updateAnim()
        end
    end

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

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

        pf2.afaze = random(2)
        pf2:updateAnim()
    end

    -- -------------------------------------------------------------
    local function prog_init_db1()
        return function()
            if db1.dir == dir_no then
                db1.afaze = 0
            else
                db1.afaze = 1
            end
            db1:updateAnim()
        end
    end

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

        pf1.afaze = random(2)
        pf1:updateAnim()
    end

    -- -------------------------------------------------------------
    local function prog_init_db2()
        return function()
            if db2.dir == dir_no then
                db2.afaze = 0
            else
                db2.afaze = 1
            end
            db2:updateAnim()
        end
    end

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

        pc1.stav = 0

        return function()
            if pc1.stav > 0 then
                pc1.stav = pc1.stav - 1
            else
                pc1.stav = random(300) + 50
            end
            if isRange(pc1.stav, 2, 3) then
                pc1.afaze = pc1.afaze - 1
            elseif isRange(pc1.stav, 6, 7) then
                pc1.afaze = pc1.afaze + 1
            elseif pc1.stav == 8 then
                if random(2) == 1 then
                    pc1.afaze = 0
                else
                    pc1.afaze = 3
                end
            end
            pc1:updateAnim()
        end
    end

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

        local crystals = {}
        for pom1 = 0, 9 do
            item = getModelsTable()[krystal.index + pom1]
            crystals[pom1] = item
            pom2 = random(7) * 4
            item.afaze = pom2
            item.glob1 = 0
            item.glob2 = pom2
        end

        return function()
            for key, item in pairs(crystals) do
                if item.glob1 == 0 then
                    if random(25) == 1 then
                        item.glob1 = item.glob1 + 1
                    end
                elseif isRange(item.glob1, 1, 5) then
                    item.glob1 = item.glob1 + 1
                elseif item.glob1 == 6 then
                    item.glob1 = 0
                end
                if isRange(item.glob1, 0, 3) then
                    pom2 = item.glob1
                elseif isRange(item.glob1, 4, 6) then
                    pom2 = 7 - item.glob1
                end
                item.afaze = item.glob2 + pom2
                item:updateAnim()
            end
        end
    end

    -- --------------------
    local update_table = {}
    local subinit
    subinit = prog_init_room()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_universal()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_big()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_pc2()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_switcher()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_pf2()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_db1()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_pf1()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_db2()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_pc1()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_krystal()
    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