Index: game/engines/default/engine/init.lua =================================================================== --- game/engines/default/engine/init.lua (revision 2963) +++ game/engines/default/engine/init.lua (working copy) @@ -57,6 +57,7 @@ mouse_cursor = true display_fps = 30 gamma_correction = 120 +mouse_move = true ]] for i, file in ipairs(fs.list("/settings/")) do if file:find(".cfg$") then Index: game/engines/default/engine/interface/PlayerMouse.lua =================================================================== --- game/engines/default/engine/interface/PlayerMouse.lua (revision 2963) +++ game/engines/default/engine/interface/PlayerMouse.lua (working copy) @@ -20,6 +20,7 @@ require "engine.class" local Astar = require"engine.Astar" local DirectPath = require"engine.DirectPath" +local Map = require "engine.Map" --- Handles player default mouse actions -- Defines some methods to help use the mouse in an uniform way in all modules @@ -33,7 +34,7 @@ -- @param tmy the coords clicked -- @param spotHostiles a function taking only the player as a parameter that must return true if hostiles are in sight -- @param astar_check nil or a function to check each tile on the astar path for passability -function _M:mouseMove(tmx, tmy, spotHostiles, astar_check) +function _M:mouseMove(tmx, tmy, spotHostiles, astar_check, force_move) tmx = util.bound(tmx, 0, game.level.map.w - 1) tmy = util.bound(tmy, 0, game.level.map.h - 1) @@ -45,31 +46,37 @@ if self.x == tmx and self.y == tmy then self:useEnergy() return end -- If hostiles, attack! - if (spotHostiles and spotHostiles(self)) or math.floor(core.fov.distance(self.x, self.y, tmx, tmy)) == 1 then + -- Expand logic for clarity + local test_actor = game.level.map(tmx, tmy, Map.ACTOR) + local test_hostile = spotHostiles and spotHostiles(self) + local test_adjacent = math.floor(core.fov.distance(self.x, self.y, tmx, tmy)) == 1 + if ((config.settings.mouse_move or force_move) and (test_hostile or test_adjacent)) or (not config.settings.mouse_move and test_adjacent and test_actor) then local l = line.new(self.x, self.y, tmx, tmy) local nx, ny = l() self:move(nx or self.x, ny or self.y) return end - local a = Astar.new(game.level.map, self) - local path = a:calc(self.x, self.y, tmx, tmy, true, nil, astar_check) - -- No Astar path ? just be dumb and try direct line - if not path then - local d = DirectPath.new(game.level.map, self) - path = d:calc(self.x, self.y, tmx, tmy, true) + if config.settings.mouse_move or force_move then + local a = Astar.new(game.level.map, self) + local path = a:calc(self.x, self.y, tmx, tmy, true, nil, astar_check) + -- No Astar path ? just be dumb and try direct line + if not path then + local d = DirectPath.new(game.level.map, self) + path = d:calc(self.x, self.y, tmx, tmy, true) + end + + if path then + -- Should we just try to move in the direction, aka: attack! + if path[1] and game.level.map:checkAllEntities(path[1].x, path[1].y, "block_move", self) then self:move(path[1].x, path[1].y) return end + + -- Insert the player coords, running needs to find the player + table.insert(path, 1, {x=self.x, y=self.y}) + + -- Move along the projected A* path + self:runFollow(path) + end end - - if path then - -- Should we just try to move in the direction, aka: attack! - if path[1] and game.level.map:checkAllEntities(path[1].x, path[1].y, "block_move", self) then self:move(path[1].x, path[1].y) return end - - -- Insert the player coords, running needs to find the player - table.insert(path, 1, {x=self.x, y=self.y}) - - -- Move along the projected A* path - self:runFollow(path) - end end end Index: game/modules/tome/dialogs/MapMenu.lua =================================================================== --- game/modules/tome/dialogs/MapMenu.lua (revision 2963) +++ game/modules/tome/dialogs/MapMenu.lua (working copy) @@ -65,7 +65,7 @@ local act = item.action - if act == "move_to" then game.player:mouseMove(self.tmx, self.tmy) + if act == "move_to" then game.player:mouseMove(self.tmx, self.tmy, true) elseif act == "control" then game.party:setPlayer(item.actor) elseif act == "order" then game.party:giveOrders(item.actor) elseif act == "change_level" then game.key:triggerVirtual("CHANGE_LEVEL") Index: game/modules/tome/dialogs/GameOptions.lua =================================================================== --- game/modules/tome/dialogs/GameOptions.lua (revision 2963) +++ game/modules/tome/dialogs/GameOptions.lua (working copy) @@ -110,7 +110,7 @@ self.c_list:drawItem(item) end,} - local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Enables of disables day/night light variations effects..#WHITE#"} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Enables or disables day/night light variations effects..#WHITE#"} list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Day/night light cycle#WHITE##{normal}#", status=function(item) return tostring(config.settings.tome.daynight and "enabled" or "disabled") end, fct=function(item) @@ -128,15 +128,6 @@ self.c_list:drawItem(item) end,} - local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Enables smooth fog-of-war.\nDisabling it will make the fog of war look 'blocky' but might gain a slight performance increase.#WHITE#"} - list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Smooth fog of war#WHITE##{normal}#", status=function(item) - return tostring(config.settings.tome.smooth_fov and "enabled" or "disabled") - end, fct=function(item) - config.settings.tome.smooth_fov = not config.settings.tome.smooth_fov - game:saveSettings("tome.smooth_fov", ("tome.smooth_fov = %s\n"):format(tostring(config.settings.tome.smooth_fov))) - self.c_list:drawItem(item) - end,} - local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"If enabled the chats between players will also appear in the game log, in addition to the normal chat log.#WHITE#"} list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Community chat appears in the game log#WHITE##{normal}#", status=function(item) return tostring(config.settings.tome.chat_log and "enabled" or "disabled") @@ -182,5 +173,14 @@ end) end,} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Enables easy movement using the mouse by left-clicking on the map.#WHITE#"} + list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Use mouse to move#WHITE##{normal}#", status=function(item) + return tostring(config.settings.mouse_move and "enabled" or "disabled") + end, fct=function(item) + config.settings.mouse_move = not config.settings.mouse_move + game:saveSettings("mouse_move", ("mouse_move = %s\n"):format(tostring(config.settings.mouse_move))) + self.c_list:drawItem(item) + end,} + self.list = list end Index: game/modules/tome/class/Player.lua =================================================================== --- game/modules/tome/class/Player.lua (revision 2963) +++ game/modules/tome/class/Player.lua (working copy) @@ -556,14 +556,14 @@ --- Move with the mouse -- We just feed our spotHostile to the interface mouseMove -function _M:mouseMove(tmx, tmy) +function _M:mouseMove(tmx, tmy, force_move) local astar_check = function(x, y) -- Dont do traps local trap = game.level.map(x, y, Map.TRAP) if trap and trap:knownBy(self) and trap:canTrigger(x, y, self, true) then return false end return true end - return engine.interface.PlayerMouse.mouseMove(self, tmx, tmy, spotHostiles, astar_check) + return engine.interface.PlayerMouse.mouseMove(self, tmx, tmy, spotHostiles, astar_check, force_move) end --- Called after running a step