Skip to content
Snippets Groups Projects
Commit de310d38 authored by dg's avatar dg
Browse files

Bill can not be cut off from the level

git-svn-id: http://svn.net-core.org/repos/t-engine4@2687 51575b47-30f0-44d4-a5cc-537603b46e54
parent 6b7d1454
No related branches found
No related tags found
No related merge requests found
......@@ -30,10 +30,10 @@ function _M:init(zone, map, level, spots)
self.spot_filters = data.spot_filters or {}
-- Pick a number of spots
self.spots = {}
self.genspots = {}
for i = 1, self.nb_spots or 2 do
local spot = self.level:pickSpot(rng.table(self.spot_filters))
if spot then self.spots[#self.spots+1] = spot end
if spot then self.genspots[#self.genspots+1] = spot end
end
end
......@@ -42,14 +42,14 @@ function _M:getSpawnSpot(m)
if rng.percent(self.on_spot_chance) then
-- Cycle through spots, looking for one with empty spaces
local tries = 0
local spot = rng.table(self.spots)
local spot = rng.table(self.genspots)
if not spot then
print("No spots for spawning")
return
end
local _, _, gs = util.findFreeGrid(spot.x, spot.y, self.spot_radius, "block_move", {[Map.ACTOR]=true})
while not gs and tries < 10 do
spot = rng.table(self.spots)
spot = rng.table(self.genspots)
_, _, gs = util.findFreeGrid(spot.x, spot.y, self.spot_radius, "block_move", {[Map.ACTOR]=true})
tries = tries + 1
end
......
......@@ -30,10 +30,10 @@ function _M:init(zone, map, level, spots)
self.spot_filters = data.spot_filters or {{special=function(spot) return spot.spawned_actors and true or false end}}
-- Pick a number of spots
self.spots = {}
self.genspots = {}
for i = 1, self.nb_spots or 2 do
local spot = self.level:pickSpot(rng.table(self.spot_filters))
if spot then self.spots[#self.spots+1] = spot end
if spot then self.genspots[#self.genspots+1] = spot end
end
end
......@@ -42,14 +42,14 @@ function _M:getSpawnSpot(o)
if rng.percent(self.on_spot_chance) then
-- Cycle through spots, looking for one with empty spaces
local tries = 0
local spot = rng.table(self.spots)
local spot = rng.table(self.genspots)
if not spot then
print("No spots for spawning")
return
end
local _, _, gs = util.findFreeGrid(spot.x, spot.y, self.spot_radius, "block_move", {[Map.OBJECT]=true})
while not gs and tries < 10 do
spot = rng.table(self.spots)
spot = rng.table(self.genspots)
_, _, gs = util.findFreeGrid(spot.x, spot.y, self.spot_radius, "block_move", {[Map.OBJECT]=true})
tries = tries + 1
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment