Commit Graph

568 Commits

Author SHA1 Message Date
Pasi Kallinen
28e416da3a Add moving on the trap to the mouse menu 2022-04-11 15:08:50 +03:00
Pasi Kallinen
503b85b1cf Add spell casting to mouse menu 2022-04-11 14:54:12 +03:00
Pasi Kallinen
ec4fafcf53 Fix erroneous test_move params 2022-04-10 12:52:39 +03:00
Pasi Kallinen
e53a4c0abd Context sensitive item usage from inventory
Allow selecting an item from inventory and show a menu of actions
applicable for that particular item. Some of the entries might
be slightly spoilerish (eg. it'll reveal that you can read T-shirts),
but the improved usability for new players is more than worth it.

Generally known as "item actions", this was first implemented
in AceHack by Alex Smith.
2022-04-09 15:28:23 +03:00
Pasi Kallinen
093f7452af Some more therecmdmenu
If on, therecmdmenu handles clicking anywhere on the map,
not just on or next to hero.  Add throwing items to the menu.
2022-04-08 19:48:01 +03:00
Pasi Kallinen
77cf464836 Add chat and offer to herecmdmenu 2022-04-07 18:06:31 +03:00
Pasi Kallinen
10fd0deab2 When levitating, hide drink and dip from herecmd_menu 2022-04-07 16:44:16 +03:00
PatR
6d490de39c warning fix
Remove redundant 'if (K)' from there_cmd_menu().  The !K case doesn't
get there and that test's presence fools the compiler (oldish clang)
into warning that 'npick' might be used uninitialized.
2022-04-06 12:06:47 -07:00
Pasi Kallinen
eb9c7d77d4 Improve therecmdmenu
Turning on herecmd_menu and clicking with mouse is now actually
somewhat playable.
2022-04-06 21:23:27 +03:00
Pasi Kallinen
e260c9ded5 Fix mouse travel and look
Looks like I broke mouse travel and clicklook a while back, and
no-one noticed...
2022-04-05 15:03:20 +03:00
Pasi Kallinen
92c21b588b Ask to kick a locked door open, if hero has no unlocking tool 2022-04-03 13:58:50 +03:00
Pasi Kallinen
6977aef436 Fix stuck travel for good
My fixes to the travel stuck oscillation did not fix all of them,
and I've even seen a 3-step loop - which my fixes cannot detect.
I guess there could be arbitrary-sized loops too.

To definitely fix this, keep track of all the map locations travel
has moved the hero through, and if it tries to go on a location already
used, stop travel and give the unsure -message.
2022-04-02 18:27:53 +03:00
PatR
6fb0c8a82e cancelled #herecmd using time
I managed to execute #herecmd by mistake and when I typed ESC to get
out of its menu, monsters took their next turn.  #therecmd behaved
similarly.
2022-03-21 18:33:34 -07:00
PatR
b150594d68 hide-under webmakers...
Offer the chance to explicitly hide via #monster when poly'd into a
hides-under creature.  hides_under() doesn't pass the is_hider() test
so wasn't being allowed before.

If poly'd hero's monster form is both a webmaker and can hide-under,
have #monster prompt the player for which is intended.  When poly'd
hero successfully spins a web, say so.

If poly'd hero deliberately tries to hide under a cockatrice corpse,
turn to stone.
2022-03-21 18:21:07 -07:00
nhkeni
ff1289e828 Add Strlen(), a strlen(3) that panics if string is stupid long and returns unsigned.
First batch of changes to use it to suppress warnings.
2022-03-16 21:34:21 -04:00
nhkeni
1e31fee0df Don't infringe on POSIX typedef namespace. 2022-03-16 21:31:26 -04:00
nhkeni
16ea5e7fa6 cmdcount_t
Add a type to force g.{command_count,last_command_count,multi} to have the
same type (because cmd.c: g.multi = g.command_count;) and some resulting
cleanup.
2022-03-16 17:33:44 -04:00
Pasi Kallinen
62906e732e Trap sanity checking 2022-03-04 16:54:43 +02:00
PatR
77bd50fd77 fix github issue #687 - logging of major events
Reported by k21971, the dumplog section labeled "major events" showed
all logged events rather than just the ones classified as major.
Filter out the non-major ones when writing dumplog.

At the moment only a couple of ones other than achievements are major.
Probably various other types should be too.

The #chronicle command still lists all logged events unless they're
flagged as 'spoiler'.  So far the mines' end luckstone is the only
one flagged that way.  Unfortunately a player with access to live
logging could still learn whether or not the gray stone that has just
been picked up on the last mines level is the target luckstone by
viewing the log from outside of the game.

The #chronicle command would be more useful if it gathered all the
categories of events present and put up a menu allowing the player to
choose which ones to view.  I haven't attempted to implement that.

Closes #687
2022-03-01 04:15:55 -08:00
nhkeni
3cf1b87914 cmdcount_t
Add a type to force g.{command_count,last_command_count,multi} to have the
same type (because cmd.c: g.multi = g.command_count;) and some resulting
cleanup.
2022-02-27 20:01:49 -05:00
Pasi Kallinen
16a8caac97 Allow using #wiztelekinesis on yourself 2022-02-24 15:10:39 +02:00
Michael Meyer
1e951db9bc Fix: monster hurtling and liquid
A monster hurtling over liquid would drown immediately the instant it
touched the first square of water, even if normally it would have kept
moving (e.g. hurtling over a short moat).  Additionally, its placement
on liquid would not take into consideration other monsters, so it could
overwrite an existing monster on that spot and lead to an impossible,
and/or two monsters occupying a single position.

Fix these issues, so that liquid effects like drowning only happen if
the monster ends up in liquid at the end of the hurtle, and so that
other monsters in the way will stop it early even if they're floating
over or swimming on a pool/water/lava square.

Also use canspotmon instead of canseemon for the wiztelekinesis debug
command.
2022-02-24 14:53:48 +02:00
Pasi Kallinen
8e91320d2f Use u_at macro 2022-02-23 20:28:55 +02:00
nhmall
407e515d7a whitelist a new warning in cmd.c
src/cmd.c(1253): warning: conditional expression is constant
2022-02-22 15:10:33 -05:00
Pasi Kallinen
268022e5de Add #wiztelekinesis for testing purposes
For testing mhurtle, which is used for jousting or
bare-handed combat.

Improve mhurtle_step to handle bumping into another monster,
and when the monster gets killed or stuck in a trap.
2022-02-22 16:00:05 +02:00
Pasi Kallinen
953a534cc5 Fix fire auto-swapweaponing to polearm
When you have a polearm as secondary weapon, have a fireassist on,
and press 'f' to fire, the code tries to swapweapon to the polearm.
This failed badly and got stuck in a loop if you were also wearing
a shield - as polearms are two-handed and shield prevents wielding
those.

Add a new "command failed" result, and clear the command queue
in that case. Also make swapweapon and wield actually return
the ECMD flags back to the rhack loop.
2022-02-17 09:12:07 +02:00
Pasi Kallinen
679f8c11c9 Fix broken fireassist
When I recently refactored the rhack loop, I also broke fireassist,
as rhack was clearing the command queue unconditionally.
2022-02-15 20:16:31 +02:00
PatR
27dd93df17 more curses get_count
A couple of formatting bits I made when investigating cursor
positioning misbehavior for curses menu counts.  No change in
behavior here.
2022-02-11 12:12:35 -08:00
PatR
d761263e89 livelog tweaks
Log all level gains and loses.  For the existing logging of changes
in rank, mention the level number with the new title.  Classifying
level loss as "minor achievement" seems weird but I didn't see any
choice more appropriate.

Make '#chronicle' autocomplete.  That makes "#ch" ambiguous, but
better to have to type #cha to chat than to have to completely spell
out #chronicle.  (Changing it to #journal would make #j ambigious
but might still be an improvement.)
2022-02-09 14:25:32 -08:00
Pasi Kallinen
1e90f89203 Chronicle of major events, and livelog
Log game events, such as entering a new dungeon level, breaking
a conduct, or killing a unique monster, in a new "Major events"
chronicle. The entries record the turn when the event happened.
The log can be viewed with #chronicle -command, and the entries
also show up in the end-of-game dump, if that is available.

