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

Autoexplore will rest before starting, disable-able by an option

git-svn-id: http://svn.net-core.org/repos/t-engine4@5633 51575b47-30f0-44d4-a5cc-537603b46e54
parent 726d80e7
No related branches found
No related tags found
No related merge requests found
......@@ -24,13 +24,14 @@ local Dialog = require "engine.ui.Dialog"
module(..., package.seeall, class.make)
--- Initializes resting
function _M:restInit(turns, what, past, on_end)
function _M:restInit(turns, what, past, on_end, on_very_end)
what = what or "resting"
past = past or "rested"
self.resting = {
rest_turns = turns,
past = past,
on_end = on_end,
on_very_end = on_very_end,
cnt = 0,
dialog = Dialog:simplePopup(what:capitalize().."...", "You are "..what..", press Enter to stop.", function()
self:restStop()
......@@ -102,8 +103,12 @@ function _M:restStop(msg)
game.log(self.resting.past:capitalize().." for %d turns.", self.resting.cnt)
end
local finish = self.resting.cnt and self.resting.rest_turns and self.resting.cnt > self.resting.rest_turns
game.log("========== %d %d", self.resting.cnt or -1, self.resting.rest_turns or -1)
local on_very_end = self.resting.on_very_end
if self.resting.on_end then self.resting.on_end(self.resting.cnt, self.resting.rest_turns) end
self:onRestStop()
self.resting = nil
if on_very_end then on_very_end(finish) end
return true
end
......@@ -1017,6 +1017,11 @@ function _M:tick()
-- Check damages to log
self:displayDelayedLogDamage()
if self.tick_loopback then
self.tick_loopback = nil
return self:tick()
end
if savefile_pipe.saving then self.player.changed = true end
if self.paused and not savefile_pipe.saving then return true end
-- if self.on_tick_end and #self.on_tick_end > 0 then return true end
......@@ -1303,7 +1308,7 @@ do return end
end,
RUN_AUTO = function()
if self.level and self.zone then
local ae = function() if self.level and self.zone then
local seen = {}
-- Check for visible monsters. Only see LOS actors, so telepathy wont prevent it
core.fov.calc_circle(self.player.x, self.player.y, self.level.map.w, self.level.map.h, self.player.sight or 10,
......@@ -1323,6 +1328,13 @@ do return end
elseif not self.player:autoExplore() then
self.log("There is nowhere left to explore.")
end
end end
if config.settings.tome.rest_before_explore then
local ok = false
self.player:restInit(nil, nil, nil, function() ok = self.player.resting.rested_fully end, function() if ok then self:onTickEnd(ae) self.tick_loopback = true end end)
else
ae()
end
end,
......
......@@ -730,6 +730,7 @@ function _M:restCheck()
end
self.resting.wait_recall = nil
self.resting.rested_fully = true
return false, "all resources and life at maximum"
end
......
......@@ -273,6 +273,15 @@ function _M:generateList()
game:saveSettings("tome.autoassign_talents_on_birth", ("tome.autoassign_talents_on_birth = %s\n"):format(tostring(config.settings.tome.autoassign_talents_on_birth)))
self.c_list:drawItem(item)
end,}
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Always rest to full before auto-exploring.#WHITE#"}
list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Rest before auto-explore#WHITE##{normal}#", status=function(item)
return tostring(config.settings.tome.rest_before_explore and "enabled" or "disabled")
end, fct=function(item)
config.settings.tome.rest_before_explore = not config.settings.tome.rest_before_explore
game:saveSettings("tome.rest_before_explore", ("tome.rest_before_explore = %s\n"):format(tostring(config.settings.tome.rest_before_explore)))
self.c_list:drawItem(item)
end,}
--[[
local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Your movement mode depends on which character/creature you're currently controlling.#WHITE#"}
list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Actor-based movement mode#WHITE##{normal}#", status=function(item)
......
......@@ -78,6 +78,7 @@ function _M:use(item)
elseif act == "levelup" then game.key:triggerVirtual("LEVELUP")
elseif act == "inventory" then game.key:triggerVirtual("SHOW_INVENTORY")
elseif act == "rest" then game.key:triggerVirtual("REST")
elseif act == "autoexplore" then game.key:triggerVirtual("RUN_AUTO")
elseif act == "chat-link" then profile.chat.uc_ext:sendActorLink(game.level.map(self.tmx, self.tmy, Map.ACTOR))
elseif act == "talent" then
local d = item
......@@ -118,6 +119,7 @@ function _M:generateList()
if a and not self.on_player and game.party:canControl(a, false) then list[#list+1] = {name="Control", action="control", color=colors.simple(colors.TEAL), actor=a} end
if a and not self.on_player and game.party:canOrder(a, false) then list[#list+1] = {name="Give order", action="order", color=colors.simple(colors.TEAL), actor=a} end
if self.on_player then list[#list+1] = {name="Rest a while", action="rest", color=colors.simple(colors.ANTIQUE_WHITE)} end
if self.on_player then list[#list+1] = {name="Auto-explore", action="autoexplore", color=colors.simple(colors.ANTIQUE_WHITE)} end
if self.on_player then list[#list+1] = {name="Inventory", action="inventory", color=colors.simple(colors.ANTIQUE_WHITE)} end
if self.on_player then list[#list+1] = {name="Quest Log", action="quests", color=colors.simple(colors.ANTIQUE_WHITE)} end
if a then list[#list+1] = {name="Inspect Creature", action="character_sheet", color=colors.simple(colors.ANTIQUE_WHITE), actor=a} end
......
......@@ -75,6 +75,7 @@ if type(config.settings.tome.effects_icons) == "nil" then config.settings.tome.e
if type(config.settings.tome.autoassign_talents_on_birth) == "nil" then config.settings.tome.autoassign_talents_on_birth = true end
if type(config.settings.tome.chat_log) == "nil" then config.settings.tome.chat_log = true end
if type(config.settings.tome.actor_based_movement_mode) == "nil" then config.settings.tome.actor_based_movement_mode = true end
if type(config.settings.tome.rest_before_explore) == "nil" then config.settings.tome.rest_before_explore = true end
if not config.settings.tome.fonts then config.settings.tome.fonts = {type="fantasy", size="normal"} end
if not config.settings.tome.ui_theme2 then config.settings.tome.ui_theme2 = "metal" end
if not config.settings.tome.uiset_mode then config.settings.tome.uiset_mode = "Minimalist" 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