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

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


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

        room.uvod = 0
        room.odedkovi = 0
        room.ritual = 0
        room.ohlavem = 0
        room.ohlavev = 0
        room.blizko = 0
        room.jikry = 0
        room.curat = 0

        return function()
            if isReady(small) and isReady(big) and no_dialog() then
                if room.blizko > 0 then
                    room.blizko = room.blizko - 1
                end
                if room.uvod == 0 then
                    room.uvod = 1
                    addm(randint(5, 20), "zd2-m-dalsi")
                    switch(random(2)){
                        [0] = function()
                            addv(random(5), "zd2-v-odlis0")
                        end,
                        [1] = function()
                            addv(random(5), "zd2-v-odlis1")
                        end,
                    }
                elseif room.odedkovi == 0 and small.X > 20 and small.Y < 30 and look_at(big, dedek) then
                    room.odedkovi = 1
                    addv(randint(5, 10), "zd2-v-vlevo")
                    switch(random(2)){
                        [0] = function()
                            addm(randint(1, 5), "zd2-m-nevid0")
                        end,
                        [1] = function()
                            addm(randint(1, 5), "zd2-m-nevid1")
                        end,
                    }
                elseif room.ritual == 0 and random(100) < 5 and room.odedkovi == 1 and dedek.pohlse == 0 then
                    addv(1, "zd2-v-symbol")
                    addm(randint(1, 5), "zd2-m-douf")
                    room.ritual = 1
                elseif room.ohlavem == 0 and dist(small, hlava) < 3 and look_at(small, hlava) and random(100) < 5 then
                    room.ohlavem = 1
                    addm(1, "zd2-m-lebka")
                elseif room.ohlavev == 0 and dist(big, hlava) < 3 and look_at(big, hlava) and random(100) < 5 then
                    room.ohlavev = 1
                    addv(1, "zd2-v-haml")
                elseif room.blizko == 0 and (dist(small, dedek) < 5 and look_at(small, dedek) or dist(small, dedek) < 5 and look_at(small, dedek)) then
                    room.blizko = random(400) + 100
                    switch(random(3)){
                        [0] = function()
                            planDialogSet(random(3), "zd2-x-hus0", 101, dedek, "mluvi")
                        end,
                        [1] = function()
                            planDialogSet(random(3), "zd2-x-hus1", 102, dedek, "mluvi")
                        end,
                        [2] = function()
                            planDialogSet(random(3), "zd2-x-kricet", 102, dedek, "mluvi")
                        end,
                    }
                elseif dedek.dir ~= dir_no and random(100) < 2 then
                    switch(random(3)){
                        [0] = function()
                            planDialogSet(randint(2, 6), "zd2-x-krik0", 101, dedek, "mluvi")
                        end,
                        [1] = function()
                            planDialogSet(randint(2, 6), "zd2-x-krik1", 102, dedek, "mluvi")
                        end,
                        [2] = function()
                            if room.ritual == 1 then
                                planDialogSet(randint(2, 6), "zd2-x-ritual", 102, dedek, "mluvi")
                            end
                        end,
                    }
                elseif dist(small, dedek) < 3 and dist(big, dedek) < 3 and random(100) < 1 then
                    planDialogSet(randint(2, 6), "zd2-x-nechteme", 102, dedek, "mluvi")
                elseif (dist(small, dedek) <= 1 or dist(big, dedek) <= 1) and random(100) < 2 then
                    switch(random(3)){
                        [0] = function()
                            planDialogSet(randint(2, 6), "zd2-x-nechme", 102, dedek, "mluvi")
                        end,
                        [1] = function()
                            planDialogSet(randint(2, 6), "zd2-x-pokoj", 102, dedek, "mluvi")
                        end,
                        [2] = function()
                            planDialogSet(randint(2, 6), "zd2-x-fuj", 102, dedek, "mluvi")
                        end,
                    }
                elseif dist(small, dedek) < 3 and look_at(small, dedek) and room.jikry == 0 and random(100) < 1 then
                    room.jikry = 1
                    planDialogSet(random(3), "zd2-x-neklast", 102, dedek, "mluvi")
                elseif dist(big, dedek) < 3 and look_at(big, dedek) and room.curat == 0 and random(100) < 1 then
                    room.curat = 1
                    planDialogSet(random(3), "zd2-x-necurat", 102, dedek, "mluvi")
                end
            end
        end
    end

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

        --NOTE: double rope
        game_addDecor("rope", vytah.index, stroj.index, 43, 0, 58, 27)
        game_addDecor("rope", vytah.index, stroj.index, 43 + 3, 0, 58 + 3, 27)
    end

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

        return function()
            if stroj.X == vytah.X - 1 then
                if stroj.dir == dir_no and vytah.dir == dir_down then
                    pom1 = 2
                elseif stroj.dir == dir_up and vytah.dir == dir_no then
                    pom1 = 1
                elseif stroj.dir == dir_no and vytah.dir == dir_up then
                    pom1 = -1
                elseif stroj.dir == dir_down and vytah.dir == dir_no then
                    pom1 = -2
                else
                    pom1 = 0
                end
                stroj.afaze = stroj.afaze + pom1
                if stroj.afaze > 5 then
                    stroj.afaze = stroj.afaze - 6
                elseif stroj.afaze < 0 then
                    stroj.afaze = stroj.afaze + 6
                end
            end
            stroj:updateAnim()
        end
    end

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

        dedek.mluvi = 0
        dedek.pohlse = 0
        dedek.mavani = randint(1, 3)

        return function()
            if dedek.dir ~= dir_no then
                dedek.pohlse = 1
            end
            if dedek.mavani == 0 then
                if dedek.mluvi == 102 then
                    dedek.afaze = 1
                else
                    dedek.afaze = 0
                end
                dedek.mavani = randint(1, 3)
            else
                switch(dedek.mluvi){
                    [101] = function()
                        dedek.afaze = 1
                        dedek.mavani = dedek.mavani - 1
                    end,
                    [102] = function()
                        dedek.afaze = 2
                        dedek.mavani = dedek.mavani - 1
                    end,
                    default = function()
                        dedek.afaze = 0
                    end,
                }
            end
            dedek:updateAnim()
        end
    end

    -- --------------------
    local update_table = {}
    local subinit
    subinit = prog_init_room()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_vytah()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_stroj()
    if subinit then
        table.insert(update_table, subinit)
    end
    subinit = prog_init_dedek()
    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