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:
Linus Probert 2018-08-21 12:56:02 +02:00
parent 9ef97c0897
commit c390c024f6
1 changed files with 19 additions and 3 deletions

View File

@ -35,11 +35,27 @@ function module.add_traps_to_room(room)
while i < count do
local rx = random(13) + 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
room.traps[rx][ry] = traps[random(#traps)]
i = i + 1
end
end
end
end
function module.load_traps(map, traps)