Changeset - b452ad484de2
[Not reviewed]
default
0 3 1
Silverwing - 6 years ago 2018-09-01 15:25:45

prologue: warehouse32 refactor
4 files changed with 278 insertions and 436 deletions:
0 comments (0 inline, 0 general)
main.lua
Show inline comments
 
@@ -14,11 +14,12 @@ require "prefs"
 
 
-- Код и ядро
 
dofile "utils.lua"
 
dofile "battlefield.lua";
 
dofile "battlefield.lua"
 
dofile "stealth.lua"
 
-- Общее
 
dofile "items.lua"
 
dofile "party.lua"
 
dofile "game_over.lua";
 
dofile "game_over.lua"
 
-- Часть 1: Лондон. Пролог
 
dofile "london.lua"
 
dofile "wright.lua"
 
@@ -35,6 +36,7 @@ dofile "atlantis_dlg.lua"
 
dofile "atlantis_intro.lua"
 
dofile "atlantis_iraa.lua"
 
dofile "atlantis_dyp.lua"
 
dofile "atlantis_dyp_night.lua"
 
dofile "atlantis_from_the_ashes.lua"
 
dofile "atlantis_iyhehevjiarr.lua"
 
-- Часть 3: Путь в Лсэрианотр
 
@@ -49,4 +51,4 @@ dofile "lse_service_tunnels.lua"
 
dofile "lse_powerplant.lua";
 
dofile "lse_final_battle.lua";
 
 
dofile "startup.lua";
 
\ No newline at end of file
 
dofile "startup.lua";
startup.lua
Show inline comments
 
@@ -167,158 +167,5 @@ function init()
 
    pl.where = intro;
 
    ---debug
 
    
 
    --pl.where = "item_book_dlg";
 
    --pl.where = "dyp_obelisk_puzzle";
 
    --language_known = true;
 
    --put("item_toolbox", pl);
 
    --put("item_electric_lamp", pl);
 
    --put("item_dynamo", pl);
 
    --put("item_toolbox", pl);
 
    --put("item_cogs", pl);
 
    --put("item_ducttape", pl);
 
    --put("item_electrodes", pl);
 
    --pl.where = dock_2;
 
    --pl.where = warehouse_32;
 
    --put(item_lamp, pl);
 
    --language_known = true;
 
    --pl.where = "leviathan_airlock";
 
    --move(submarine_leviathan, "iyh_rear_entrance_foot");
 
    --put(item_suit, pl);
 
    --put(item_suit, pl);
 

	
 
    --pl.where = "atlantis_intro_dock";
 

	
 
    ---leviathan
 
    --submarine_leviathan.airpump = false;
 
    --[[
 
    leviathan_airlock.has_light = true;
 
    leviathan_wardroom.has_light = true;
 
    leviathan_wheelhouse.has_light = true;
 
    leviathan_corridor.has_light = true;
 
    leviathan_cabin_1.has_light = true;
 
    leviathan_cabin_2.has_light = true;
 
    leviathan_cabin_3.has_light = true;
 
    leviathan_cabin_4.has_light = true;
 
    leviathan_cabin_5.has_light = true;
 
    leviathan_captains_cabin.has_light = true;
 
    leviathan_cargo_hold.has_light = true;
 
    leviathan_engines.has_light = true;
 
    leviathan_lower_deck.has_light = true;
 
    leviathan_life_support.has_light = true;
 
    submarine_leviathan.air_level = 432000;
 
    submarine_leviathan.battery = true; 
 
    submarine_leviathan.battery_charge = 100;
 
    submarine_leviathan.circuit_breaks = 0;
 
    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");
 
    --[[
 
    ---IYH
 
    lifeon(char_learr);
 
    lifeon(char_wright);
 
    lifeon(char_radcliffe);
 
    lifeon(char_anna);
 
    lifeon(char_aikerjarr_lev);
 
    pl.party = {'learr', 'wright', 'radcliffe', 'anna'};
 
    atlantis_found = true;
 
    move(submarine_leviathan, "ctt_dyp_temple_entrance");
 
    --move(submarine_leviathan, "iyh_far_from_entrance_foot");
 
    pl.where = leviathan_wheelhouse;
 
    submarine_leviathan.battery = true; -- Состояние батареи 
 
    submarine_leviathan.battery_charge = 100; -- Уровень заряда батареи
 
    submarine_leviathan.circuit_breaks = 0; -- Разрывы цепи
 
    submarine_leviathan.valves_to_replace = 0; -- Количество клапанов, которые нужно заменить для полноценной работы
 
    submarine_leviathan.power_on = true; -- включена ли энергия
 
    submarine_leviathan.air_level = 432000; -- запас воздуха. Максимум - 5 дней(5 * 24 * 60 * 60 = 432000)
 
    submarine_leviathan.airpump = false;
 
    leviathan_airlock.has_light = true;
 
    leviathan_wardroom.has_light = true;
 
    leviathan_wheelhouse.has_light = true;
 
    leviathan_corridor.has_light = true;
 
    leviathan_cabin_1.has_light = true;
 
    leviathan_cabin_2.has_light = true;
 
    leviathan_cabin_3.has_light = true;
 
    leviathan_cabin_4.has_light = true;
 
    leviathan_cabin_5.has_light = true;
 
    leviathan_captains_cabin.has_light = true;
 
    leviathan_cargo_hold.has_light = true;
 
    leviathan_engines.has_light = true;
 
    leviathan_lower_deck.has_light = true;
 
    leviathan_life_support.has_light = true;
 
    --]]
 
    
 
    --- Chapter 1: Atlantis
 
    --[[submarine_leviathan.battery = true; -- Состояние батареи 
 
    submarine_leviathan.battery_charge = 100; -- Уровень заряда батареи
 
    submarine_leviathan.circuit_breaks = 0; -- Разрывы цепи
 
    submarine_leviathan.valves_to_replace = 0; -- Количество клапанов, которые нужно заменить для полноценной работы
 
    submarine_leviathan.power_on = true; -- включена ли энергия
 
    submarine_leviathan.air_level = 432000; -- запас воздуха. Максимум - 5 дней(5 * 24 * 60 * 60 = 432000)
 
    submarine_leviathan.airpump = false;
 
    leviathan_airlock.has_light = true;
 
    leviathan_wardroom.has_light = true;
 
    leviathan_wheelhouse.has_light = true;
 
    leviathan_corridor.has_light = true;
 
    leviathan_cabin_1.has_light = true;
 
    leviathan_cabin_2.has_light = true;
 
    leviathan_cabin_3.has_light = true;
 
    leviathan_cabin_4.has_light = true;
 
    leviathan_cabin_5.has_light = true;
 
    leviathan_captains_cabin.has_light = true;
 
    leviathan_cargo_hold.has_light = true;
 
    leviathan_engines.has_light = true;
 
    leviathan_lower_deck.has_light = true;
 
    leviathan_life_support.has_light = true;
 
    
 
    pl.party = {'wright'};
 
    put(item_toolbox, pl);
 
    put(item_ducttape, pl);
 
    pl.where = "leviathan_airlock";
 
    atlantis_found = true;
 
    move(submarine_leviathan, "atl_aqua_leviathan_dock");
 
    submarine_leviathan:enable();   ]]
 
           
 
    --ven_temple_l1.position = "66";   
 
    --put(item_ven_tablet, pl);
 
    --put(item_harpoon, pl);
 
    --put(item_colt, pl);
 
    --ven_shark.position = "55";
 
    --pl.where = "za_plaetlarr_fight";
 
    --pl.where = "lse_final_battle";
 
    --move(submarine_leviathan, "za_temple_back_entrance_foot");
 
    --char_anna.follow = true;
 
    --pl.where = "ven_chest_look";
 
    --move(ven_shark, "ven_temple_l1");
 
    
 
    --put(item_suit, pl);
 
    
 
    -- pl.where = warehouse_32;
 
    -- pl.where = w32_mgr;
 
    
 
    -- put(item_cogs, pl);
 
    -- put(item_pump_details, pl);
 
    -- put(item_electrodes, pl);
 
    --put(item_lamp, pl);
 
    -- pl.where = aurora_borealis;
 
    -- move(submarine_leviathan, first_city_entrance);
 
    -- move(submarine_leviathan, first_city_outer_east);
 
    -- walk(final_scene);
 
    -- walk(leviathan_wardroom);
 
    -- walk(leviathan_wardroom);
 
    -- put("char_learr", "leviathan_wardroom");
 
    -- put("char_phaetlarr", "leviathan_engines");
 
    -- put("char_radcliffe", "leviathan_engines");
 
    -- put("char_wright", "leviathan_wardroom");
 
    -- pl.where = leviathan_airlock;
 
    -- pl.where = hotel_street;
 
    -- pl.where = warehouse_32_entry;
 
    -- dock_found = true;
 
    pl.where = "warehouse_32";
 
end; 
stealth.lua
Show inline comments
 
new file 100644
 
function getDirName(dir)
 
    if (dir == 1) then
 
        return "север";
 
    elseif (dir == 2) then
 
        return "восток";
 
    elseif (dir == 3) then
 
        return "юг";
 
    elseif (dir == 4) then
 
        return "запад";
 
    end;
 
end;
 

	
 
stealthroom = function(tab)
 
    tab.nolamp = true;
 
    tab.pic = function(s)
 
        local pl_y = math.floor(tonumber(s.pos) / 10);
 
        local pl_x = tonumber(s.pos) % 10;
 
        local pl_xm = pl_x * 2 + 1;
 
        local deltax = 0;
 
        local deltay = 0;
 
        if pl_x == 0 then
 
            pl_xm = 2;
 
            deltax = -32;
 
        elseif pl_x == 5 then
 
            pl_xm = 10;
 
            deltax = 32;
 
        end;
 
        local pl_ym = pl_y * 2 + 1;
 
        if pl_y == 0 then
 
            pl_ym = 2;
 
            deltay = 32;
 
        elseif pl_y == 5 then
 
            pl_ym = 10;
 
            deltay = -32;
 
        end;
 
        local rval = "images/" .. s.background .. ".png";
 

	
 
        for x = 0, 8 do
 
            for y = 0, 8 do
 
                print(pl_ym - 4 + y, pl_xm - 4 + x)
 
                if pl_xm - 4 + x > 0 and pl_ym - 4 + y > 0 and pl_xm - 4 + x < 12 and pl_ym - 4 + y < 12 then
 
                    if s.map[pl_ym - 4 + y][pl_xm - 4 + x] == 1 then
 
                        rval = rval .. ";images/" .. s.wall .. ".png@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                    elseif s.map[pl_ym - 4 + y][pl_xm - 4 + x] == 2 then
 
                        rval = rval .. ";images/" .. s.door .. ".png@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                    elseif s.map[pl_ym - 4 + y][pl_xm - 4 + x] == 3 then
 
                        rval = rval .. ";images/" .. s.obstacle .. ".png@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                    end;
 
                else
 
                    rval = rval .. ";box:32x32,black,255@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                end;
 
            end;
 
        end;
 

	
 

	
 
        for i = 1, #s.guards do
 
            local g_y = math.floor(tonumber(s.guards[i].pos) / 10);
 
            local g_x = tonumber(s.guards[i].pos) % 10;
 
            if pl_y - g_y == 0 or pl_x - g_x == 0 and math.abs(pl_y - g_y) + math.abs(pl_x - g_x) < 3 then
 
                rval = rval .. ";images/" .. s.guard .. tostring(s.guards[i].dir) .. ".png@" .. tostring((g_x - pl_x) * 64 + 128 + deltax) .. ",".. tostring((pl_y - g_y) * 64 + 128 + deltay);
 
            end;
 
            if math.abs(pl_y - g_y) == 1 and math.abs(pl_x - g_x) == 1 then
 
                rval = rval .. ";images/unseen_enemy.png@" .. tostring((g_x - pl_x) * 64 + 128 + deltax) .. ",".. tostring((pl_y - g_y) * 64 + 128 + deltay);
 
            end;
 
        end;
 

	
 
        rval = rval .. ";images/" .. s.player .. ".png@128,128";
 
        print(rval);
 
        return rval .. ";images/wh32_mask.png";
 
    end;
 

	
 
    tab.disp = function(s)
 
        return s.definitions[s.pos].name;
 
    end;
 

	
 
    tab.checkGuardSight = function(s)
 
        --Проверить область зрения каждого стражника, если игрок находится в области зрения - FAIL
 
        for i = 1, #s.guards do
 
            if (s.guards[i].pos == s.pos) then
 
                --detected
 
                walk(s.game_over);
 
                return false;
 
            end;
 
            if (s.guards[i].dir == 1) then
 
                if (not s.hidden and s.definitions[s.guards[i].pos].e1 and s.pos == s.definitions[s.guards[i].pos].e1) then
 
                    --detected
 
                    walk(s.game_over);
 
                    return false;
 
                end;
 
            elseif (s.guards[i].dir == 2) then
 
                if (not s.hidden and s.definitions[s.guards[i].pos].e2 and s.pos == s.definitions[s.guards[i].pos].e2) then
 
                    --detected
 
                    walk(s.game_over);
 
                    return false;
 
                end;
 
            elseif (s.guards[i].dir == 3) then
 
                if (not s.hidden and s.definitions[s.guards[i].pos].e3 and s.pos == s.definitions[s.guards[i].pos].e3) then
 
                    --detected
 
                    walk(s.game_over);
 
                    return false;
 
                end;
 
            elseif (s.guards[i].dir == 4) then
 
                if (not s.hidden and s.definitions[s.guards[i].pos].e4 and s.pos == s.definitions[s.guards[i].pos].e4) then
 
                    --detected
 
                    walk(s.game_over);
 
                    return false;
 
                end;
 
            end;
 
        end;
 
        return true;
 
    end;
 

	
 
    makeTurn = tab.makeTurn;
 
    tab.makeTurn = function(s)
 
        if (s:checkGuardSight()) then
 
            s:guardTurn();
 
            if (s:checkGuardSight()) then
 

	
 
                if (s.definitions[s.pos].e1 or s.definitions[s.pos].ex1) then
 
                    path("На север"):enable();
 
                else
 
                    path("На север"):disable();
 
                end;
 

	
 
                if (s.definitions[s.pos].e2 or s.definitions[s.pos].ex2) then
 
                    path("На восток"):enable();
 
                else
 
                    path("На восток"):disable();
 
                end;
 

	
 
                if (s.definitions[s.pos].e3 or s.definitions[s.pos].ex3) then
 
                    path("На юг"):enable();
 
                else
 
                    path("На юг"):disable();
 
                end;
 

	
 
                if (s.definitions[s.pos].e4 or s.definitions[s.pos].ex4) then
 
                    path("На запад"):enable();
 
                else
 
                    path("На запад"):disable();
 
                end;
 

	
 
                if (s.definitions[s.pos].corner) then
 
                    path("Спрятаться"):enable();
 
                else
 
                    path("Спрятаться"):disable();
 
                end;
 

	
 
                if (s.hidden) then
 
                    path("Спрятаться"):disable();
 
                    path("Выбраться из укрытия"):enable();
 
                    path("На запад"):disable();
 
                    path("На восток"):disable();
 
                    path("На север"):disable();
 
                    path("На юг"):disable();
 
                else
 
                    path("Выбраться из укрытия"):disable();
 
                end;
 

	
 
            end;
 
        end;
 
    end;
 

	
 
    tab.way = {
 
        kh_vroom("На север", function(s)
 
            if (rm.definitions[rm.pos].ex1) then
 
                return rm.definitions[rm.pos].ex1;
 
            else
 
                rm.pos = rm.definitions[rm.pos].e1;
 
            end;
 

	
 
            return rm;
 
        end);
 

	
 
        kh_vroom("На юг", function(s)
 
            if (rm.definitions[rm.pos].ex3) then
 
                return rm.definitions[rm.pos].ex3;
 
            else
 
                rm.pos = rm.definitions[rm.pos].e3;
 
            end;
 

	
 
            return rm;
 
        end);
 

	
 
        kh_vroom("На запад", function(s)
 
            if (rm.definitions[rm.pos].ex4) then
 
                return rm.definitions[rm.pos].ex4;
 
            else
 
                rm.pos = rm.definitions[rm.pos].e4;
 
            end;
 

	
 
            return rm;
 
        end);
 

	
 
        kh_vroom("На восток", function(s)
 
            if (rm.definitions[rm.pos].ex2) then
 
                return rm.definitions[rm.pos].ex2;
 
            else
 
                rm.pos = rm.definitions[rm.pos].e2;
 
            end;
 

	
 
            return rm;
 
        end);
 

	
 
        kh_vroom("Ждать", function(s)
 
            return rm;
 
        end);
 

	
 
        kh_vroom("Спрятаться", function(s)
 
            rm.hidden = true;
 

	
 
            return rm;
 
        end);
 

	
 
        kh_vroom("Выбраться из укрытия", function(s)
 
            rm.hidden = false;
 

	
 
            return rm;
 
        end);
 
    };
 

	
 
    rm = room(tab);
 

	
 
    return rm;
 
end;
 
\ No newline at end of file
warehouse32.lua
Show inline comments
 
@@ -288,90 +288,78 @@ w32_mgr_bookcase = obj {
 
 
warehouse_32_definitions = {
 
	---line E
 
	["01"] = { name="у задней двери", dsc=[[К югу от вас расположена задняя дверь склада. ]], e1 = "11", ex3 = "w32_backdoor"};
 
	["02"] = { name="тупик", dsc=[[Вы в тупике. К югу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e1 = "12", corner = true};
 
	["03"] = { name="тупик", dsc=[[Вы в тупике. К югу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e1 = "13", corner = true};
 
	["04"] = { name="тупик", dsc=[[Вы в тупике. К югу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e1 = "14", corner = true};
 
	["01"] = { name="Склад 32, у задней двери", dsc=[[К югу от вас расположена задняя дверь склада. ]], e1 = "11", ex3 = "w32_backdoor"};
 
	["02"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К югу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e1 = "12", corner = true};
 
	["03"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К югу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e1 = "13", corner = true};
 
	["04"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К югу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e1 = "14", corner = true};
 
	---line DE
 
	["10"] = { name="тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "11", corner = true};
 
	["11"] = { name="секция D1", dsc=[[
 
	["10"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "11", corner = true};
 
	["11"] = { name="Склад 32, секция D1", dsc=[[
 
		
 
	]], e1 = "21", e2="12", e3="01", e4="10", sector = "D1"};
 
	["12"] = { name="секция D2", dsc=[[
 
	["12"] = { name="Склад 32, секция D2", dsc=[[
 
		
 
	]], e1 = "22", e2="13", e3="02", e4="11", sector = "D2"};
 
	["13"] = { name="секция D3", dsc=[[
 
	["13"] = { name="Склад 32, секция D3", dsc=[[
 
		
 
	]], e1 = "23", e2="14", e3="03", e4="12", sector = "D3"};
 
	["14"] = { name="секция D4", dsc=[[
 
	["14"] = { name="Склад 32, секция D4", dsc=[[
 
		
 
	]], e1 = "24", e2="15", e3="04", e4="13", sector = "D4"};
 
	["15"] = { name="тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "14", corner = true};
 
	["15"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "14", corner = true};
 
	---line CD
 
	["20"] = { name="тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "21", corner = true};
 
	["21"] = { name="секция C1", dsc=[[
 
	["20"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "21", corner = true};
 
	["21"] = { name="Склад 32, секция C1", dsc=[[
 
		
 
	]], e1 = "31", e2="22", e3="11", e4="20", sector = "C1"};
 
	["22"] = { name="секция C2", dsc=[[
 
	["22"] = { name="Склад 32, секция C2", dsc=[[
 
		
 
	]], e1 = "32", e2="23", e3="12", e4="21", sector = "C2"};
 
	["23"] = { name="секция C3", dsc=[[
 
	["23"] = { name="Склад 32, секция C3", dsc=[[
 
		
 
	]], e1 = "33", e2="24", e3="13", e4="22", sector = "C3"};
 
	["24"] = { name="секция C4", dsc=[[
 
	["24"] = { name="Склад 32, секция C4", dsc=[[
 
		
 
	]], e1 = "34", e2="25", e3="14", e4="23", sector = "C4"};
 
	["25"] = { name="тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "24", corner = true};
 
	["25"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "24", corner = true};
 
	---line BC
 
	["30"] = { name="тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "31", corner = true};
 
	["31"] = { name="секция B1", dsc=[[
 
	["30"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "31", corner = true};
 
	["31"] = { name="Склад 32, секция B1", dsc=[[
 
		
 
	]], e1 = "41", e2="32", e3="21", e4="30", sector = "B1"};
 
	["32"] = { name="секция B2", dsc=[[
 
	["32"] = { name="Склад 32, секция B2", dsc=[[
 
		
 
	]], e1 = "42", e2="33", e3="22", e4="31", sector = "B2"};
 
	["33"] = { name="секция B3", dsc=[[
 
	["33"] = { name="Склад 32, Склад 32, секция B3", dsc=[[
 
		
 
	]], e1 = "43", e2="34", e3="23", e4="32", sector = "B3"};
 
	["34"] = { name="секция B4", dsc=[[
 
	["34"] = { name="Склад 32, секция B4", dsc=[[
 
		
 
	]], e1 = "44", e2="35", e3="24", e4="33", sector = "B4"};
 
	["35"] = { name="тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "34", corner = true};
 
	["35"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "34", corner = true};
 
	---line AB
 
	["40"] = { name="тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "41", corner = true};
 
	["41"] = { name="секция A1", dsc=[[
 
	["40"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К западу от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e2 = "41", corner = true};
 
	["41"] = { name="Склад 32, секция A1", dsc=[[
 
		
 
	]], e1 = "51", e2="42", e3="31", e4="40", sector = "A1"};
 
	["42"] = { name="секция A2", dsc=[[
 
	["42"] = { name="Склад 32, секция A2", dsc=[[
 
		
 
	]], e1 = "52", e2="43", e3="32", e4="41", sector = "A2"};
 
	["43"] = { name="секция A3", dsc=[[
 
	["43"] = { name="Склад 32, секция A3", dsc=[[
 
		
 
	]], e1 = "53", e2="44", e3="33", e4="42", sector = "A3"};
 
	["44"] = { name="секция A4", dsc=[[
 
	["44"] = { name="Склад 32, секция A4", dsc=[[
 
		
 
	]], e1 = "54", e2="45", e3="34", e4="43", sector = "A4"};
 
	["45"] = { name="тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "34", corner = true};
 
	["45"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К востоку от вас находится стена, на севере и юге -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e4 = "34", corner = true};
 
	---line A
 
	["51"] = { name="тупик", dsc=[[Вы в тупике. К северу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e3 = "41", corner = true};
 
	["52"] = { name="у входа", dsc=[[К северу от вас расположен главный вход склада, но он заперт. ]], e3 = "42"};
 
	["53"] = { name="тупик", dsc=[[Вы в тупике. К северу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e3 = "43", corner = true};
 
	["54"] = { name="у входа в кабинет управляющего", dsc=[[К северу от вас расположена дверь, ведущая в кабинет управляющего. ]], e3 = "44", ex1="w32_mgr"};
 
	["51"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К северу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e3 = "41", corner = true};
 
	["52"] = { name="Склад 32, у входа", dsc=[[К северу от вас расположен главный вход склада, но он заперт. ]], e3 = "42"};
 
	["53"] = { name="Склад 32, тупик", dsc=[[Вы в тупике. К северу от вас находится стена, на востоке и западе -- стеллажи. Здесь составлено несколько больших ящиков, за которыми можно спрятаться. ]], e3 = "43", corner = true};
 
	["54"] = { name="Склад 32, у входа в кабинет управляющего", dsc=[[К северу от вас расположена дверь, ведущая в кабинет управляющего. ]], e3 = "44", ex1="w32_mgr"};
 
};
 
 
function getDirName(dir)
 
	if (dir == 1) then
 
		return "север";
 
	elseif (dir == 2) then
 
		return "восток";
 
	elseif (dir == 3) then
 
		return "юг";
 
	elseif (dir == 4) then
 
		return "запад";
 
	end;
 
end;
 
 
warehouse_32 = room {
 
warehouse_32 = stealthroom {
 
    var{
 
        pos = "01";
 
        hidden = false;
 
@@ -383,8 +371,7 @@ warehouse_32 = room {
 
        };
 
    };
 
	nam = "warehouse_32";
 
	nolamp = true;
 
    map = {
 
	map = {
 
        {1,1,2,1,1,1,1,1,1,1,1};
 
        {1,3,0,3,0,3,0,3,0,3,1};
 
        {1,0,0,0,0,0,0,0,0,0,1};
 
@@ -397,136 +384,24 @@ warehouse_32 = room {
 
        {1,3,0,3,0,3,0,3,0,3,1};
 
        {1,1,1,1,2,1,1,1,2,1,1};
 
    };
 
    pic = function(s)
 
        local pl_y = math.floor(tonumber(s.pos) / 10);
 
        local pl_x = tonumber(s.pos) % 10;
 
        local pl_xm = pl_x * 2 + 1;
 
        local deltax = 0;
 
        local deltay = 0;
 
        if pl_x == 0 then
 
            pl_xm = 2;
 
            deltax = -32;
 
        elseif pl_x == 5 then
 
            pl_xm = 10;
 
            deltax = 32;
 
        end;
 
        local pl_ym = pl_y * 2 + 1;
 
        if pl_y == 0 then
 
            pl_ym = 2;
 
            deltay = 32;
 
        elseif pl_y == 5 then
 
            pl_ym = 10;
 
            deltay = -32;
 
        end;
 
        local rval = "images/wh32_bg.png";
 
        
 
        
 
        for x = 0, 8 do
 
            for y = 0, 8 do
 
                print(pl_ym - 4 + y, pl_xm - 4 + x)
 
                if pl_xm - 4 + x > 0 and pl_ym - 4 + y > 0 and pl_xm - 4 + x < 12 and pl_ym - 4 + y < 12 then
 
                    if s.map[pl_ym - 4 + y][pl_xm - 4 + x] == 1 then
 
                        rval = rval .. ";images/wh32_wall.png@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                    elseif s.map[pl_ym - 4 + y][pl_xm - 4 + x] == 2 then
 
                        rval = rval .. ";images/wh32_door.png@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                    elseif s.map[pl_ym - 4 + y][pl_xm - 4 + x] == 3 then
 
                        rval = rval .. ";images/wh32_shelves.png@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                    end;
 
                else
 
                    rval = rval .. ";box:32x32,black,255@" .. tostring((x) * 32) .. "," .. tostring(256 - (y) * 32);
 
                end;
 
            end;
 
        end;
 
        
 
        
 
        for i = 1, #s.guards do
 
            local g_y = math.floor(tonumber(s.guards[i].pos) / 10);
 
            local g_x = tonumber(s.guards[i].pos) % 10;
 
            if pl_y - g_y == 0 or pl_x - g_x == 0 and math.abs(pl_y - g_y) + math.abs(pl_x - g_x) < 3 then
 
                rval = rval .. ";images/wh32_guard_" .. tostring(s.guards[i].dir) .. ".png@" .. tostring((g_x - pl_x) * 64 + 128 + deltax) .. ",".. tostring((pl_y - g_y) * 64 + 128 + deltay);
 
            end;
 
            if math.abs(pl_y - g_y) == 1 and math.abs(pl_x - g_x) == 1 then
 
                rval = rval .. ";images/unseen_enemy.png@" .. tostring((g_x - pl_x) * 64 + 128 + deltax) .. ",".. tostring((pl_y - g_y) * 64 + 128 + deltay);
 
            end;
 
        end;
 
        
 
        rval = rval .. ";images/wh32_player.png@128,128";
 
        print(rval);
 
        return rval .. ";images/wh32_mask.png";
 
    end;
 
	disp = function(s)
 
		return "Склад 32, " .. s.definitions[s.pos].name;
 
	end;
 
    wall = 'wh32_wall';
 
	door = 'wh32_door';
 
	background = 'wh32_bg';
 
	obstacle = 'wh32_shelves';
 
	guard = 'wh32_guard_';
 
	player = 'wh32_player';
 
	game_over = 'game_over_caught';
 
 
	dsc = function(s)
 
		--return s.definitions[s.pos].dsc .. "^ Вы смотрите на " .. getDirName(s.dir);
 
		
 
		return 'Вы стоите где-то между стеллажами склада 32. В помещении темно, за исключением фонарей охранников. ' .. s.definitions[s.pos].dsc;
 
	end;
 
	definitions = warehouse_32_definitions;
 
	checkGuardSight = function(s)
 
		--Проверить область зрения каждого стражника, если игрок находится в области зрения - FAIL
 
		for i = 1, #s.guards do
 
			if (s.guards[i].pos == s.pos) then
 
				--detected
 
				walk("game_over_caught");
 
				return false;
 
			end;
 
			if (s.guards[i].dir == 1) then
 
				if (not s.hidden and s.definitions[s.guards[i].pos].e1 and s.pos == s.definitions[s.guards[i].pos].e1) then
 
					--detected
 
					walk("game_over_caught");
 
					return false;
 
				end;
 
			elseif (s.guards[i].dir == 2) then
 
				if (not s.hidden and s.definitions[s.guards[i].pos].e2 and s.pos == s.definitions[s.guards[i].pos].e2) then
 
					--detected
 
					walk("game_over_caught");
 
					return false;
 
				end;
 
			elseif (s.guards[i].dir == 3) then
 
				if (not s.hidden and s.definitions[s.guards[i].pos].e3 and s.pos == s.definitions[s.guards[i].pos].e3) then
 
					--detected
 
					walk("game_over_caught");
 
					return false;
 
				end;
 
			elseif (s.guards[i].dir == 4) then
 
				if (not s.hidden and s.definitions[s.guards[i].pos].e4 and s.pos == s.definitions[s.guards[i].pos].e4) then
 
					--detected
 
					walk("game_over_caught");
 
					return false;
 
				end;
 
			end;
 
		end;
 
		return true;
 
	end;
 
	guardTurn = function(s)
 
		local pl_y = math.floor(tonumber(s.pos) / 10);
 
		local pl_x = tonumber(s.pos) % 10;
 
		--Каждый стражник делает ход, игрок получает сообщения, о том, слышит ли он шаги, откуда и как они движутся
 
		for i = 1, #s.guards do
 
			if (rnd(10) < 9) then
 
                --[[if (s.guards[i].s == 1) then
 
                    if s.guards[i].dir ~= 3 then
 
                        s.guards[i].dir = s.guards[i].dir + 1;
 
                    else
 
                        s.guards[i].pos = s.definitions[s.guards[i].pos].e3;
 
                        if not s.definitions[s.definitions[s.guards[i].pos].e3].e3 then
 
                            s.guards[i].s = 2;
 
                        end;
 
                    end;
 
                else
 
                    if s.guards[i].dir ~= 1 then
 
                        s.guards[i].dir = s.guards[i].dir + 1;
 
                        if (s.guards[i].dir > 4) then
 
                            s.guards[i].dir = 1;
 
                        end;
 
                    else
 
                        s.guards[i].pos = s.definitions[s.guards[i].pos].e1;
 
                        if not s.definitions[s.definitions[s.guards[i].pos].e1].e1 then
 
                            s.guards[i].s = 1;
 
                        end;
 
                    end;
 
                end;]]
 
				if (s.guards[i].s == 1) then
 
					s.guards[i].s = 2;
 
					s.guards[i].dir = s.guards[i].dir + 1;
 
@@ -557,9 +432,6 @@ warehouse_32 = room {
 
			
 
			local g_y = math.floor(tonumber(s.guards[i].pos) / 10);
 
			local g_x = tonumber(s.guards[i].pos) % 10;
 
			--print("guard:", g_x, g_y)
 
			--Видимость при разнице не более двух. В прямой видимости - видно, иначе - слышно
 
			--TODO может стоит сделать, чтобы шаги были слышны только при движении стражнека?
 
			if (g_x == pl_x) then
 
				--North-south line
 
				if (g_y - pl_y == 2) then
 
@@ -596,120 +468,16 @@ warehouse_32 = room {
 
		end;
 
	end;
 
	makeTurn = function(s)
 
		-- TODO debug
 
		if (s:checkGuardSight()) then
 
			s:guardTurn();
 
			if (s:checkGuardSight()) then				
 
				if (warehouse_32_definitions[warehouse_32.pos].e1 or warehouse_32_definitions[warehouse_32.pos].ex1) then
 
					path("На север"):enable();
 
				else
 
					path("На север"):disable();
 
				end;
 
				
 
				if (warehouse_32_definitions[warehouse_32.pos].e2 or warehouse_32_definitions[warehouse_32.pos].ex2) then
 
					path("На восток"):enable();
 
				else
 
					path("На восток"):disable();
 
				end;
 
			
 
				if (warehouse_32_definitions[warehouse_32.pos].e3 or warehouse_32_definitions[warehouse_32.pos].ex3) then
 
					path("На юг"):enable();
 
				else
 
					path("На юг"):disable();
 
				end;
 
			
 
				if (warehouse_32_definitions[warehouse_32.pos].e4 or warehouse_32_definitions[warehouse_32.pos].ex4) then
 
					path("На запад"):enable();
 
				else
 
					path("На запад"):disable();
 
				end;
 
				
 
				if (warehouse_32_definitions[warehouse_32.pos].corner) then
 
					path("Спрятаться"):enable();
 
				else
 
					path("Спрятаться"):disable();
 
				end;
 
				
 
				if (warehouse_32.hidden) then
 
					path("Спрятаться"):disable();
 
					path("Выбраться из укрытия"):enable();
 
					path("На запад"):disable();
 
					path("На восток"):disable();
 
					path("На север"):disable();
 
					path("На юг"):disable();
 
				else
 
					path("Выбраться из укрытия"):disable();
 
				end;
 
				
 
				if (warehouse_32_definitions[warehouse_32.pos].sector) then
 
					warehouse_32_shelves.current = warehouse_32_definitions[warehouse_32.pos].sector;
 
					warehouse_32_shelves:enable();
 
				else
 
					warehouse_32_shelves:disable();
 
				end;
 
			end;
 
		if (s.definitions[s.pos].sector) then
 
			warehouse_32_shelves.current = s.definitions[s.pos].sector;
 
			warehouse_32_shelves:enable();
 
		else
 
			warehouse_32_shelves:disable();
 
		end;
 
	end;
 
	enter = function(s)
 
		s:makeTurn();
 
	end;
 
	way = {
 
		kh_vroom("На север", function(s)
 
			if (warehouse_32_definitions[warehouse_32.pos].ex1) then
 
				return warehouse_32_definitions[warehouse_32.pos].ex1;
 
			else
 
				warehouse_32.pos = warehouse_32_definitions[warehouse_32.pos].e1;
 
			end;
 
			
 
			return "warehouse_32";
 
		end);
 
		
 
		kh_vroom("На юг", function(s)
 
			if (warehouse_32_definitions[warehouse_32.pos].ex3) then
 
				return warehouse_32_definitions[warehouse_32.pos].ex3;
 
			else
 
				warehouse_32.pos = warehouse_32_definitions[warehouse_32.pos].e3;
 
			end;
 
			
 
			return "warehouse_32";
 
		end);
 
		
 
		kh_vroom("На запад", function(s)
 
			if (warehouse_32_definitions[warehouse_32.pos].ex4) then
 
				return warehouse_32_definitions[warehouse_32.pos].ex4;
 
			else
 
				warehouse_32.pos = warehouse_32_definitions[warehouse_32.pos].e4;
 
			end;
 
			
 
			return "warehouse_32";
 
		end);
 
		
 
		kh_vroom("На восток", function(s)
 
			if (warehouse_32_definitions[warehouse_32.pos].ex2) then
 
				return warehouse_32_definitions[warehouse_32.pos].ex2;
 
			else
 
				warehouse_32.pos = warehouse_32_definitions[warehouse_32.pos].e2;
 
			end;
 
			
 
			return "warehouse_32";
 
		end);
 
		
 
		kh_vroom("Ждать", function(s)
 
			return "warehouse_32";
 
		end);
 
		
 
		kh_vroom("Спрятаться", function(s)
 
			warehouse_32.hidden = true;
 
			
 
			return "warehouse_32";
 
		end);
 
		
 
		kh_vroom("Выбраться из укрытия", function(s)
 
			warehouse_32.hidden = false;
 
			
 
			return "warehouse_32";
 
		end);
 
	};
 
	obj = {
 
		'warehouse_32_shelves'
 
	};
0 comments (0 inline, 0 general)