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

do not slide around monsters

git-svn-id: http://svn.net-core.org/repos/t-engine4@426 51575b47-30f0-44d4-a5cc-537603b46e54
parent a9d7b65d
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ function _M:updateFOV(a, sqdist)
fov.actors_dist[#fov.actors_dist+1] = a
end
fov.actors[a] = t
table.sort(fov.actors_dist, function(a, b) return fov.actors[a].sqdist < fov.actors[b].sqdist end)
-- print("Updated FOV for", self.uid, self.name, ":: seen ", #fov.actors_dist, "actors closeby; from", a, sqdist)
table.sort(fov.actors_dist, function(a, b) if a and b then return fov.actors[a].sqdist < fov.actors[b].sqdist elseif a then return 1 else return nil end end)
self.fov_last_change = game.turn
end
......@@ -10,7 +10,7 @@ function _M:bloodyDeath()
local color = {255,0,100}
local done = 3
if type(self.has_blood) == "table" then
done = self.has_blood.nb
done = self.has_blood.nb or 3
color = self.has_blood.color
end
for i = 1, done do
......
require "engine.class"
local Map = require "engine.Map"
--- Makes the player "slide" along walls when possible
-- Simply call x, y = self:tryPlayerSlide(x, y, force) in your player's move() method
......@@ -6,16 +7,16 @@ module(..., package.seeall, class.make)
function _M:tryPlayerSlide(x, y, force)
-- Try to slide along walls if possible
if game.level.map:checkAllEntities(x, y, "block_move", self, false) and not force then
if game.level.map:checkEntity(x, y, Map.TERRAIN, "block_move", self, false) and not force then
local dir = util.getDir(x, y, self.x, self.y)
local ldir, rdir = dir_sides[dir].left, dir_sides[dir].right
local lx, ly = util.coordAddDir(self.x, self.y, ldir)
local rx, ry = util.coordAddDir(self.x, self.y, rdir)
-- Slide left
if not game.level.map:checkAllEntities(lx, ly, "block_move", self, false) and game.level.map:checkAllEntities(rx, ry, "block_move", self, false) then
if not game.level.map:checkEntity(lx, ly, Map.TERRAIN, "block_move", self, false) and game.level.map:checkEntity(rx, ry, Map.TERRAIN, "block_move", self, false) then
x, y = lx, ly
-- Slide right
elseif game.level.map:checkAllEntities(lx, ly, "block_move", self, false) and not game.level.map:checkAllEntities(rx, ry, "block_move", self, false) then
elseif game.level.map:checkEntity(lx, ly, Map.TERRAIN, "block_move", self, false) and not game.level.map:checkEntity(rx, ry, Map.TERRAIN, "block_move", self, false) then
x, y = rx, ry
end
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