diff --git a/warehouse32.lua b/warehouse32.lua --- a/warehouse32.lua +++ b/warehouse32.lua @@ -383,6 +383,72 @@ warehouse_32 = room { }; nam = "warehouse_32"; nolamp = true; + 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}; + {1,3,0,3,0,3,0,3,0,3,1}; + {1,0,0,0,0,0,0,0,0,0,1}; + {1,3,0,3,0,3,0,3,0,3,1}; + {1,0,0,0,0,0,0,0,0,0,1}; + {1,3,0,3,0,3,0,3,0,3,1}; + {1,0,0,0,0,0,0,0,0,0,1}; + {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; + end; + + rval = rval .. ";images/wh32_player.png@128,128"; + return rval .. ";images/wh32_mask.png"; + end; disp = function(s) return "Склад 32, " .. s.definitions[s.pos].name; end; @@ -439,7 +505,7 @@ warehouse_32 = room { 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.guards[i].pos].e3 then + if not s.definitions[s.definitions[s.guards[i].pos].e3].e3 then s.guards[i].s = 2; end; end; @@ -451,7 +517,7 @@ warehouse_32 = room { end; else s.guards[i].pos = s.definitions[s.guards[i].pos].e1; - if not s.definitions[s.guards[i].pos].e1 then + if not s.definitions[s.definitions[s.guards[i].pos].e1].e1 then s.guards[i].s = 1; end; end;