This feature is on by default, but can be disabled by
defining NO_CHRONICLE compile-time option.

This also contains "live logging", writing the events as they
happen into a single livelog-file. This is mostly useful for
public servers. The livelog is off by default, and must be
compiled in with LIVELOG, and then turned on in sysconf.

Mostly this a version of livelogging from the Hardfought server,
with some changes.
2022-02-09 22:49:25 +02:00
PatR
a0100dd300 using prefixes via their extended command names
Trying to use #reqmenu/#rush/#run/#fight prefixes by their extended
command names didn't work because rhack()'s post-processing was stuck
dealing with the entry for the '#' key after using doextcmd() to run
any command.  Use a static variable (actually a global one since I put
it into struct g) to notify rhack() of the command that ultimately got
executed.
2022-02-07 16:53:56 -08:00
PatR
deec94e533 disallow g/G/F prefix with rush/run commands
Reject an attempt to specify a conflicting or redundant prefix with
a Ctrl+<move> or Shift+<move> (not numpad) or Alt+<move> (numpad).
'm' prefix is accepted.
2022-02-07 14:22:41 -08:00
Pasi Kallinen
bbd5577063 Fix copy-paste error 2022-02-07 13:09:52 +02:00
PatR
6a8394688b move up/down tweak
Have '<' and '>' accept 'm' prefix for move without autopickup but
disallow the other movement prefix keys.
2022-02-07 02:29:01 -08:00
Pasi Kallinen
e2442c395b Make double fight prefix cancel out 2022-02-07 09:14:47 +02:00
PatR
568ba7b305 more command prefix handling
When a command doesn't allow a prefix, go back to showing the prefix
keystroke in the can't-do-that feedback rather than the command name
that it has for potential binding.  I went away from that earlier
after typing 'G' followed by 'o' and getting "the open command does
not accept 5 prefix" instead of "G prefix".

