Skip to content

Our Hero can safely wait until recovered#27

Merged
primeau merged 2 commits into
primeau:masterfrom
friedev:wait
Apr 19, 2026
Merged

Our Hero can safely wait until recovered#27
primeau merged 2 commits into
primeau:masterfrom
friedev:wait

Conversation

@friedev
Copy link
Copy Markdown
Contributor

@friedev friedev commented Apr 11, 2026

Implements the M command to wait multiple turns until the hero has regenerated all of their HP and spells, or until interrupted by a nearby monster or taking damage.

I pretty much followed the outline from the existing TODO comment, with a few differences:

  • Set the nomove flag, because otherwise the hero waits one additional turn after interrupted.
  • I didn't implement the idea of waiting 100 turns if you were already at full HP/spells, because I wouldn't want a player to accidentally press M to recover while already at full HP and accidentally waste 100 turns. This way, you can always safely press M to make sure you're recovered without needing to checking your HP and spells first.
  • Added a sanity check for game over - just in case - because otherwise the game goes into an infinite loop.
  • Added a log message to communicate how long the hero waited and why they stopped. Hopefully this also makes the command pretty self-explanatory, even if someone uses it accidentally.
  • Added a note in the comment saying which version this was added in, to indicate that it's not in the original Larn. I took a guess and put 12.5.4, but if you intend to release this in a different version, that's an easy change.

For now, this command is effectively undocumented in-game, like the P shortcut to auto-pray.

One thing I noticed that isn't specific to this PR but is related: it doesn't seem that other uses of nearbymonst() and nearbymonsters() check whether the hero can actually see the nearby monster (e.g. invisible monsters, blindness), which could inadvertently reveal information to the player that their character shouldn't know. I think it might make more sense to fix this across the codebase in a different PR; if you agree, I can open an issue.

@friedev friedev force-pushed the wait branch 2 times, most recently from fca1cc1 to a877be9 Compare April 11, 2026 18:45
@friedev friedev marked this pull request as draft April 19, 2026 12:56
@friedev friedev marked this pull request as ready for review April 19, 2026 13:20
@friedev
Copy link
Copy Markdown
Contributor Author

friedev commented Apr 19, 2026

Rebased onto master. Additional changes:

  • Fix: if the player cannot see a nearby monster (i.e. monster is invisible or hero is blind), it no longer interrupts waiting.
    • Getting hit still interrupts waiting, so you won't just die if an invisible monster attacks you while waiting.
  • Fix: game time now passes while using this shortcut.
    • This stems from a more fundamental bug: parse2 doesn't actually increment gtime. This means that various actions that should count toward your overall time limit actually don't, such as running any number of tiles or falling asleep. This exploit might've been in the original Larn, but do we want to fix it?
  • Mobile controls: holding the run button and pressing . will wait until recovered.
    • I think this is a fairly elegant way to do it, but it carries the risk of players accidentally using it. I'm happy to change it to a dedicated button if anyone is opposed to this.

@primeau primeau merged commit 252e566 into primeau:master Apr 19, 2026
@clashleyca
Copy link
Copy Markdown

clashleyca commented Apr 21, 2026

I got stuck in time stop (stp) earlier today, I couldn't get out and had to leave the game. I wonder if this is why, I could believe I might have hit "M" while in the stopped time.

Cool feature though!

@friedev
Copy link
Copy Markdown
Contributor Author

friedev commented Apr 21, 2026

@clashleyca Good catch! The root cause is actually a related change that inadvertently caused time stop to last forever. I created #29 to fix this.

@primeau
Copy link
Copy Markdown
Owner

primeau commented Apr 21, 2026

Thanks for the bug report! I've shipped Aaron's fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants