Halfling Rogue cannot rest any more

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
Oddabit
Posts: 1
Joined: Mon Nov 12, 2018 10:51 pm

Halfling Rogue cannot rest any more

#1 Post by Oddabit »

I already did send this through the game but the sticky topic says post it here, too.

Basically what happened is I was going through the old forest as a rogue, and uncovered a trap. I used the Disarm Trap spell, and it was successful. After that, trying to rest (or autoexplore) gave the message "Trap has been disarmed". I quit the game, and upon returning, trying to rest (or autoexplore) tosses out this dump:

[LOG] Resting starts...
Lua Error: /mod/class/Trap.lua:202: attempt to compare nil with number
At [C]:-1 __le
At /mod/class/Trap.lua:202 restCheck
At /engine/interface/PlayerRest.lua:47 restInit
At /mod/class/Game.lua:2142
At /engine/KeyBind.lua:236

One other thing I noticed (I went back to the Old Forest looking for more traps, maybe to reset it? I dunno) was that enemies being in range didn't seem to stop the character from entering stealth mode.

BugReporter
Higher
Posts: 62
Joined: Wed Jun 06, 2018 10:53 am

Re: Halfling Rogue cannot rest any more

#2 Post by BugReporter »

I encountered this issue as well, no error though. That character was also a rogue (I don't remember what race). I tried to disarm a trap in a vault with no luck. Then it disappeared (disarmed?) and that character lost his ability to rest and auto-explore.

SouppuoS
Low Yeek
Posts: 5
Joined: Sat May 30, 2015 3:01 am

Re: Halfling Rogue cannot rest any more

#3 Post by SouppuoS »

Met something similar in 1.6.6 and already reported it in game.
I step on a trap when fighting boss. It ask me if I want to disarm and learn the trap, so I pressed ESC and then cannot REST anymore.
By source code, it seems like restCheck is not set right when use ESC to quit disarm procedure.

And I want to know is there any method I can rest again without using developer mode(because the cheat will be true)?
thanks

ERROR:
Game version: tome-1.6.6
Addons: ashes-urhrok-1.6.0[O], items-vault-1.6.0[O], possessors-1.6.6[O], orcs-1.6.0[O], cults-1.6.0[O]

Game version (character creation): tome-1.6.6
Lua Error: /mod/class/Trap.lua:202: attempt to compare nil with number
At [C]:-1 __le
At /mod/class/Trap.lua:202 restCheck
At /engine/interface/PlayerRest.lua:47 restInit
At /mod/class/Game.lua:2142
At /engine/KeyBind.lua:231
English isn't my native language +1

Dervic
Halfling
Posts: 83
Joined: Thu Jun 21, 2012 9:37 am

Re: Halfling Rogue cannot rest any more

#4 Post by Dervic »

The game does the following:
1 - Copies player.restCheck to oldrestCheck
2 - Replaces player.restCheck with a function to disarm the trap
3 - Copies oldrestCheck to player.restCheck

Step 3 broke somehow, so now your player.restcheck has disarm trap code that shouldn't be there.

From trap.lua

Code: Select all

function _M:onDisarm(x, y, who)
	self:check("disarmed", x, y, who)
	--table.set(game, "debug", "last_trap_disarmed", self) -- debugging
	-- The player may unlock a trap talent when disarming a (similar) trap (uses Trap Mastery)
	if self.unlock_talent_on_disarm and who.player and who:knowTalent(who.T_TRAP_MASTERY) and core.fov.distance(x, y, who.x, who.y) <= 1 and not game.state:unlockTalentCheck(self.unlock_talent_on_disarm.tid, who) then
		local hit, chance = who:checkHit(who:callTalent(who.T_TRAP_MASTERY, "getPower") + who:callTalent(who.T_DEVICE_MASTERY, "trapDisarm")*.25, self.disarm_power)
		local t = who:getTalentFromId(self.unlock_talent_on_disarm.tid)
		if t and hit and chance > 20 and (not self.unlock_talent_on_disarm.chance or rng.percent(self.unlock_talent_on_disarm.chance)) and next(who:spotHostiles()) == nil then
			local diff_level = (t.trap_mastery_level or 5)
			local success, consec, msg = false, 0
			local oldrestCheck = rawget(who, "restCheck") -- hack restCheck to perform action each turn
			who.restCheck = function(player)
				if not player.resting then player.restCheck = oldrestCheck return false, "not resting" end
				if player.resting.cnt >= diff_level then -- start making checks at diff_level turns
					if rng.percent(chance) then
						consec = consec + 1
					else -- reset success count
						consec = 0
						if rng.percent(10) then -- oops! 10% chance to set it off
							game:onTickEnd(function() self:triggered(player.x, player.y, player) end)
							msg = "You set off the trap!"
							return false, msg
						end
					end
				end
				if consec >= diff_level then -- success after diff_level consecutive checks
					msg = "You successfully dismantled the trap."
					success = true return false, msg
				end
				local continue, reason = mod.class.Player.restCheck(player)
				if not continue then msg = "You were interrupted." end
				return continue, reason
			end

			local turns = math.ceil(diff_level*(1 + rng.float(1, 6*(1-chance/200)))) -- random turns to dismantle
			local dismantle = coroutine.create(function(self, who)
				local wait = function()
					local co = coroutine.running()
					who:restInit(turns, "Dismantling", "dismantled", function(cnt, max)
						-- "resting" finished, undo the restCheck hack and check results
						who.restCheck = oldrestCheck
						if not success then
							if cnt >= max then -- too difficult
								msg = "Your level of skill was not enough to understand the workings of this trap."
							else -- interrupted
								msg = msg or "You quit dismantling the trap."
							end
						end
						coroutine.resume(co)
					end)
					coroutine.yield()
					game.logPlayer(who, "#LIGHT_BLUE#%s: %s#LAST#", success and "Success" or "Failure", msg)
					return success
				end
				if not wait() then
					return 
				end
				game.state:unlockTalent(self.unlock_talent_on_disarm.tid, who)
			end)
			self:identify(true)
			local desc = util.getval(self.desc, self)
			desc = desc and "\n#LIGHT_BLUE#Trap Description:#WHITE#\n"..desc or ""
			require "engine.ui.Dialog":yesnoLongPopup(("Disarming a trap: %s"):format(self:getName()),
	([[As you begin disarming the trap, you think you may be able to learn how it works by carefully dismantling it.  You estimate this will take up to #YELLOW#%d#LAST# uninterrupted turns.
	What do you want to do?
%s
]]):format(turns, desc), math.min(800, game.w*.75),
			function(quit)
				if quit == true then
					game:playSoundNear(who, "ambient/town/town_large2")
					coroutine.resume(dismantle, self, who)
				end
			end,
			"Dismantle Carefully", "Disarm Normally")
		end
	end
end

BABBLETRON
Posts: 2
Joined: Thu Feb 13, 2020 10:30 pm

Re: Halfling Rogue cannot rest any more

#5 Post by BABBLETRON »

I ran into this issue yesterday and can't rest or auto explore anymore. How do I resolve this so I can rest or auto explore?

Lua Error: /mod/class/Trap.lua:202: attempt to compare nil with number
At [C]:-1 __le
At /mod/class/Trap.lua:202 restCheck
At /engine/interface/PlayerRest.lua:47 restInit
At /mod/class/Game.lua:2214
At /engine/KeyBind.lua:237

Post Reply