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
|
-- -----------------------------------------------------------------
-- Init
-- -----------------------------------------------------------------
local function prog_init()
initModels()
sound_playMusic("music/rybky09.ogg")
local pokus = getRestartCount()
-- -------------------------------------------------------------
local function prog_init_room()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
if pokus == 1 then
room.uvod = 3
else
room.uvod = random(3)
end
room.oregistry = random(5000) + 500
room.odolech = 0
room.oblizardu = 0
return function()
if room.oblizardu == 0 and isReady(big) and big.X == 47 and big.Y == 11 then
room.oblizardu = 1
big:setBusy(true)
addv(5, "war-v-blizzard")
if isReady(small) then
small:setBusy(true)
addm(4, "war-m-hodiny")
end
planBusy(big, false)
planBusy(small, false)
end
if no_dialog() and isReady(small) and isReady(big) then
for pom1 = 1, 10 do
if room.oregistry > 0 then
room.oregistry = room.oregistry - 1
end
end
if room.uvod > 0 then
if room.uvod == 1 or room.uvod == 3 then
addm(random(30) + 10, "war-m-kam")
addv(random(30) + 10, "war-v-povedome")
end
if room.uvod == 2 or room.uvod == 3 then
switch(random(2)){
[0] = function()
addm(random(30) + 20, "war-m-hrad")
end,
[1] = function()
addm(random(30) + 20, "war-m-ocel")
end,
}
if random(100) < 50 or pokus == 1 then
addv(random(200) + 10, "war-v-vesnicane")
addm(4, "war-m-peoni")
end
end
room.uvod = 0
elseif room.odolech == 0 and (dul1.dir ~= dir_no or dul2.dir ~= dir_no) and random(100) < 10 then
room.odolech = 0
addv(random(30) + 10, "war-v-doly")
addm(random(20), "war-m-povazuji")
elseif room.oregistry == 0 then
room.oregistry = -1
addv(20, "war-v-pohadka")
addm(random(40) + 10, "war-m-pichat")
addv(2, "war-v-prozradit")
addm(4, "war-m-aznato")
end
end
end
end
-- -------------------------------------------------------------
local function prog_init_knight1()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
knight1.hybese = 0
knight1.unejvelka = 1
knight1.unejmala = 0
return function()
pom2 = 0
if dist(big, knight1) <= 1 then
pom1 = 1
else
pom1 = 0
end
if knight1.unejvelka == 0 and pom1 == 1 then
pom2 = 1
end
knight1.unejvelka = pom1
if dist(small, knight1) <= 1 then
pom1 = 1
else
pom1 = 0
end
if knight1.unejmala == 0 and pom1 == 1 then
pom2 = 1
end
knight1.unejmala = pom1
if knight1.dir ~= dir_no and knight1.hybese == 0 then
pom2 = 2
end
if knight1.dir ~= dir_no then
knight1.hybese = 1
else
knight1.hybese = 0
end
switch(pom2){
[1] = function()
knight1:talk("war-k-ready"..random(3), VOLUME_FULL)
end,
[2] = function()
knight1:talk("war-k-move" ..random(3), VOLUME_FULL)
end,
}
end
end
-- -------------------------------------------------------------
local function prog_init_knight2()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
knight2.hybese = 0
knight2.unejvelka = 0
knight2.unejmala = 0
return function()
pom2 = 0
if dist(big, knight2) <= 1 then
pom1 = 1
else
pom1 = 0
end
if knight2.unejvelka == 0 and pom1 == 1 then
pom2 = 1
end
knight2.unejvelka = pom1
if dist(small, knight2) <= 1 then
pom1 = 1
else
pom1 = 0
end
if knight2.unejmala == 0 and pom1 == 1 then
pom2 = 1
end
knight2.unejmala = pom1
if knight2.dir ~= dir_no and knight2.hybese == 0 then
pom2 = 2
end
if knight2.dir ~= dir_no then
knight2.hybese = 1
else
knight2.hybese = 0
end
switch(pom2){
[1] = function()
knight2:talk("war-k-ready"..random(3), VOLUME_FULL)
end,
[2] = function()
knight2:talk("war-k-move"..random(3), VOLUME_FULL)
end,
}
end
end
-- -------------------------------------------------------------
local function prog_init_archer1()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
archer1.hybese = 0
archer1.unejvelka = 1
archer1.unejmala = 0
return function()
pom2 = 0
if dist(big, archer1) <= 1 then
pom1 = 1
else
pom1 = 0
end
if archer1.unejvelka == 0 and pom1 == 1 then
pom2 = 1
end
archer1.unejvelka = pom1
if dist(small, archer1) <= 1 then
pom1 = 1
else
pom1 = 0
end
if archer1.unejmala == 0 and pom1 == 1 then
pom2 = 1
end
archer1.unejmala = pom1
if archer1.dir ~= dir_no and archer1.hybese == 0 then
pom2 = 2
end
if archer1.dir ~= dir_no then
archer1.hybese = 1
else
archer1.hybese = 0
end
switch(pom2){
[1] = function()
archer1:talk("war-a-ready"..random(2), VOLUME_FULL)
end,
[2] = function()
archer1:talk("war-a-move"..random(2), VOLUME_FULL)
end,
}
end
end
-- -------------------------------------------------------------
local function prog_init_archer2()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
archer2.hybese = 0
archer2.unejvelka = 1
archer2.unejmala = 0
return function()
pom2 = 0
if dist(big, archer2) <= 1 then
pom1 = 1
else
pom1 = 0
end
if archer2.unejvelka == 0 and pom1 == 1 then
pom2 = 1
end
archer2.unejvelka = pom1
if dist(small, archer2) <= 1 then
pom1 = 1
else
pom1 = 0
end
if archer2.unejmala == 0 and pom1 == 1 then
pom2 = 1
end
archer2.unejmala = pom1
if archer2.dir ~= dir_no and archer2.hybese == 0 then
pom2 = 2
end
if archer2.dir ~= dir_no then
archer2.hybese = 1
else
archer2.hybese = 0
end
switch(pom2){
[1] = function()
archer2:talk("war-a-ready"..random(2), VOLUME_FULL)
end,
[2] = function()
archer2:talk("war-a-move"..random(2), VOLUME_FULL)
end,
}
end
end
-- --------------------
local update_table = {}
local subinit
subinit = prog_init_room()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_knight1()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_knight2()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_archer1()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_archer2()
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
|