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 (131 lines) | stat: -rw-r--r-- 4,547 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

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


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

        room.rozh = random(50) + 10
        --NOTE: turn off standard black jokes
        stdBlackJoke = function() end

        return function()
            if game_getCycles() == room.rozh then
                room.rozh = room.rozh + 500 + random(1000)
                if no_dialog() then
                    if random(5) == 1 then
                        addm(2, "tr-m-ztuhl")
                    else
                        addm(3, "tr-m-chlad"..(random(2) + 1))
                        if game_getCycles() < 2000 or random(3) == 1 then
                            addv(5, "tr-v-jid"..(random(2) + 1))
                        end
                    end
                end
            end
            if isReady(small) and not isReady(big) and not big:isOut() then
                if snehulak.Y <= 5 then
                    if roompole[1] == 0 or pokus - roompole[1] > random(20) then
                        roompole[1] = pokus
                        addm(11, "tr-m-cvicit")
                    end
                end
            end
            if isReady(big) and not small:isAlive() then
                if snehulak.Y >= 5 then
                    if roompole[2] == 0 or pokus - roompole[2] > random(20) then
                        roompole[2] = pokus
                        addv(14, "tr-v-prezil")
                    end
                end
            end
            if snehulak.uder > 4 and no_dialog() and isReady(big) and isReady(small) then
                if odd(pokus) then
                    addv(4, "tr-v-agres")
                    snehulak.uder = -10
                end
            end
        end
    end

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

        snehulak.prastil = 0
        snehulak.uder = 0

        return function()
            if snehulak.dir == dir_down and ocel.dir ~= dir_down then
                snehulak.afaze = 2
            else
                if snehulak.afaze == 2 then
                    snehulak.afaze = 1
                end
                pom1 = snehulak.afaze
                pomb1 = isReady(small) and small.X + 2 == snehulak.X and small.Y - 2 == snehulak.Y and not small:isLeft()
                if not pomb1 then
                    snehulak.afaze = 0
                    snehulak.prastil = 0
                elseif snehulak.dir == dir_right then
                    if odd(game_getCycles()) then
                        snehulak.afaze = 1 - snehulak.afaze
                    end
                else
                    if snehulak.prastil == 0 then
                        snehulak.prastil = -3
                        snehulak.afaze = 1
                    else
                        if snehulak.prastil < -1 then
                            snehulak.prastil = snehulak.prastil + 1
                        end
                        if snehulak.prastil == -1 then
                            snehulak.afaze = 0
                        end
                    end
                end
                if pom1 == 0 and snehulak.afaze == 1 then
                    snehulak:talk("tr-x-koste", VOLUME_FULL)
                    if no_dialog() then
                        addm(2, "tr-m-au"..(random(2) + 1))
                    end
                    snehulak.uder = snehulak.uder + 1
                end
            end
            snehulak:updateAnim()
        end
    end

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