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

never move monsters, never moves !

git-svn-id: http://svn.net-core.org/repos/t-engine4@197 51575b47-30f0-44d4-a5cc-537603b46e54
parent e12640e5
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@ end
function _M:move(x, y, force)
if self.dead then return true end
local map = game.level.map
if not force and map:checkAllEntities(x, y, "block_move", self) then return true end
if not force and map:checkAllEntities(x, y, "block_move", self, true) then return true end
if self.x and self.y then
map:remove(self.x, self.y, Map.ACTOR)
......@@ -69,7 +69,7 @@ function _M:canMove(x, y, terrain_only)
if terrain_only then
return not game.level.map:checkEntity(x, y, Map.TERRAIN, "block_move")
else
return not game.level.map:checkAllEntities(x, y, "block_move", self, true)
return not game.level.map:checkAllEntities(x, y, "block_move", self)
end
end
......
......@@ -15,9 +15,9 @@ end
--- Checks if something bumps in us
-- If it happens the method attack is called on the target with the attacker as parameter.
-- Do not touch!
function _M:block_move(x, y, e, only_check)
function _M:block_move(x, y, e, can_attack)
-- Dont bump yourself!
if e and e ~= self and not only_check then
if e and e ~= self and can_attack then
e:attack(self)
end
return true
......
......@@ -96,6 +96,10 @@ function _M:move(x, y, force)
-- Should we prob travel through walls ?
if not force and self:attr("prob_travel") and game.level.map:checkEntity(x, y, Map.TERRAIN, "block_move", self) then
moved = self:probabilityTravel(x, y)
-- Never move but tries to attack ? ok
elseif self:attr("never_move") then
-- A bit weird, but this simple asks the collision code to detect an attack
game.level.map:checkAllEntities(x, y, "block_move", self, true)
else
moved = engine.Actor.move(self, x, y, force)
end
......
......@@ -11,7 +11,7 @@ newEntity{
stats = { str=10, dex=15, mag=3, con=3 },
energy = { mod=0.5 },
combat_armor = 1, combat_def = 1,
never_move = true,
never_move = 1,
}
newEntity{ base = "BASE_NPC_MOLD",
......
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