Files
@ 81f86c201541
Branch filter:
Location: games/Awakening/stealth.lua
81f86c201541
7.7 KiB
text/x-lua
There is no need to talk with Wright about saboteur after one is found
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | 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
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";
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;
makeTurn(s);
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;
|