Fix the lookup routine which was responsible for that.  At least
partially fix it; actually it only ignores digits for !numpad.  If a
numpad user types G where it isn't allowed, the feedback will still
be about 5 instead of G.  The code is going from keystroke-used to
command-it-invokes back to keystroke-for-command which won't
necessarily yield the original keystroke because a command can be
bound to more than one key.
2022-02-06 18:09:23 -08:00
PatR
b3c5d68399 fix movement prefixes
My earlier change resulted in rejecting all commands entered after
a movement prefix key, rather than just ones that aren't supposed to
take any prefix.

This fixes that and also restores the ability to use 'm>' or 'm<' on
stairs to change levels without auto-pickup at the destination.
2022-02-06 17:46:31 -08:00
PatR
cfd753dd12 command prefix handling
Investigating github issue #664 by argrath turned up a more
significant problem.  Prefixes other than 'm' preceding commands
that don't use a prefix didn't get rejected but didn't do anything.

Fixes #664
2022-02-06 11:51:00 -08:00
Pasi Kallinen
93db2a8a84 Rejigger the prefix input
Make prefix commands cancel themselves when pressed twice,
with a message saying so.

Hopefully this fixes the problems I introduced.
2022-02-05 10:05:40 +02:00
SHIRAKATA Kentaro
cf810630de add missing const
If you want to declare a pointer which the address pointed to is constant,
you should declare it as like `static const char *const var = "...";`.

