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 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
|
local function isOneOf(models, x, y)
for key, model in pairs(models) do
if modelEquals(model, x, y) then
return true
end
end
return false
end
-- -----------------------------------------------------------------
-- Init
-- -----------------------------------------------------------------
local function prog_init()
initModels()
local pokus = getRestartCount()
local windflowers = {}
table.insert(windflowers, sas1)
table.insert(windflowers, sas2)
table.insert(windflowers, sas3)
table.insert(windflowers, sas4)
table.insert(windflowers, sas5)
table.insert(windflowers, sas6)
-- -------------------------------------------------------------
local function prog_init_room()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
room.quvod = random(20) + 20
room.qhlaska = random(100) + 100
room.pouzito = {}
room.vydrz = random(2) + 2
room.komentovaly = 0
room.kreseni = 0
return function()
if isReady(small) and isReady(big) and no_dialog() and (balalajka.cinnost == 0 or balalajka.cinnost > 70) then
if room.quvod > 0 then
room.quvod = room.quvod - 1
end
if balalajka.hrala > 0 then
room.quvod = -1
end
if room.qhlaska > 0 then
room.qhlaska = room.qhlaska - 1
end
if room.komentovaly < balalajka.hrala then
--TODO: getRestartCount cannot be changed
if pokus < 1000 then
pokus = pokus + 1000
end
room.komentovaly = balalajka.hrala
if room.komentovaly <= room.vydrz then
switch(random(4)){
[2] = function()
addv(0, "kor-v-odvaz")
end,
[3] = function()
addm(6, "kor-m-vsimlsis")
addv(2, "kor-v-avidelas")
addm(4, "kor-m-tovis")
end,
default = function()
if random(2) == 1 then
addv(6, "kor-v-juchacka")
else
addv(6, "kor-v-vali")
end
switch(random(3)){
[0] = function()
addm(3, "kor-m-hraje")
end,
[1] = function()
addm(3, "kor-m-nachob")
end,
}
end,
}
else
pom1 = random(6)
for pom2 = 1, 2 do
if pom2 == 1 and isIn(pom1, {0, 1, 4}) and random(3) == 0 or pom2 == 2 and pom1 == 5 then
switch(random(2)){
[0] = function()
addm(5, "kor-m-jinou")
end,
[1] = function()
addm(5, "kor-m-neprehani")
end,
}
elseif pom2 == 1 and pom1 <= 1 then
addm(5, "kor-m-lezekrkem")
end
if pom2 == 1 and isIn(pom1, {2, 3, 5}) or pom2 == 2 and pom1 == 4 then
switch(random(2)){
[0] = function()
addv(5, "kor-v-lezekrkem")
end,
[1] = function()
addv(5, "kor-v-kostice")
end,
}
end
end
end
elseif room.kreseni == 0 and big.X >= 30 and big.Y == 5 and elko.X == 30 then
room.kreseni = room.kreseni + 1
addv(5, "kor-v-odsud")
addm(8, "kor-m-budesmuset")
elseif room.kreseni == 1 and isWater(10, 6) and isWater(23, 6) then
room.kreseni = room.kreseni + 1
elseif room.kreseni == 2 and (isOneOf(windflowers, 10, 6) or isOneOf(windflowers, 23, 6)) then
room.kreseni = room.kreseni + 1
addm(10, "kor-m-neniono")
addm(20, "kor-m-tudiru")
elseif room.qhlaska == 0 then
room.qhlaska = random(600) + 200
pom1 = random(6)
if not room.pouzito[pom1] then
switch(pom1){
[0] = function()
addm(10, "kor-m-dusi")
end,
[1] = function()
addm(10, "kor-m-pocit")
end,
[2] = function()
addm(10, "kor-m-bizarni")
end,
[3] = function()
addv(10, "kor-v-bermudy")
end,
[4] = function()
addv(10, "kor-v-inteligentni")
end,
[5] = function()
addv(10, "kor-v-jedovate")
end,
}
end
room.pouzito[pom1] = true
elseif room.quvod == 0 then
--TODO: getRestartCount cannot be changed
if 1 <= pokus and pokus <= 1000 then
room.quvod = random(2) + 1
elseif 1001 <= pokus and pokus <= 2000 then
room.quvod = 3
pokus = pokus + 1000
else
room.quvod = random(4)
end
if room.quvod == 0 or room.quvod == 1 then
addv(10, "kor-v-podivej")
addm(2, "kor-m-vzdyt")
addv(6, "kor-v-treba")
elseif room.quvod == 2 or room.quvod == 3 then
addm(10, "kor-m-podivej")
addv(5, "kor-v-spitu")
if random(100) < 40 then
addm(2, "kor-m-avlada")
end
addv(10, "kor-v-nicje")
if room.quvod == 3 then
addm(5, "kor-m-pokud")
end
end
room.quvod = -1
end
end
end
end
-- -------------------------------------------------------------
local function prog_init_krab1()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab1.krabfaze = 1
krab1.cekat = 0
return function()
if room:isTalking() then
switch(math.mod(game_getCycles(), 4)){
[0] = function()
krab1.krabfaze = 7
end,
[1] = function()
krab1.krabfaze = 7
end,
default = function()
krab1.krabfaze = 9
end,
}
elseif krab1.krabfaze <= 2 then
krab1.krabfaze = 1
else
krab1.krabfaze = 2
end
if krab1.krabfaze == 2 then
krab1.cekat = random(70) + 30
end
if krab1.krabfaze <= 2 then
if krab1.cekat == 0 then
krab1.afaze = 1
else
krab1.afaze = 0
krab1.cekat = krab1.cekat - 1
end
elseif not isWater(krab1.X, krab1.Y + 1) and not isWater(krab1.X + 1, krab1.Y + 1) then
krab1.afaze = krab1.krabfaze
elseif random(100) < 50 then
krab1.afaze = random(4) + 2
end
krab1:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_balalajka()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
balalajka.cinnost = 0
balalajka.hrala = 0
balalajka.tcatcat = random(15) + 10
return function()
if balalajka.dir ~= dir_no and balalajka.cinnost == 0 then
balalajka.cinnost = balalajka.cinnost + 1
end
switch(balalajka.cinnost){
[0] = function()
local cycle = math.mod(game_getCycles(), 18)
switch(cycle){
[0] = function()
if balalajka.tcatcat == 0 then
balalajka:talk("kor-chob-tca", VOLUME_FULL)
balalajka.tcatcat = random(15) + 10
else
balalajka:talk("kor-chob-psi", VOLUME_FULL)
balalajka.tcatcat = balalajka.tcatcat - 1
end
end,
[11] = function()
balalajka:talk("kor-chob-chro", VOLUME_FULL)
end,
default = function()
if 1 <= cycle and cycle <= 10 then
balalajka.afaze = 0
else
balalajka.afaze = 1
end
end,
}
end,
[1] = function()
balalajka.hrala = balalajka.hrala + 1
game_killPlan()
balalajka.afaze = 2
balalajka:killSound()
end,
[6] = function()
balalajka.afaze = 3
end,
[10] = function()
balalajka.afaze = 4
end,
[13] = function()
balalajka.afaze = 3
end,
[15] = function()
balalajka.afaze = 4
end,
[17] = function()
balalajka.afaze = 5
end,
[19] = function()
room:talk("kor-room-music", VOLUME_LOW)
end,
[83] = function()
balalajka.afaze = 5
end,
[90] = function()
balalajka.cinnost = 0
end,
default = function()
if isIn(balalajka.cinnost, {21, 23, 25, 27}) then
balalajka.afaze = 6
elseif isIn(balalajka.cinnost, {22, 24, 26, 28}) then
if random(100) < 10 then
balalajka.afaze = 7
else
balalajka.afaze = 8
end
elseif isIn(balalajka.cinnost, {29, 31, 33, 35}) then
balalajka.afaze = 9
elseif isIn(balalajka.cinnost, {30, 32, 34, 36}) then
balalajka.afaze = 10
end
end,
}
if balalajka.cinnost > 20 and balalajka.cinnost < 80 and not room:isTalking() then
balalajka.cinnost = 80
elseif balalajka.cinnost == 36 then
balalajka.cinnost = 21
elseif balalajka.cinnost > 0 then
balalajka.cinnost = balalajka.cinnost + 1
end
balalajka:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sas1()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sas1.sasfaze = -1
sas1.kvet = random(2) * 2 + 1
sas1.noha = random(2)
return function()
if room:isTalking() then
local cycle = math.mod(game_getCycles(), 8)
if isIn(cycle, {0, 1, 2, 3}) then
pom1 = 0
else
pom1 = 1
end
if isIn(cycle, {0, 3, 4, 7}) then
pom2 = 2
else
pom2 = 1
end
sas1.sasfaze = pom1 * 4 + pom2
else
sas1.sasfaze = -1
end
if isWater(sas1.X + 1, sas1.Y - 1) or modelEquals(room, sas1.X + 1, sas1.Y - 1) then
if sas1.sasfaze >= 0 then
sas1.afaze = sas1.sasfaze
else
if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
sas1.kvet = random(2) * 2 + 1
end
if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
sas1.noha = random(2)
end
sas1.afaze = sas1.noha * 4 + sas1.kvet
end
else
sas1.afaze = 0
end
sas1:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sas2()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sas2.kvet = random(2) * 2 + 1
sas2.noha = random(2)
return function()
if isWater(sas2.X + 1, sas2.Y - 1) or modelEquals(room, sas2.X + 1, sas2.Y - 1) then
if sas1.sasfaze >= 0 then
sas2.afaze = sas1.sasfaze
else
if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
sas2.kvet = random(2) * 2 + 1
end
if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
sas2.noha = random(2)
end
sas2.afaze = sas2.noha * 4 + sas2.kvet
end
else
sas2.afaze = 0
end
sas2:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sas3()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sas3.kvet = random(2) * 2 + 1
sas3.noha = random(2)
return function()
if isWater(sas3.X + 1, sas3.Y - 1) or modelEquals(room, sas3.X + 1, sas3.Y - 1) then
if sas1.sasfaze >= 0 then
sas3.afaze = sas1.sasfaze
else
if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
sas3.kvet = random(2) * 2 + 1
end
if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
sas3.noha = random(2)
end
sas3.afaze = sas3.noha * 4 + sas3.kvet
end
else
sas3.afaze = 0
end
sas3:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sas4()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sas4.kvet = random(2) * 2 + 1
sas4.noha = random(2)
return function()
if isWater(sas4.X + 1, sas4.Y - 1) or modelEquals(room, sas4.X + 1, sas4.Y - 1) then
if sas1.sasfaze >= 0 then
sas4.afaze = sas1.sasfaze
else
if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
sas4.kvet = random(2) * 2 + 1
end
if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
sas4.noha = random(2)
end
sas4.afaze = sas4.noha * 4 + sas4.kvet
end
else
sas4.afaze = 0
end
sas4:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sas5()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sas5.kvet = random(2) * 2 + 1
sas5.noha = random(2)
return function()
if isWater(sas5.X + 1, sas5.Y - 1) or modelEquals(room, sas5.X + 1, sas5.Y - 1) then
if sas1.sasfaze >= 0 then
sas5.afaze = sas1.sasfaze
else
if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
sas5.kvet = random(2) * 2 + 1
end
if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
sas5.noha = random(2)
end
sas5.afaze = sas5.noha * 4 + sas5.kvet
end
else
sas5.afaze = 0
end
sas5:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sas6()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sas6.kvet = random(2) * 2 + 1
sas6.noha = random(2)
return function()
if isWater(sas6.X + 1, sas6.Y - 1) or modelEquals(room, sas6.X + 1, sas6.Y - 1) then
if sas1.sasfaze >= 0 then
sas6.afaze = sas1.sasfaze
else
if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
sas6.kvet = random(2) * 2 + 1
end
if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
sas6.noha = random(2)
end
sas6.afaze = sas6.noha * 4 + sas6.kvet
end
else
sas6.afaze = 0
end
sas6:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_krab2()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab2.cekat = 0
return function()
if krab1.krabfaze == 2 then
krab2.cekat = random(70) + 30
end
if krab1.krabfaze <= 2 then
if krab2.cekat == 0 then
krab2.afaze = 1
else
krab2.afaze = 0
krab2.cekat = krab2.cekat - 1
end
elseif not isWater(krab2.X, krab2.Y + 1) and not isWater(krab2.X + 1, krab2.Y + 1) then
krab2.afaze = krab1.krabfaze
elseif random(100) < 50 then
krab2.afaze = random(4) + 2
end
krab2:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_krab3()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab3.cekat = 0
return function()
if krab1.krabfaze == 2 then
krab3.cekat = random(70) + 30
end
if krab1.krabfaze <= 2 then
if krab3.cekat == 0 then
krab3.afaze = 1
else
krab3.afaze = 0
krab3.cekat = krab3.cekat - 1
end
elseif not isWater(krab3.X, krab3.Y + 1) and not isWater(krab3.X + 1, krab3.Y + 1) then
krab3.afaze = krab1.krabfaze
elseif random(100) < 50 then
krab3.afaze = random(4) + 2
end
krab3:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_krab4()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab4.cekat = 0
return function()
if krab1.krabfaze == 2 then
krab4.cekat = random(70) + 30
end
if krab1.krabfaze <= 2 then
if krab4.cekat == 0 then
krab4.afaze = 1
else
krab4.afaze = 0
krab4.cekat = krab4.cekat - 1
end
elseif not isWater(krab4.X, krab4.Y + 1) and not isWater(krab4.X + 1, krab4.Y + 1) then
krab4.afaze = krab1.krabfaze
elseif random(100) < 50 then
krab4.afaze = random(4) + 2
end
krab4:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_krab5()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab5.cekat = 0
return function()
if krab1.krabfaze == 2 then
krab5.cekat = random(70) + 30
end
if krab1.krabfaze <= 2 then
if krab5.cekat == 0 then
krab5.afaze = 1
else
krab5.afaze = 0
krab5.cekat = krab5.cekat - 1
end
elseif not isWater(krab5.X, krab5.Y + 1) and not isWater(krab5.X + 1, krab5.Y + 1) then
krab5.afaze = krab1.krabfaze
elseif random(100) < 50 then
krab5.afaze = random(4) + 2
end
krab5:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_krab6()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab6.cekat = 0
return function()
if krab1.krabfaze == 2 then
krab6.cekat = random(70) + 30
end
if krab1.krabfaze <= 2 then
if krab6.cekat == 0 then
krab6.afaze = 1
else
krab6.afaze = 0
krab6.cekat = krab6.cekat - 1
end
elseif not isWater(krab6.X, krab6.Y + 1) and not isWater(krab6.X + 1, krab6.Y + 1) then
krab6.afaze = krab1.krabfaze
elseif random(100) < 50 then
krab6.afaze = random(4) + 2
end
krab6:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_sepie()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
sepie.mrk = 0
sepie.nohy = 0
return function()
pomb1 = sepie.dir == dir_down
pomb2 = isWater(sepie.X, sepie.Y + 1) and isWater(sepie.X + 1, sepie.Y + 1) and not isWater(sepie.X + 2, sepie.Y + 3)
if sepie.mrk > 0 then
sepie.mrk = sepie.mrk - 1
elseif random(100) < 15 then
sepie.mrk = random(3) + 2
end
if pomb1 or not pomb2 then
if odd(game_getCycles()) then
sepie.nohy = math.mod(sepie.nohy + 2 + random(2) * 2, 3)
end
sepie.afaze = sepie.nohy
if pomb1 then
sepie.afaze = sepie.nohy + 3
elseif sepie.mrk > 0 then
sepie.afaze = sepie.nohy + 6
else
sepie.afaze = sepie.nohy
end
else
if sepie.dir == dir_left or sepie.dir == dir_right then
sepie.nohy = math.mod(sepie.nohy + 1, 2)
else
sepie.nohy = 0
end
if sepie.mrk > 0 then
sepie.afaze = 2 * sepie.nohy + 10
else
sepie.afaze = 2 * sepie.nohy + 9
end
end
sepie:updateAnim()
end
end
-- --------------------
local update_table = {}
local subinit
subinit = prog_init_room()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab1()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_balalajka()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sas1()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sas2()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sas3()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sas4()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sas5()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sas6()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab2()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab3()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab4()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab5()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab6()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_sepie()
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
|