From 24b6d984e012e41156214fa8a1229fa2c6c5144a Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Sat, 19 Oct 2019 14:49:29 +0200 Subject: [PATCH] Fixed a bug in AI displace code --- game/modules/tome/class/Game.lua | 14 ++++++++------ game/modules/tome/class/interface/ActorAI.lua | 6 +++--- game/modules/tome/data/zones/test/zone.lua | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index df5f1a70da..181858c703 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -2008,6 +2008,14 @@ function _M:setupCommands() print("===============") end end, [{"_g","ctrl"}] = function() if config.settings.cheat then + self:changeLevel(1, "tareyal+bamboo-forest") +do return end + if self.zone.short_name ~= "test" then + self:changeLevel(1, "test") + else + self:changeLevel(game.level.level + 1) + end +do return end local f, err = loadfile("/data/general/events/weird-pedestals.lua") print(f, err) setfenv(f, setmetatable({level=self.level, zone=self.zone}, {__index=_G})) @@ -2015,12 +2023,6 @@ function _M:setupCommands() do return end package.loaded["mod.dialogs.Donation"] = nil self:registerDialog(require("mod.dialogs.Donation").new()) -do return end - if self.zone.short_name ~= "test" then - self:changeLevel(1, "test") - else - self:changeLevel(game.level.level + 1) - end do return end local m = game.zone:makeEntity(game.level, "actor", {name="elven mage"}, nil, true) local x, y = util.findFreeGrid(game.player.x, game.player.y, 20, true, {[Map.ACTOR]=true}) diff --git a/game/modules/tome/class/interface/ActorAI.lua b/game/modules/tome/class/interface/ActorAI.lua index 784962e41c..ade1b2ec66 100644 --- a/game/modules/tome/class/interface/ActorAI.lua +++ b/game/modules/tome/class/interface/ActorAI.lua @@ -313,7 +313,7 @@ _M.aiSubstDamtypes = { -- Still count grids we can potentially shove or swap our way into function _M:aiPathingBlockCheck(x, y, actor_checking) - return not self:block_move(x, y, actor_checking) or not actor_checking:canBumpDisplace(self) + return not self:block_move(x, y, actor_checking) or not actor_checking.canBumpDisplace or not actor_checking:canBumpDisplace(self) end -- Can an NPC shove or swap positions with a space occupied by another NPC? @@ -346,7 +346,7 @@ function _M:moveDirection(x, y, force) -- Find all possible directions to move, including towards friendly targets local target = game.level.map(lx, ly, engine.Map.ACTOR) - if target and self:reactionToward(target) > 0 and self:canBumpDisplace(target) then l[#l+1] = {lx,ly, core.fov.distance(x,y,lx,ly)/2+rng.float(0, .1), target} end -- Add straight ahead if shoveable + if target and self:reactionToward(target) > 0 and self.canBumpDisplace and self:canBumpDisplace(target) then l[#l+1] = {lx,ly, core.fov.distance(x,y,lx,ly)/2+rng.float(0, .1), target} end -- Add straight ahead if shoveable local dir = util.getDir(lx, ly, self.x, self.y) local sides = util.dirSides(dir, self.x, self.y) for _, dir in pairs(sides) do -- sides @@ -356,7 +356,7 @@ function _M:moveDirection(x, y, force) l[#l+1] = {dx,dy, core.fov.distance(x,y,dx,dy)} else target = game.level.map(dx, dy, engine.Map.ACTOR) - if target and self:reactionToward(target) > 0 and self:canBumpDisplace(target) then + if target and self:reactionToward(target) > 0 and self.canBumpDisplace and self:canBumpDisplace(target) then l[#l+1] = {dx,dy, core.fov.distance(x,y,dx,dy)/2+rng.float(0, .1), target} end end diff --git a/game/modules/tome/data/zones/test/zone.lua b/game/modules/tome/data/zones/test/zone.lua index 974c23bc07..aef02aa678 100644 --- a/game/modules/tome/data/zones/test/zone.lua +++ b/game/modules/tome/data/zones/test/zone.lua @@ -43,8 +43,8 @@ return { [';'] = "GRASS", ['T'] = "TREE", ['='] = "DEEP_WATER", -- mapscript = "!cavernous_forest", - mapscript = "!testroom2", - -- mapscript = "!inner_outer", + -- mapscript = "!testroom2", + mapscript = "!inner_outer", --]] --[[ class = "engine.generator.map.Hexacle", -- GitLab