Changeset - 08bed57892a3
[Not reviewed]
default
0 9 16
silverwing - 7 years ago 2017-09-09 09:06:13

wip
25 files changed with 1231 insertions and 27 deletions:
0 comments (0 inline, 0 general)
atlantis_dyp.lua
Show inline comments
 
@@ -361,7 +361,7 @@ dyp_temple_west_footprints = obj {
 

	
 
dyp_temple_north_west_obelisk = obj {
 
    nam = "dyp_temple_north_west_obelisk";
 
    dsc = [[Перед вами возвышается массивный каменный {обелиск}. Некогда он был украшен резными орнаментами, но сейчас все они практически полностью стерлись. ]]
 
    dsc = [[Перед вами возвышается массивный каменный {обелиск}. Некогда он был украшен резными орнаментами, но сейчас все они практически полностью стерлись. ]];
 
    act = [[Древняя каменная конструкция, с неизвестной целью помещенная в этом месте. ]];
 
};
 

	
 
@@ -427,16 +427,16 @@ dyp_temple_obelisk_footprints = obj {
 

	
 
dyp_temple_warning_obelisk = obj {
 
    nam = "dyp_temple_warning_obelisk";
 
    dsc = [[Перед вами возвышается массивный каменный {обелиск}. Некогда он был украшен резными орнаментами, но сейчас все они практически полностью стерлись. ]]
 
    dsc = [[Перед вами возвышается массивный каменный {обелиск}. Некогда он был украшен резными орнаментами, но сейчас все они практически полностью стерлись. ]];
 
    act = [[Древняя каменная конструкция, с неизвестной целью помещенная в этом месте. ]];
 
};
 

	
 
dyp_temple_cliff_1 = room {
 
    nam = "Океан";
 
    no_exit = function(s)
 
        [[Нет смысла покидать Левиафан здесь. ]];
 
        return [[Нет смысла покидать Левиафан здесь. ]];
 
    end;
 
    view = [[Вы находитесь к югу от высокой скалы, протянувшейся с востока на запад. Здесь в скале вы видите вход в глубокую темную пещеру. ]]
 
    view = [[Вы находитесь к югу от высокой скалы, протянувшейся с востока на запад. Здесь в скале вы видите вход в глубокую темную пещеру. ]];
 
    way = {
 
        kh_vroom("В Левиафан", "leviathan_airlock");
 
        kh_vroom("В пещеру", "dyp_crab_cave");
 
@@ -459,7 +459,7 @@ dyp_temple_cliff_2 = room {
 
            return [[Нет смысла покидать Левиафан здесь. ]];
 
        end;
 
    end;
 
    view = [[Вы находитесь к югу от высокой скалы, протянувшейся с востока на запад. ]]
 
    view = [[Вы находитесь к югу от высокой скалы, протянувшейся с востока на запад. ]];
 
    dsc = [[Вы стоите у подножя высокой скалы, протянувшейся с востока на запад к северу от вас. ]];
 
    way = {
 
        kh_vroom("В Левиафан", "leviathan_airlock");
 
@@ -946,20 +946,13 @@ dyp_crab_cave = labyrinth {
 
        position = "00";
 
        fight = false;
 
    };
 
    nam = "dyp_crab_cave";
 
    disp = "Пещера";
 
    dir1 = "На северо-запад";
 
    dir2 = "На северо-восток";
 
    dir3 = "На юго-запад";
 
    dir4 = "На юго-восток";
 
    ex = "Выйти";
 
    enter = function(s)
 
        if s.position == "43" then
 
            if not fight then
 
                walk("dyp_crab_fight");
 
            end;
 
        elseif s.position == "52" then
 
        elseif s.position == "50" then
 
        end;
 
    end;
 
    map = {
 
        ["00"] = {
 
            name = [[Вы стоите у входа в глубокую пещеру. Стены здесь неровные и извилистые, образую причудливые переплетения длинный коридоров. Кто знает, куда они приведут? На каменистом полу едва ли можно заметить какие-либо следы. ]];
 
@@ -991,7 +984,7 @@ dyp_crab_cave = labyrinth {
 
            e3 = "11";
 
        };
 
        ["30"] = {
 
            e1 = "40":
 
            e1 = "40";
 
            e2 = "41";
 
            e4 = "20";
 
        };
 
@@ -1018,27 +1011,639 @@ dyp_crab_cave = labyrinth {
 
            e3 = "31";
 
        };
 
        ["43"] = {
 
            e1 = "52";
 
            e3 = "32";
 
            enter = function(s)
 
                if not s.fight then
 
                    s.fight = true;
 
                    walk("dyp_crab_fight_intro");
 
                end;
 
            end;
 
        };
 
        ["50"] = {
 
            e3 = "40";
 
        };
 
        ["51"] = {
 
            e4 = "42";
 
        };
 
        ["52"] = {
 
            e4 = "43";
 
            enter = function(s)
 
                if (not exist(dyp_, s)) then
 
                    move(ven_skeleton, s);
 
                end;
 
            end;
 
            exit = function(s)
 
                
 
            end;
 
        };
 
    };
 
};
 

	
 
dyp_crab_fight_intro = cutscene("dyp_crab_fight_intro", "Пещера", [[Впереди, вы замечаете какое-то движение. Луч прожетора выхватывает огромные острые клешни гигантского краба, устремившегося к вам. Следом за ним вы видите множество крабов поменьше, также ползущих к вам на своих тонких острых ногах. ]], "dyp_crab_fight");
 

	
 
dyp_crab_fight_win = cutscene("dyp_crab_fight_win", "Пещера", [[Отбившись от крабов, вы остаетесь одни в темном лабиринте пещер. ]], "dyp_crab_cave");
 

	
 
dyp_cmbt_learr = combatant {
 
    nam = "dyp_cmbt_learr";
 
    disp2 = "Леарр";
 
    disp3 = "Леарр";
 
    x = 5;
 
    y = 7;
 
    pic = "images/learr.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasSpear = true;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
            local obj = here().obj[item];
 
            if (obj.enemy and obj.hp > 0) then
 
                local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y);
 
                if (p) then
 
                    table.insert(enemies, {
 
                        o = obj,
 
                        p = p
 
                    });
 
                end;
 
            end;
 
        end;
 
        if (#enemies == 0) then
 
            pn("Леарр ждет. ");
 
            return;
 
        end;
 
        table.sort(enemies, function(a, b)
 
            return (a.p.l < b.p.l);
 
        end);
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        for i = 1,#enemies do
 
            print(enemies[i].p.l);
 
        end;
 
        -- AI Order:
 
        -- If has spear and enemy is far   - throw spear
 
        -- If has spear and enemy is close - hit with spear
 
        -- if spear is nearer than any enemy - walk towards spear
 
        -- walk towards nearest enemy
 
        -- If enemy close and enemy has spear - take spear from enemy
 
        -- If enemy close and enemy doesn't have spear - hit with claws
 

	
 
        if s.hasSpear then
 
            if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then
 
                --50%
 
                if (rnd(2) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Леарр бьет " .. enemy.disp2 .. " копьем и попадает. ");
 
                else
 
                    pn("Леарр бьет " .. enemy.disp2 .. " копьем, но промахивается. ");
 
                end;
 
                return;
 
            elseif  (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then
 
                --75%
 
                if (rnd(4) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Леарр бьет " .. enemy.disp2 .. " копьем и попадает. ");
 
                else
 
                    pn("Леарр бьет " .. enemy.disp2 .. " копьем, но промахивается. ");
 
                end;
 
                return;
 
            elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
                s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
                --100%
 
                enemy.hp = enemy.hp - 2;
 
                pn("Леарр бьет " .. enemy.disp2 .. " копьем и попадает. ");
 
                return;
 
            end;
 
        else
 
            if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
                s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
                enemy.hp = enemy.hp - 1;
 
                pn("Леарр бьет " .. enemy.disp2 .. " и попадает. ");
 
                return;
 
            end;
 
        end;
 
        
 
        s.x = path.p[2][1];
 
        s.y = path.p[2][2];
 
        pn("Леарр идет к " .. enemy.disp3 .. ". ");
 
    end;
 
    dsc = function(s)
 
        if (s.hp > 0) then
 
            return [[ {Леарр} готова к бою. ]];
 
        else
 
            return [[ {Леарр} без сознания. ]];
 
        end;
 
    end;
 
};
 

	
 
dyp_cmbt_wright = combatant {
 
    nam = "za_cmbt_wright";
 
    disp2 = "Райта";
 
    disp3 = "Райту";
 
    x = 5;
 
    y = 7;
 
    pic = "images/jack.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
            local obj = here().obj[item];
 
            if (obj.enemy and obj.hp > 0) then
 
                local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y);
 
                if (p) then
 
                    table.insert(enemies, {
 
                        o = obj,
 
                        p = p
 
                    });
 
                end;
 
            end;
 
        end;
 
        if (#enemies == 0) then
 
            pn("Райт ждет. ");
 
            return;
 
        end;
 
        table.sort(enemies, function(a, b)
 
            return (a.p.l < b.p.l);
 
        end);
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        
 
        if (s.x ~= 6 or s.y ~=3) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 3);
 
            if (ppath.l < path.l) then
 
                s.x = ppath.p[2][1];
 
                s.y = ppath.p[2][2];
 
                pn("Райт идет к укрытию");
 
            end;
 
        end;
 
        
 
        -- AI Order:
 
        -- If has harpoon and enemy is far - shoot
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 
        
 
        if (s.hasHarpoon) then
 
            if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then
 
                --50%
 
                if (rnd(2) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Райт бьет " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            elseif  (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then
 
                --75%
 
                if (rnd(4) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Райт бьет " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
                s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
                --100%
 
                enemy.hp = enemy.hp - 2;
 
                pn("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                return;
 
            else
 
                local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY));--here().getDistance(here().plX, here().plY, s.x, s.y);
 
                if (rnd(4) > dist - 2) then
 
                    s.hasSpear = false;
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Райт стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Райт стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            end;
 
        else
 
            s.hasHarpoon = true;
 
            pn("Райт перезаряжает ружье. ");
 
        end;
 
        
 
        s.x = path.p[2][1];
 
        s.y = path.p[2][2];
 
        pn("Райт идет к " .. enemy.disp3 .. ". ");
 
    end;
 
    dsc = function(s)
 
        if (s.hp > 0) then
 
            return [[ {Райт} готов к бою. ]];
 
        else
 
            return [[ {Райт} без сознания. ]];
 
        end;
 
    end;
 
};
 

	
 
dyp_cmbt_radcliffe = combatant {
 
    nam = "dyp_cmbt_radcliffe";
 
    disp2 = "Рэклиффа";
 
    disp3 = "Рэдклиффу";
 
    x = 5;
 
    y = 7;
 
    pic = "images/walter.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
            local obj = here().obj[item];
 
            if (obj.enemy and obj.hp > 0) then
 
                local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y);
 
                if (p) then
 
                    table.insert(enemies, {
 
                        o = obj,
 
                        p = p
 
                    });
 
                end;
 
            end;
 
        end;
 
        if (#enemies == 0) then
 
            pn("Рэдклифф ждет. ");
 
            return;
 
        end;
 
        table.sort(enemies, function(a, b)
 
            return (a.p.l < b.p.l);
 
        end);
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        
 
        if (s.x ~= 6 or s.y ~=3) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 3);
 
            if (ppath.l < path.l) then
 
                s.x = ppath.p[2][1];
 
                s.y = ppath.p[2][2];
 
                pn("Рэдклифф идет к укрытию");
 
            end;
 
        end;
 
        
 
        -- AI Order:
 
        -- If has harpoon and enemy is far - shoot
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 
        
 
        if (s.hasHarpoon) then
 
            if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then
 
                --50%
 
                if (rnd(2) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            elseif  (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then
 
                --75%
 
                if (rnd(4) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
                s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
                --100%
 
                enemy.hp = enemy.hp - 2;
 
                pn("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                return;
 
            else
 
                local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY));--here().getDistance(here().plX, here().plY, s.x, s.y);
 
                if (rnd(4) > dist - 2) then
 
                    s.hasSpear = false;
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Рэдклифф стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Рэдклифф стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            end;
 
        else
 
            s.hasHarpoon = true;
 
            pn("Рэдклифф перезаряжает ружье. ");
 
        end;
 
        
 
        s.x = path.p[2][1];
 
        s.y = path.p[2][2];
 
        pn("Рэдклифф идет к " .. enemy.disp3 .. ". ");
 
    end;
 
    dsc = function(s)
 
        if (s.hp > 0) then
 
            return [[ {Рэдклифф} готов к бою. ]];
 
        else
 
            return [[ {Рэдклифф} без сознания. ]];
 
        end;
 
    end;
 
};
 

	
 
dyp_cmbt_anna = combatant {
 
    nam = "dyp_cmbt_anna";
 
    disp2 = "Анну";
 
    disp3 = "Анне";
 
    x = 5;
 
    y = 7;
 
    pic = "images/anna.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
            local obj = here().obj[item];
 
            if (obj.enemy and obj.hp > 0) then
 
                local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y);
 
                if (p) then
 
                    table.insert(enemies, {
 
                        o = obj,
 
                        p = p
 
                    });
 
                end;
 
            end;
 
        end;
 
        if (#enemies == 0) then
 
            pn("Анна ждет. ");
 
            return;
 
        end;
 
        table.sort(enemies, function(a, b)
 
            return (a.p.l < b.p.l);
 
        end);
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        
 
        if (s.x ~= 6 or s.y ~=3) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 3);
 
            if (ppath.l < path.l) then
 
                s.x = ppath.p[2][1];
 
                s.y = ppath.p[2][2];
 
                pn("Анна идет к укрытию");
 
            end;
 
        end;
 
        
 
        -- AI Order:
 
        -- If has harpoon and enemy is far - shoot
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 
        
 
        if (s.hasHarpoon) then
 
            if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then
 
                --50%
 
                if (rnd(2) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Анна бьет " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            elseif  (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then
 
                --75%
 
                if (rnd(4) > 1) then
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Анна бьет " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
                s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
                --100%
 
                enemy.hp = enemy.hp - 2;
 
                pn("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                return;
 
            else
 
                local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY));--here().getDistance(here().plX, here().plY, s.x, s.y);
 
                if (rnd(4) > dist - 2) then
 
                    s.hasSpear = false;
 
                    enemy.hp = enemy.hp - 2;
 
                    pn("Анна стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pn("Анна стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            end;
 
        else
 
            s.hasHarpoon = true;
 
            pn("Анна перезаряжает ружье. ");
 
        end;
 
        
 
        local plpath = here():getWalkDistance(s.x, s.y, pl.x, pl.y);
 
        if (plpath.l > 2) then
 
            s.x = plpath.p[2][1];
 
            s.y = plpath.p[2][2];
 
            pn("Анна идет к вам. ");
 
        end;
 
    end;
 
    dsc = function(s)
 
        if (s.hp > 0) then
 
            return [[ {Анна} готова к бою. ]];
 
        else
 
            return [[ {Анна} без сознания. ]];
 
        end;
 
    end;
 
};
 

	
 
dyp_king_crab = combatant {
 
    nam = "dyp_king_crab";
 
    disp2 = "краба";
 
    disp3 = "крабу";
 
    x = 4;
 
    y = 1;
 
    hp = 4;
 
    pic = "images/king_crab.png";
 
    shootHit = "Вы стреляете в краба и попадаете в него. ";
 
    shootMiss = "Вы стреляете в краба, но не попадаете в него. ";
 
    shootKill = "Вы стреляете в краба и он умирает. ";
 
    handHit = "Вы ударяете краба. ";
 
    handKill = "Вы ударяет краба, убивая его. ";
 
    handFar = "Слишком далеко. ";
 
    enemy = true;
 
    dsc = function(s)
 
        if (s.hp > 0) then
 
            return "{Краб} готов к бою. ";
 
        else
 
            return false;
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = { };
 
        for item=1,#here().obj do
 
            local obj = here().obj[item];
 
            if (obj.ally and obj.hp > 0) then
 
                local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y);
 
                if (p) then
 
                    table.insert(enemies, {
 
                        o = obj,
 
                        p = p
 
                    });
 
                end;
 
            end;
 
        end;
 
        table.sort(enemies, function(a, b)
 
            return (a.p.l < b.p.l);
 
        end);
 

	
 
        local enemy = enemies[1];
 
        local path = here():getWalkDistance(s.x, s.y, here().plX, here().plY);
 
        if (not enemy or path and enemy.p.l > path.l ) then
 
            enemy = pl;
 
        else
 
            path = enemy.p;
 
            enemy = enemy.o;
 
        end;
 

	
 
        if (not enemy or not path) then
 
            pn("Краб ждет. ");
 
            return;
 
        end;
 

	
 
        -- AI Order:
 
        -- If has spear and enemy is close - hit with spear
 
        -- walk towards nearest enemy
 
        -- If enemy close - hit with claws
 

	
 
        if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
            s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
            enemy.hp = enemy.hp - 2;
 
            pn("Краб бьет " .. enemy.disp2 .. " и попадает. ");
 
            return;
 
        end;
 

	
 
        print("fug2",path);
 
        s.x = path.p[2][1];
 
        s.y = path.p[2][2];
 
        pn("Краб идет к " .. enemy.disp3 .. ". ");
 
    end;
 
};
 

	
 
dyp_little_crab = function(nam, index, x, y) 
 
    return combatant {
 
        nam = nam;
 
        disp2 = "детеныша краба " .. tostring(index);
 
        disp3 = "детенышу краба " .. tostring(index);
 
        x = x;
 
        y = y;
 
        hp = 2;
 
        pic = "images/little_crab_".. index ..".png";
 
        shootHit = "Вы стреляете в детеныша краба и попадаете в него. ";
 
        shootMiss = "Вы стреляете в детеныша краба, но не попадаете в него. ";
 
        shootKill = "Вы стреляете в детеныша краба и он умирает. ";
 
        handHit = "Вы ударяете детеныша краба. ";
 
        handKill = "Вы ударяет детеныша краба, убивая его. ";
 
        handFar = "Слишком далеко. ";
 
        enemy = true;
 
        dsc = function(s)
 
            if (s.hp > 0) then
 
                return "{Детеныш краба " .. tostring(index).. "} готов к бою. ";
 
            else
 
                return false;
 
            end;
 
        end;
 
        make_turn = function(s)
 
            local enemies = {  };
 
            for item=1,#here().obj do
 
                local obj = here().obj[item];
 
                if (obj.ally and obj.hp > 0) then
 
                    local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y);
 
                    if (p) then
 
                        table.insert(enemies, {
 
                            o = obj,
 
                            p = p
 
                        });
 
                    end;
 
                end;
 
            end;
 
            table.sort(enemies, function(a, b)
 
                return (a.p.l < b.p.l);
 
            end);
 

	
 
            local enemy = enemies[1];
 
            local path = here():getWalkDistance(s.x, s.y, here().plX, here().plY);
 
            if (not enemy or path and enemy.p.l > path.l ) then
 
                enemy = pl;
 
            else
 
                path = enemy.p;
 
                enemy = enemy.o;
 
            end;
 

	
 
            if (not enemy or not path) then
 
                pn("Детеныш краба ".. tostring(index).. " ждет. ");
 
                return;
 
            end;
 

	
 
            -- AI Order:
 
            -- If has spear and enemy is close - hit with spear
 
            -- walk towards nearest enemy
 
            -- If enemy close - hit with claws
 

	
 
            if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or
 
                s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then
 
                enemy.hp = enemy.hp - 1;
 
                pn("Детеныш краба ".. tostring(index).. " бьет " .. enemy.disp2 .. " и попадает. ");
 
                return;
 
            end;
 

	
 
            print("fug2",path);
 
            s.x = path.p[2][1];
 
            s.y = path.p[2][2];
 
            pn("Детеныш краба ".. tostring(index).. " идет к " .. enemy.disp3 .. ". ");
 
        end;
 
    };
 
end;
 

	
 
dyp_crab_fight = battlefield {
 
    nam = "Пещера";
 
    plX = 4;
 
    plY = 7;
 
    map = {
 
        {2,0,0,0,0,0,2};
 
        {2,0,0,0,0,0,2};
 
        {2,0,0,0,0,0,2};
 
        {2,1,1,0,0,0,2};
 
        {2,0,1,0,1,1,2};
 
        {2,0,0,0,1,0,2};
 
        {2,1,0,0,0,0,2};
 
        {2,0,0,1,0,1,2};
 
        {2,0,1,0,0,0,2};
 
        {2,0,0,0,0,1,2};
 
        {2,0,0,0,0,0,2};
 
    };
 
    win = "dyp_crab_cave_win";
 
    lose = "game_over_crab_cave";
 
    obstacle = "images/stones.png";
 
};
 
\ No newline at end of file
 
    underwater = true;
 
    entered = function(s)
 
        --TODO prepend player associate - anna, learr, walter or jack
 
        if (char_learr.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_learr);
 
            s.plX = 3;
 
        elseif (char_anna.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_anna);
 
            s.plX = 3;
 
        elseif (char_wright.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_wright);
 
            s.plX = 3;
 
        elseif (char_radcliffe.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_radcliffe);
 
            s.plX = 3;
 
        end;
 
    end;
 
    obj = {
 
        "dyp_king_crab",
 
        dyp_little_crab("dyp_little_crab_1", 1, 2, 1);
 
        dyp_little_crab("dyp_little_crab_2", 2, 3, 1);
 
        dyp_little_crab("dyp_little_crab_3", 3, 5, 1);
 
        dyp_little_crab("dyp_little_crab_4", 4, 6, 1);
 
        dyp_little_crab("dyp_little_crab_5", 5, 3, 2);
 
        dyp_little_crab("dyp_little_crab_6", 6, 4, 2);
 
        dyp_little_crab("dyp_little_crab_7", 7, 5, 2);
 
    };
 
};
 

	
 
dyp_crab_cave_win = cutscene("dyp_crab_cave_win", "Пещера", [[Вы расправляетесь с выводком крабов, поселившихся в этой пещере. Чуть поодаль, вы видите тело навьяра, истерзанное этими монстрами. ]], "dyp_crab_cave");
 
\ No newline at end of file
game_over.lua
Show inline comments
 
game_over_crab_cave = game_over("game_over_crab_cave", [[Мощный удар острой клешни пробивает стекло скафандра. Захлебываясь холодной соленой водой океана, вы умираете. ]]);
 
 
game_over_caught_iraa = game_over("game_over_caught_iraa", [[Стражник замечает вас и поднимает тревогу. Теперь, даже если вам удастся одолеть его и добыть фрагмент карты, вы ничего не сможете сделать -- на Атлантиде вас немедленно посадят под арест, а навьяры тепеь точно нестанут вам помогать. ]]);
 
 
game_over_banished_lfc = game_over("game_over_banished_lfc", [[Как только вы оказываетесь в межсекционном коридоре, вас окружают стражники Атлантиды. Они просят вас проследовать за ними и вы понимаете, что сопротивление бесполезно. Вас проводят в кабинет Винсента Даркстара. Когда стражники выходят, начальник службы безопасности поднимается из-за стола и начинает вас отчитывать:"Господин Дрейк. Вы крайне разочаровали меня. Мало того! Вы поставили под угрозу дальнейшую работу станции", -- впервые вы слышите, как Даркстар практически срывается на крик -- до этого он всегда говорил спокойно и уверенно, -- "Отныне, вы лишены всяческих привилегий и при первой возможности будете депортированы". Когда вы выходите из кабинета, охранники сопроваждают вас в вашу каюту и запирают там. Несколько месяцев вы проводите взаперти. Уильям и Адриан Блэк так и не вернулись из своей экспедиции.^Вскоре вас в запертой каюте Левиафана, мало отличающейся от каюты на станции, высылают на поверхность. Вас высаживают возле одного из небольшихэ прибрежных городков соединенных штатов, откуда вы без проблем доберетесь куда угодно. Однако, путь на Атлантиду потерян для вас навсегда.  ]]);
images/checkerblack.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/checkerblackq.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/checkerboard.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/checkerwhite.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/checkerwhiteq.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/king_crab.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/learr.png
Show inline comments
 
binary diff not shown
Show images
images/little_crab.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_1.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_2.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_3.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_4.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_5.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_6.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/little_crab_7.png
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
images/player.png
Show inline comments
 
binary diff not shown
Show images
journey_nleyyslanotrr.lua
Show inline comments
 
@@ -1210,7 +1210,6 @@ za_plaetlarr_fight = battlefield {
 
    win = "za_plaetlarr_victory";
 
    underwater = true;
 
    entered = function(s)
 
        --TODO prepend player associate - anna, learr, walter or jack
 
        if (char_learr.follow) then
 
            table.insert(s.obj, 2, za_cmbt_learr);
 
            s.plX = 3;
journey_venaedanotrr.lua
Show inline comments
 
@@ -434,7 +434,7 @@ ven_tower_l2 = room {
 
        end );
 
    };
 
}
 
        
 

	
 
ven_tower_l3 = room {
 
    var {
 
        state = 0;
london.lua
Show inline comments
 
@@ -74,6 +74,33 @@ port_street = room {
 
		vroom("В пивную лавку", "ginshop");
 
	};
 
	dsc = [[Вы с трудом пробираетесь сквозь толпы людей, спешащих по своим делам. Из порта доносятся гудки пароходов. Со всех сторон доносится шум большого города. Тяжелые черные тучи медленно плывут по небу, грозя разразиться дождем в любую минуту. ]];
 
    obj = {
 
        "dice_player"
 
    };
 
};
 
 
dice_player = npc {
 
    nam = "char_dice_player";
 
    disp = "Игрок";
 
    dsc = [[У дверей пивной лавки сидит на раскладном стульчике хитрого вида {тип} в мятом старом костюме и не менее старой и мятой кепкой, он раглядывает прохожих. В руке он вертит обычную шестигранную игральную кость. ^]];
 
    dlg = "dice_player_dlg";
 
};
 
 
dice_player_dlg = dlg {
 
    nam = "dice_player_dlg";
 
    disp = "Игрок";
 
    entered = [[Человек обращается к вам: "Эй, сыграем?"]];
 
    phr = {
 
        {always=true, "Во что играем?", [[Человек объясняет правила: "Играем в свинью. Все просто -- сперва мы бросаем кость. У кого выпадет больше -- тот ходит первым. Ходящий кидает кость пока не выкинет единицу или ему не надоест. Сколько выпадает на кости, стольок очков он прибавляет себе. Если выпадает единица - все очки набранные за ход теряются. Ну так, что? Играем?"]]};
 
        {always=true, "Я сыграю. ", [[Человек потирает руки, спрашивая: "Сколько ставим?"]], code [[psub("stake");]]};
 
        {always=true, "Не в этот раз. ", code [[back();]]};
 
        {tag="stake"};
 
        {always=true, "5 шиллингов. ", code [[dice_game.stake = 5; walk("dice_game");]]};
 
        {always=true, "10 шиллингов. ", code [[dice_game.stake = 10; walk("dice_game");]]};
 
        {always=true, "25 шиллингов. ", code [[dice_game.stake = 25; walk("dice_game");]]};
 
        {always=true, "50 шиллингов. ", code [[dice_game.stake = 50; walk("dice_game");]]};
 
        {always=true, "Я передумал", code [[back();]]};
 
    };
 
};
 
 
char_worker = npc {
london_checkers.lua
Show inline comments
 
new file 100644
 
checkers_game = room {
 
    var {
 
        board = {};
 
        selected = 0;
 
        select_lock = false;
 
    };
 
    nam = "checkers_game";
 
    nosave = true;
 
    noautosave = true;
 
    forcedsc = true;
 
    randomness = 15;
 
    depth = 6;
 
    cutoff_lo = -3;
 
    cutoff_hi = 3;
 
    draw_board = function(board)
 
        rval = {
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
            {0,0,0,0,0,0,0,0};
 
        };
 
        
 
        for i = 1, #board do
 
            if board[i][3] then
 
                if board[i][4] then
 
                    rval[board[i][1]][board[i][2]] = 3;
 
                else
 
                    rval[board[i][1]][board[i][2]] = 1;
 
                end;
 
            else
 
                if board[i][4] then
 
                    rval[board[i][1]][board[i][2]] = 4;
 
                else
 
                    rval[board[i][1]][board[i][2]] = 2;
 
                end;
 
            end;
 
        end;
 
        
 
        return rval;
 
    end;
 
    calc_take = function(s, x, y, w, q, map)
 
        local rval = {};
 
        local r = nil;
 
        if w then
 
            -- белый рубит черного - рубит вверх
 
            if (map[x - 1][y - 1] == 2 or map[x - 1][y - 1] == 4)
 
                and map[x - 2][y - 2] == 0 and x - 2 > 0 and y - 2 > 0 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x - 2, y - 2, w, q or y == 2, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x-1, y-1}}, q or y == 2, x-2, y-2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x-1, y-1};
 
                    r[i][3] = r[i][3] or q or y == 2;
 
                    rval[#rval + 1] = r[i]
 
                end;
 
            end;
 
            if (map[x + 1][y - 1] == 2 or map[x + 1][y - 1] == 4)
 
                and map[x + 2][y - 2] == 0 and x + 2 < 9 and y - 2 > 0 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x + 2, y - 2, w, q or y == 2, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x+1, y-1}}, q or y == 2, x+2, y-2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x+1, y-1};
 
                    r[i][3] = r[i][3] or q or y == 2;
 
                    rval[#rval + 1] = r[i]
 
                end;
 
            end;
 
            --Дамка может рубить и вниз
 
            if q and (map[x - 1][y + 1] == 2 or map[x - 1][y + 1] == 4)
 
                and map[x - 2][y + 2] == 0 and x - 2 > 0 and y + 2 < 9 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x - 2, y + 2, w, q, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x-1, y+1}}, q, x-2, y+2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x-1, y+1};
 
                    r[i][3] = r[i][3] or q;
 
                    rval[#rval + 1] = r[i];
 
                end;
 
            end;
 
            if q and (map[x + 1][y + 1] == 2 or map[x + 1][y + 1] == 4)
 
                and map[x + 2][y + 2] == 0 and x + 2 < 9 and y + 2 < 9 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x + 2, y + 2, w, q, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x+1, y+1}}, q, x+2, y+2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x+1, y+1};
 
                    r[i][3] = r[i][3] or q;
 
                    rval[#rval + 1] = r[i];
 
                end;
 
            end;
 
        else
 
            --черный рубит белого - рубит вниз
 
            if (map[x - 1][y + 1] == 1 or map[x - 1][y + 1] == 3)
 
                and map[x - 2][y + 2] == 0 and x - 2 > 0 and y + 2 < 9 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x - 2, y + 2, w, q or y == 6, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x-1, y+1}}, q or y == 6, x-2, y+2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x-1, y+1};
 
                    r[i][3] = r[i][3] or q or y == 6;
 
                    rval[#rval + 1] = r[i]
 
                end;
 
            end;
 
            if (map[x + 1][y + 1] == 1 or map[x + 1][y + 1] == 3)
 
                and map[x + 2][y + 2] == 0 and x + 2 < 9 and y + 2 < 9 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x + 2, y + 2, w, q or y == 6, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x+1, y+1}}, q or y == 6, x+2, y+2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x+1, y+1};
 
                    r[i][3] = r[i][3] or q or y == 2;
 
                    rval[#rval + 1] = r[i]
 
                end;
 
            end;
 
            --Дамка может рубить и вниз
 
            if q and (map[x - 1][y - 1] == 1 or map[x - 1][y - 1] == 3)
 
                and map[x - 2][y - 2] == 0 and x - 2 > 0 and y - 2 > 0 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x - 2, y - 2, w, q, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x-1, y-1}}, q or y == 6, x-2, y-2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x-1, y-1};
 
                    r[i][3] = r[i][3] or q;
 
                    rval[#rval + 1] = r[i];
 
                end;
 
            end;
 
            if q and (map[x + 1][y - 1] == 1 or map[x + 1][y - 1] == 3)
 
                and map[x + 2][y - 2] == 0 and x + 2 < 9 and y - 2 > 0 then
 
                mcopy = deepcopy(map);
 
                r = s:calc_take(x + 2, y - 2, w, q, mcopy);
 
                if #r == 0 then
 
                    rval[#rval + 1] = {1, {{x+1, y-1}}, q or y == 6, x+2, y-2};
 
                end;
 
                for i = 1, #r do
 
                    r[i][1] = r[i][1] + 1;
 
                    r[i][2][#r[i][2] + 1] = {x+1, y-1};
 
                    r[i][3] = r[i][3] or q;
 
                    rval[#rval + 1] = r[i];
 
                end;
 
            end;
 
        end;
 
        return rval;
 
    end;
 
    calc_turn = function(s, d, w, board)
 
        if d > s.depth then
 
            return nil, 0;
 
        end;
 
        local cost = 0;
 
        local turns = {};
 
        local bmap = s.draw_board(board);
 
        local takes = false;
 
        for i = 1, #board do
 
            --Рубка обязательна, поэтому сперва проверяем рубки
 
            if board[i][3] == w then
 
                -- своя фигура. Проверяем рубки
 
                local r = s:calc_take(board[i][1], board[i][2], w, board[i][4], bmap);
 
                if #r > 0 then
 
                    takes = true;
 
                    for j = 1, #r do
 
                        --Восстанавливаем состояние поля после рубки и уходим глубже
 
                        local bcopy = deepcopy(board);
 
                        for k = #bcopy, 1, -1 do
 
                            for l = 1, #r[j][2] do
 
                                if r[j][2][1] == bcopy[k][2] and r[j][2][1] == bcopy[k][2] then
 
                                    table.remove(bcopy, k);
 
                                    break;
 
                                end;
 
                            end;
 
                        end;
 
                        local rr, pts = s:calc_turn(d + 1, not w, bcopy);
 
                        turns[#turns + 1] = {board[i][1], board[i][2], r[j][4], r[j][5], r[j][2], r[j][1] - pts};
 
                    end;
 
                end;
 
            end;
 
        end;
 
        -- Если была рубка, не обрабатываем дальше
 
        if takes then
 
            table.sort(turns, function(a,b) 
 
                return a[6] > b[6];
 
            end);
 
            return turns[0], turns[0][6];
 
        end;
 
        for i = 1, #board do
 
            if board[i][3] == w then
 
                --Проверяем ходы
 
                if q or w then
 
                    --белая или дамка - ходит вверх
 
                    if bmap[board[i][1] - 1][board[i][2] - 1] == 0 then
 
                        local bcopy = deepcopy(board);
 
                        bcopy[i][1] = bcopy[i][1] - 1;
 
                        bcopy[i][2] = bcopy[i][2] - 1;
 
                        local rr, pts = s:calc_turn(d + 1, not w, bcopy);
 
                        turns[#turns + 1] = {board[i][1], board[i][2], bcopy[i][1], bcopy[i][2], nil, - pts};
 
                    end;
 
                    if bmap[board[i][1] - 1][board[i][2] + 1] == 0 then
 
                        local bcopy = deepcopy(board);
 
                        bcopy[i][1] = bcopy[i][1] - 1;
 
                        bcopy[i][2] = bcopy[i][2] + 1;
 
                        local rr, pts = s:calc_turn(d + 1, not w, bcopy);
 
                        turns[#turns + 1] = {board[i][1], board[i][2], bcopy[i][1], bcopy[i][2], nil, - pts};
 
                    end;
 
                end;
 
                if q or not w then
 
                    --черная или дамка - ходит вниз
 
                    if bmap[board[i][1] + 1][board[i][2] - 1] == 0 then
 
                        local bcopy = deepcopy(board);
 
                        bcopy[i][1] = bcopy[i][1] + 1;
 
                        bcopy[i][2] = bcopy[i][2] - 1;
 
                        local rr, pts = s:calc_turn(d + 1, not w, bcopy);
 
                        turns[#turns + 1] = {board[i][1], board[i][2], bcopy[i][1], bcopy[i][2], nil, - pts};
 
                    end;
 
                    if bmap[board[i][1] + 1][board[i][2] + 1] == 0 then
 
                        local bcopy = deepcopy(board);
 
                        bcopy[i][1] = bcopy[i][1] + 1;
 
                        bcopy[i][2] = bcopy[i][2] + 1;
 
                        local rr, pts = s:calc_turn(d + 1, not w, bcopy);
 
                        turns[#turns + 1] = {board[i][1], board[i][2], bcopy[i][1], bcopy[i][2], nil, - pts};
 
                    end;
 
                end;
 
            end;
 
        end;
 

	
 
        table.sort(turns, function(a,b) 
 
            return a[6] > b[6];
 
        end);
 
        return turns[0], turns[0][6];
 
    end;
 
    enemy_turn = function(s)
 
    end;
 
    click = function(s, x, y)
 
        x = math.floor((x - 4) / 24) + 1;
 
        y = math.floor((y - 4) / 24) + 1;
 
        if x > 0 and x < 9 and y > 0 and y < 9 then
 
            for i = 1,#s.board do
 
                if s.board[i][1] == x and s.board[i][2] == y then
 
                    if s.board[i][3] then
 
                        s.selected = i;
 
                        walkin(here());
 
                        return;
 
                    else
 
                        --Может рубим?
 
                        if s.selected > 0 then
 
                            print("q");
 
                            local dx = x - s.board[s.selected][1];
 
                            local dy = y - s.board[s.selected][2];
 
                            if s.board[s.selected][4] then
 
                                if math.abs(dx) == 1 and math.abs(dy) == 1 then
 
                                    s.board[s.selected][1] = s.board[s.selected][1] + dx * 2;
 
                                    s.board[s.selected][2] = s.board[s.selected][2] + dy * 2;
 
                                    s.selected = 0;
 
                                    walkin(here());
 
                                    return;
 
                                end;
 
                            else
 
                                if math.abs(dx) == 1 and dy == -1 then
 
                                    s.board[s.selected][1] = s.board[s.selected][1] + dx * 2;
 
                                    s.board[s.selected][2] = s.board[s.selected][2] + dy * 2;
 
                                    s.selected = 0;
 
                                    walkin(here());
 
                                    return;
 
                                end;
 
                            end;
 
                    end;
 
                        return;
 
                    end;
 
                end;
 
            end;
 
            
 
            if s.selected > 0 then
 
                local dx = x - s.board[s.selected][1];
 
                local dy = y - s.board[s.selected][2];
 
                print(dx, dy);
 
                if s.board[s.selected][4] then
 
                    if math.abs(dx) == 1 and math.abs(dy) == 1 then
 
                        s.board[s.selected][1] = x;
 
                        s.board[s.selected][2] = y;
 
                        s.selected = 0;
 
                        walkin(here());
 
                        return;
 
                    end;
 
                else
 
                    if math.abs(dx) == 1 and dy == -1 then
 
                        s.board[s.selected][1] = x;
 
                        s.board[s.selected][2] = y;
 
                        print(s.board[s.selected][1], s.board[s.selected][2])
 
                        s.selected = 0;
 
                        walkin(here());
 
                        return;
 
                    end;
 
                end;
 
            end;
 
            s.selected = 0;
 
        
 
            
 
        end;
 
        walkin(here());
 
    end;
 
    disp = "Шашки";
 
    reset = function(s)
 
        s.board = {
 
            {2, 3, false, false};
 
            {4, 3, false, false};
 
            {6, 3, false, false};
 
            {8, 3, false, false};
 
            
 
            --{1, 2, false, false};
 
            --{3, 2, false, false};
 
            --{5, 2, false, false};
 
            --{7, 2, false, false};
 
            
 
            {2, 5, false, false};
 
            {4, 5, false, false};
 
            {6, 5, false, false};
 
            {8, 5, false, false};
 
            
 
            {1, 6, true, false};
 
            {3, 6, true, false};
 
            {5, 6, true, false};
 
            {7, 6, true, false};
 
            
 
            {2, 7, true, false};
 
            {4, 7, true, false};
 
            {6, 7, true, false};
 
            {8, 7, true, false};
 
            
 
            {1, 8, true, false};
 
            {3, 8, true, false};
 
            {5, 8, true, false};
 
            {7, 8, true, false};
 
        };
 
    end;
 
    pic = function(s)
 
        local rval = "images/checkerboard.png";
 
        if s.selected > 0 then
 
            rval = rval .. [[;box:24x24,red,32@]] .. tostring(s.board[s.selected][1] * 24 - 20) .. "," .. tostring(s.board[s.selected][2] * 24 - 20);
 
        end;
 
        for i = 1, #s.board do
 
            if s.board[i][3] and s.board[i][4] then
 
                rval = rval .. [[;images/checkerwhiteq.png@]] .. tostring(s.board[i][1] * 24 - 20) .. "," .. tostring(s.board[i][2] * 24 - 20);
 
            elseif not s.board[i][3] and s.board[i][4] then
 
                rval = rval .. [[;images/checkerblackq.png@]] .. tostring(s.board[i][1] * 24 - 20) .. "," .. tostring(s.board[i][2] * 24 - 20);
 
            elseif s.board[i][3] and not s.board[i][4] then
 
                rval = rval .. [[;images/checkerwhite.png@]] .. tostring(s.board[i][1] * 24 - 20) .. "," .. tostring(s.board[i][2] * 24 - 20);
 
            elseif not s.board[i][3] and not s.board[i][4] then
 
                rval = rval .. [[;images/checkerblack.png@]] .. tostring(s.board[i][1] * 24 - 20) .. "," .. tostring(s.board[i][2] * 24 - 20);
 
            end;
 
        end;
 
        return rval;
 
    end;
 
};
 
\ No newline at end of file
london_dice.lua
Show inline comments
 
new file 100644
 
dice_game = room {
 
    var {
 
        player_pts = 0;
 
        current_pts = 0;
 
        enemy_pts = 0;
 
        first = false;
 
        state = 0;
 
    };
 
    nosave = true;
 
    noautosave = true;
 
    forcedsc = true;
 
    nam = "dice_game";
 
    disp = "Игра в кости";
 
    win = "dice_game_win";
 
    lose = "dice_game_lose";
 
    draw = "dice_game_draw";
 
    entered = function(s)
 
        s.player_pts = 0;
 
        s.enemy_pts = 0;
 
        s.current_pts = 0;
 
        s.state = 0;
 
        dg_pass:disable();
 
        dg_roll:enable();
 
    end;
 
    dsc = function(s)
 
        if s.state == 0 then
 
            return [[Определяем очередность ходов. Бросайте кость. ]];
 
        else
 
            return([[Очки:^Вы:]] .. s.player_pts .. [[^Соперник:]] .. s.enemy_pts .. [[^Текущий раунд:]] .. s.current_pts);
 
        end;
 
    end;
 
    obj = {
 
        "dg_roll";
 
        "dg_pass";
 
    };
 
    player_turn = function(s)
 
        if s.turn and (s.player_pts >= 100 or s.enemy_pts >= 100) then
 
            if s.player_pts >= 100 and s.enemy_pts >= 100 then
 
                walk(s.draw);
 
            elseif s.player_pts >= 100 then
 
                walk(s.win);
 
            else
 
                walk(s.lose);
 
            end;
 
        end;
 
        s.state = 1;
 
        s.current_pts = 0;
 
        timer:stop();
 
        game.timer = nil;
 
        dg_roll:enable();
 
        dg_pass:enable();
 
    end;
 
    enemy_turn = function(s)
 
        if not s.turn and (s.player_pts >= 100 or s.enemy_pts >= 100) then
 
            if s.player_pts >= 100 and s.enemy_pts >= 100 then
 
                walk(s.draw);
 
            elseif s.player_pts >= 100 then
 
                walk(s.win);
 
            else
 
                walk(s.lose);
 
            end;
 
        end;
 
        s.state = 1;
 
        s.current_pts = 0;
 
        game.timer = s.make_enemy_turn;
 
        timer:set(2500);
 
        dg_roll:disable();
 
        dg_pass:disable();
 
    end;
 
    make_enemy_turn = function()
 
        local s = dice_game;
 
        local pl = rnd(6);
 
        pr [[Соперник бросает кости. ]];
 
        pr([[Результат броска: ]] .. tostring(pl) .. [[.^]]);
 
        if pl == 1 then
 
            pr [[Ваш соперник теряет ход. ]];
 
            s:player_turn();
 
        else
 
            s.current_pts = s.current_pts + pl;
 
            local r = rnd(20);
 
            if r == 1 then
 
                s.enemy_pts = s.enemy_pts + s.current_pts;
 
                pr [[Соперник передает вам ход. ]];
 
                s:player_turn();
 
            elseif r == 2 then
 
                pr [[Соперник продолжает игру. ]];
 
            elseif s.enemy_pts > s.player_pts then
 
                if s.enemy_pts + s.current_pts >= 100 then
 
                    s.enemy_pts = s.enemy_pts + s.current_pts;
 
                    pr [[Соперник передает вам ход. ]];
 
                    s:player_turn();
 
                else
 
                    pr [[Соперник продолжает игру. ]];
 
                end;
 
            else
 
                if s.enemy_pts + s.current_pts >= s.player_pts then
 
                    s.enemy_pts = s.enemy_pts + s.current_pts;
 
                    pr [[Соперник передает вам ход. ]];
 
                    s:player_turn();
 
                else
 
                    pr [[Соперник продолжает игру. ]];
 
                end;
 
            end;
 
        end;
 
    end;
 
};
 

	
 
dg_roll = obj {
 
    nam = "dg_roll";
 
    dsc = [[{Бросить кость. }^]];
 
    act = function(s)
 
        if dice_game.state == 0 then
 
            local pl = rnd(6);
 
            local en = rnd(6);
 
            pr([[У вас выпало ]] .. tostring(pl) .. [[ очков. У соперника -- ]] .. tostring(en) .. [[. ]]);
 
            if pl > en then
 
                pr [[Вы ходите первым. Бросайте кость. ]];
 
                dice_game.first = true;
 
                dice_game:player_turn();
 
            elseif pl < en then
 
                pr [[Ваш соперник ходит первым. ]];
 
                dice_game.first = false;
 
                dice_game:enemy_turn();
 
            else
 
                pr [[Результаты совпали. Повторите бросок. ]];
 
            end;
 
        else
 
            local pl = rnd(6);
 
            pr([[Результат броска: ]] .. tostring(pl) .. [[.^]]);
 
            if pl == 1 then
 
                pr [[Вы теряете набранные очки. ]];
 
                dice_game:enemy_turn();
 
            else
 
                dice_game.current_pts = dice_game.current_pts + pl;
 
            end;
 
        end;
 
    end;
 
};
 

	
 
dg_pass = obj {
 
    nam = "dg_pass";
 
    dsc = [[{Передать ход. }^]];
 
    act = function(s)
 
        dice_game.player_pts = dice_game.player_pts + dice_game.current_pts;
 
        dice_game.current_pts = 0;
 
        dice_game:enemy_turn();
 
        return [[]];
 
    end;
 
};
 

	
 
dice_game_draw = cutscene("dice_game_draw", "Игра в кости", [[Человек разводит руками: "Ничья. Сыграем еще раз?"]], "port_street");
 

	
 

	
 
dice_game_win = cutscene("dice_game_win", "Игра в кости", [[Человек вручает вам сумму выигрыша: "Поздравляю, вы выиграли! Сыграем еще?"]], "port_street", function()
 
    pl.money = pl.money + dice_game.stake;
 
end);
 

	
 
dice_game_lose = cutscene("dice_game_lose", "Игра в кости", [[Человек довольно потирает руки и прячет в карман ваши деньги: "В следующий раз вам повезет. Может сыграем еще?"]], function()
 
    pl.money = pl.money - dice_game.stake;
 
end);
 
\ No newline at end of file
main.lua
Show inline comments
 
@@ -9,6 +9,7 @@ require "quotes"
 
require "hideinv"
 
require "kbd"
 
require "timer"
 
require "click"
 
 
-- Код и ядро
 
dofile "utils.lua"
 
@@ -25,6 +26,8 @@ dofile "dock2.lua"
 
dofile "warehouse18.lua"
 
dofile "warehouse32.lua"
 
dofile "leviathan.lua"
 
dofile "london_dice.lua"
 
dofile "london_checkers.lua"
 
-- Часть 2: Атлантида
 
dofile "atlantis.lua"
 
dofile "atlantis_ignis.lua"
 
@@ -82,7 +85,19 @@ global {
 
    svetlova_help = 0; -- Дополнительная помощь, оказанная Светловой в исследовании навьяров --увеличивается, если показать ей КНО и скипетр
 
};
 
 
game.enable_save = function ()
 
    if here().nosave then
 
        return false;
 
    end;
 
    return true;
 
end;
 
 
game.enable_autosave = function ()
 
    if here().noautosave then
 
        return false;
 
    end;
 
    return true;
 
end;
 
 
player_drake = player {
 
    var {
 
@@ -182,7 +197,7 @@ function init()
 
    ---game init
 
    pl.where = intro;
 
    ---debug	
 
    language_known = true;
 
    --language_known = true;
 
    --pl.where = "leviathan_airlock";
 
    --move(submarine_leviathan, "iyh_rear_entrance_foot");
 
    --put(item_suit, pl);
 
@@ -191,9 +206,8 @@ function init()
 
    --pl.where = "atlantis_intro_dock";
 
 
    ---leviathan
 
    pl.where = "atl_terra_main_corridor";
 
    submarine_leviathan.airpump = false;
 
    --[[]]
 
    --submarine_leviathan.airpump = false;
 
    --[[
 
    leviathan_airlock.has_light = true;
 
    leviathan_wardroom.has_light = true;
 
    leviathan_wheelhouse.has_light = true;
 
@@ -215,9 +229,14 @@ function init()
 
    submarine_leviathan.valves_to_replace = 0;
 
    submarine_leviathan.power_on = true
 
    pl.party = {'wright', 'learr'};
 
    char_learr.follow = true;
 
    atlantis_found = true;--]]
 
    --take(item_colt);
 
    --take(item_harpoon);
 
   -- checkers_game:reset();
 
    --pl.where = "checkers_game";
 
    --- iraaphaanotrr
 
    move(submarine_leviathan, "iraa_temple_entrance");
 
   --move(submarine_leviathan, "iraa_temple_entrance");
 
	--[[
 
	---IYH
 
	lifeon(char_learr);
utils.lua
Show inline comments
 
@@ -875,6 +875,8 @@ labyrinth = function(tab)
 
    tab.dsc = function(s)
 
        if (type(dsc) == "function") then
 
            return dsc(s);
 
        elseif dsc == nil then
 
            return s.map[s.position].name;
 
        else
 
            return dsc .. s.map[s.position].name;
 
        end;
 
@@ -918,4 +920,19 @@ labyrinth = function(tab)
 
    
 
    stead.add_var(tab, { oldposition = tab.position; });
 
    return lab;
 
end;
 
 
function deepcopy(orig)
 
    local orig_type = type(orig)
 
    local copy
 
    if orig_type == 'table' then
 
        copy = {}
 
        for orig_key, orig_value in next, orig, nil do
 
            copy[deepcopy(orig_key)] = deepcopy(orig_value)
 
        end
 
        setmetatable(copy, deepcopy(getmetatable(orig)))
 
    else -- number, string, boolean, etc
 
        copy = orig
 
    end
 
    return copy
 
end;
 
\ No newline at end of file
0 comments (0 inline, 0 general)