Fixes #40, Prevent adjecant traps before lvl 4
Made the simplest solution possible here. An A* start algo to check that we didn't block paths seemed overkill.
This commit is contained in:
parent
9ef97c0897
commit
c390c024f6
|
@ -35,11 +35,27 @@ function module.add_traps_to_room(room)
|
||||||
while i < count do
|
while i < count do
|
||||||
local rx = random(13) + 1
|
local rx = random(13) + 1
|
||||||
local ry = random(9) + 1
|
local ry = random(9) + 1
|
||||||
|
if CURRENT_LEVEL < 4 then
|
||||||
|
if room_builder.is_tile_avilable(room, rx, ry)
|
||||||
|
and not room.traps[rx+1][ry]
|
||||||
|
and not room.traps[rx-1][ry]
|
||||||
|
and not room.traps[rx][ry+1]
|
||||||
|
and not room.traps[rx][ry-1]
|
||||||
|
and not room.traps[rx+1][ry+1]
|
||||||
|
and not room.traps[rx+1][ry-1]
|
||||||
|
and not room.traps[rx-1][ry+1]
|
||||||
|
and not room.traps[rx-1][ry-1]
|
||||||
|
then
|
||||||
|
room.traps[rx][ry] = traps[random(#traps)]
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
if room_builder.is_tile_avilable(room, rx, ry) then
|
if room_builder.is_tile_avilable(room, rx, ry) then
|
||||||
room.traps[rx][ry] = traps[random(#traps)]
|
room.traps[rx][ry] = traps[random(#traps)]
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.load_traps(map, traps)
|
function module.load_traps(map, traps)
|
||||||
|
|
Loading…
Reference in New Issue