This commit supplies missing `const` and prevents some programming
error in the future.
2022-01-29 11:13:01 -08:00
Pasi Kallinen
9f9551bdb3 Swap running and rushing modes back
I unintentionally swapped the shift and ctrl movement keys
when redoing the movement input - change them back to how
it was earlier.

Also change the number_pad meta-key bindings, and explain
in the comments why: We can't bind shift or ctrl numbers.
Meta (aka alt-key) works with number-pad numbers when
the altmeta-option is on. There was no altmeta in 3.4.3.

Here's a table of the flags.run/g.context.run values,
from 3.4.3 and 3.7 as of this commit:

             | num_pad:0 || num_pad:1
             | 343 | 370 || 343 | 370
-------------------------------------------------
 <dir>       |  0  |  0  ||  0  |  0
 shift-<dir> |  1  |  1  ||  0  | N/A
 ctrl-<dir>  |  3  |  3  ||  0  | N/A
 meta-<dir>  | N/A | N/A || N/A |  1 (with altmeta)
 m-prefix    |  0  |  -  ||  0  |  -
 G-prefix    |  3  |  3  ||  3  |  3
 g-prefix    |  2  |  2  ||  2  |  2
 5-prefix    | N/A | N/A ||  3  |  3
-------------------------------------------------

The m-prefix in 3.7 does not set the run-value, as it can now
be used with any movement key or prefix, which will set the run value.

New input system does not lose functionality when compared to 3.4.3.
Instead, the number_pad users gain the meta-<dir> running.

This doesn't fix the issue of three badly differentiated run values.
2022-01-29 12:58:06 +02:00
Pasi Kallinen
4130a3a6ae Fix ESC so it cancels the movement prefix commands
My changes to turn the movement and prefix commands into
extended commands broke this.
2022-01-24 19:48:43 +02:00
Pasi Kallinen
738a225011 Replace a return value with ECMD define 2022-01-22 16:04:02 +02:00
Pasi Kallinen
9d64d135b8 Curses: fix extended command input
The extended command input prompt was behaving in an unintended way:
Typing #a<enter> executed #adjust. Spaces in the entry prevented matching
any command. No error message was given when no command was matched.

Fix all of those, so it behaves more like the tty.

Clean up the tty, curses, and X11 windowport code, so they don't use
the extcmdlist array directly, but query with extcmds_match
and extcmds_getentry.
2022-01-22 14:32:53 +02:00
PatR
fe4ae913cc more 'rest_on_space'
Honor any key binding for <space> when rest_on_space is Off.
Toggling it On and Off remembers the key binding if there is one.
So if the RC file has BIND=\32:attributes, <space> will run #wait
when rest_on_space is On and run #attributes when it's Off.
2022-01-22 00:30:39 -08:00
PatR
6a72e48a40 fix rest_on_space
When rest_on_space is On, assign same function as for #wait to the
<space> key.  When Off, set that key to Null instead.  Binding some
other command to <space> when rest_on_space is Off doesn't work but
I would classify that as something to be discouraged anyway.
2022-01-21 15:51:05 -08:00
PatR
5f14f0ff57 options help one more time...
Move the help text for the 'O' command from the code into its own file
and allow that to be accessed from the '?' menu as well as by choosing
entry '?' in the 'O' menu.

sys/unix/Makefile.top has been updated to handle new 'optmenu', others
need to catch up.  The game will still build and run without the file
but asking for options menu help won't work until they do.
2022-01-19 14:22:21 -08:00
PatR
f420b9672f Qt: more '#' support
Add an entry for running an extended command to Qt's 'game' menu.
2022-01-17 14:38:16 -08:00
Pasi Kallinen
2e144e814d Change repeat into extended command 2022-01-17 17:13:59 +02:00
Pasi Kallinen
89cfea0085 Fix up/down movement
I broke these in the recent commit changing the movement commands.
2022-01-16 21:46:46 +02:00