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 (273 lines) | stat: -rw-r--r-- 8,808 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

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



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

        room.uvod = 0
        room.obudikovi = 0
        room.okramech = randint(1000, 3000)
        room.olodi = 0
        room.sbirka = randint(300, 1200)

        return function()
            if isReady(small) and isReady(big) and no_dialog() then
                if room.okramech > 0 then
                    room.okramech = room.okramech - 1
                end
                if room.sbirka > 0 then
                    room.sbirka = room.sbirka - 1
                end
                if room.uvod == 0 then
                    room.uvod = 1
                    addm(randint(15, 30), "sm-m-prolezame")
                    switch(random(3)){
                        [0] = function()
                            addv(random(5), "sm-v-jine0")
                        end,
                        [1] = function()
                            addv(random(5), "sm-v-jine1")
                        end,
                        [2] = function()
                            addv(random(5), "sm-v-jine2")
                        end,
                    }
                elseif room.obudikovi == 0 and look_at(small,budik) and dist(small,budik) < 3 and random(100) < 1 then
                    room.obudikovi = 1
                    addv(0, "sm-v-budik")
                    if random(2) < 1 then
                        addm(random(5), "sm-m-normalni")
                    end
                elseif room.okramech == 0 then
                    room.okramech = randint(1000, 3000)
                    switch(random(4)){
                        [0] = function()
                            addm(random(10), "sm-m-kramy0")
                        end,
                        [1] = function()
                            addm(random(10), "sm-m-kramy1")
                        end,
                        [2] = function()
                            addv(random(10), "sm-v-kramy2")
                        end,
                        [3] = function()
                            addv(random(10), "sm-v-kramy3")
                        end,
                    }
                elseif room.olodi == 0 and lod.dir ~= dir_no then
                    room.olodi = 1
                    switch(random(2)){
                        [0] = function()
                            addv(random(7), "sm-v-lod")
                            addm(random(7), "sm-m-dedek")
                            addv(random(7), "sm-v-charon")
                            addm(random(7), "sm-m-codela")
                        end,
                        [1] = function()
                            addv(random(7), "sm-v-charon")
                            addm(random(7), "sm-m-codela")
                        end,
                    }
                    switch(random(2)){
                        [0] = function()
                            addv(random(7), "sm-v-duchodce0")
                        end,
                        [1] = function()
                            addv(random(7), "sm-v-duchodce1")
                        end,
                    }
                elseif room.sbirka == 0 then
                    room.sbirka = -1
                    addv(random(10), "sm-v-sbirka")
                    addm(random(7), "sm-m-namaloval")
                    if mic.beha == 1 then
                        addv(random(7), "sm-v-marnost")
                        addm(random(7), "sm-m-proc")
                        addv(random(7), "sm-v-podivej")
                        planDialogSet(random(7), "sm-x-meduza", 101, meduza, "keca")
                    end
                end
            end
        end
    end

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

        meduza.afaze = 0
        meduza.keca = 0

        return function()
            if meduza.keca ~= 101 then
                if meduza.X == mic.X and meduza.Y == mic.Y - 3 then
                    mic.beha = 1
                    meduza.afaze = math.mod(meduza.afaze + 1, 3)
                    meduza:updateAnim()
                else
                    mic.beha = 0
                end
            else
                mic.beha = 0
            end
        end
    end

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

        mic.beha = 1
        mic.afaze = 0

        return function()
            if mic.beha == 1 then
                mic.afaze = math.mod(mic.afaze + 1, 4)
                mic:updateAnim()
            end
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_meduza2()
        return function()
            if random(100) < 20 then
                meduza2.afaze = random(2)
                meduza2:updateAnim()
            end
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_meduza1()
        return function()
            if random(100) < 20 then
                meduza1.afaze = random(2)
                meduza1:updateAnim()
            end
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_stonozka()
        return function()
            if random(100) < 5 then
                stonozka.afaze = random(2)
                stonozka:updateAnim()
            end
        end
    end

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

        ostnatec.afaze = 0
        ostnatec.kukuc = randint(10, 30)

        return function()
            if ostnatec.kukuc > 0 and ostnatec.afaze ~= 0 then
                ostnatec.kukuc = ostnatec.kukuc - 1
            elseif ostnatec.kukuc == 0 then
                ostnatec.kukuc = randint(10, 30)
                ostnatec.afaze = 0
            elseif random(100) < 1 then
                ostnatec.afaze = random(2) + 1
            else
                ostnatec.afaze = 0
            end
            ostnatec:updateAnim()
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_uhor()
        return function()
            if random(100) < 5 then
                uhor.afaze = random(2)
                uhor:updateAnim()
            end
        end
    end

    -- -------------------------------------------------------------
    local function prog_init_budik()
        return function()
            switch(math.mod(game_getCycles(), 9)){
                [0] = function()
                    budik.afaze = 0
                end,
                [5] = function()
                    budik.afaze = 1
                end,
            }
            budik:updateAnim()

            if not budik:isTalking() then
                budik:planDialog(0, "sm-x-tiktak")
            end
        end
    end

    -- --------------------
    local update_table = {}
    local subinit
    subinit = prog_init_room()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_meduza()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_mic()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_meduza2()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_meduza1()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_stonozka()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_ostnatec()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_uhor()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_budik()
    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