Commit Graph

8506 Commits

Author SHA1 Message Date
Pasi Kallinen
56f1201e43 Use strchr, not index 2023-02-01 16:10:41 +02:00
Pasi Kallinen
df8a0ac654 Split monster looking for items into separate function 2023-02-01 14:37:12 +02:00
Pasi Kallinen
6c9700ab25 Monster movement and object pickup cleanup
Clean up some of the code for monster deciding what objects
to pick up, removing duplicate code.  There should be no real
difference in behaviour, other than monsters now can pick up
one stack of items at a time; previously monster could pick up
gold, then a practical item, followed by a magical item all
in a single turn, although this very rarely mattered.

Not extensively tested.

Code originally from NetHack4.
2023-02-01 10:23:23 +02:00
nhmall
8ee42f5644 further work on soundlib support code
move some inline code into functions
replace some magic numbers

The mingw code is not tested yet.
2023-01-31 22:19:29 -05:00
Pasi Kallinen
4ccee5a177 Use could_reach_item 2023-01-31 19:09:43 +02:00
Pasi Kallinen
97d7a735a4 Separate function for monster safe touch object
Also added the check for touching an artifact to it
2023-01-31 18:44:13 +02:00
nhmall
ce0a4f60ca more windows Makefile tinkering
It looks like the Windows API call for PlaySound using SND_RESOURCE, from a
mingw32 built program, cannot find the resources that are
embeded into the .exe by the mingw32 resource compiler. That works fine
from visual studio.

For now, fall back to not using the SND_RESOURCE flag, use an ordinary
wav file name in the filesystem. Makefile.mingw32 has been modified
to copy the wav files to the binary directory along with the exe.

This probably won't be the final approach, but it will get things
working for now.
2023-01-31 00:45:27 -05:00
nhmall
9bbb2e17cf add a master off/on switch for sounds
sounds can be set in the config file or on the fly with the Options menu.

This also adds a mechanism for specifying a terminology preference
for a boolean option in the options menu.

The choices are: Term_False, Term_Off, Term_Disabled

Term_False, the default, will use the terms "false" and "true" in the
Options menu.
Term_Off will use the terms "off" and "on" in the Options menu.
Term_Disabled will use the terms "disabled" and "enabled" in the Options
menu.

I didn't review any of the existing options to see if one of the new
alternative terms might be a better fit. They were all left at the default.
2023-01-30 12:07:03 -05:00
Pasi Kallinen
744d64487b Helltweaks: improve lava river
The lava river will now draw another river, until a certain
amount of map locations have been turned into lava, so you don't
get a teensy "river" made out of 2 lava pools.

Add a lua selection method to count the number of locations
in the selection.
2023-01-30 17:10:39 +02:00
Pasi Kallinen
8eeeec41f5 Avoid repeating the god ray
My recent change to hit and wake monsters caused a recursive
ghod_hitsu -> wakeup -> dobuzz -> buzz -> ghod_hitsu loop.
Don't call the ghod_hitsu again if the priest is already angry.
2023-01-30 12:39:35 +02:00
Pasi Kallinen
77797450f5 Remove obsolete comment 2023-01-29 18:49:58 +02:00
Pasi Kallinen
394a46ab13 Fix teleported eel hiding in dry land 2023-01-29 14:25:01 +02:00
Pasi Kallinen
7c2c692ee5 Generate random eroded, erodeproof, or greased items
Items in initial hero inventory, or generated via lua in
special levels or themed rooms are not subject to this.

Code via xnethack by copperwater <aosdict@gmail.com>,
with some modifications.
2023-01-29 11:20:03 +02:00
nhmall
4575d564c7 do warning suppression for soundlib vars another way
Instead of introducing a bunch of preprocessor #ifdef blocks,
this approach is less-intrusive.
2023-01-28 14:55:54 -05:00
Pasi Kallinen
734dcfdabe Don't let monsters loot Schroedinger's box 2023-01-28 20:27:36 +02:00
Pasi Kallinen
60cbab1130 Fix shopkeeper getting mad when monster triggers a trap
When a monster triggered a rolling boulder trap which buried
a shop item in a pit, the shopkeeper would bill the hero.
(Or get mad at hero, if they were out of the shop)

The fix might not be quite right - should the shopkeeper get
mad at hero when monster triggers a trap created by hero?
Or when an item is buried in a pit created by a hero?
2023-01-28 20:03:23 +02:00
Pasi Kallinen
cb81631a38 Fix open showing wrong glyph
Trying to open a location where a pet was removed the glyph
and showed the underlying terrain glyph instead.
Just use newsym - it'll use feel_location when Blind.
2023-01-28 19:12:24 +02:00
nhmall
44677e82ab warning fix if no added soundlib compiled in 2023-01-28 09:09:39 -05:00
nhmall
5b3a8b5774 more Soundeffects tinkering 2023-01-27 23:41:54 -05:00
nhmall
90895330c5 soundlib terminology update - sound_triggers
Switch to using the term "sound triggers" for things that
result in a call to one of the soundlib routines.

SNDCAP_* renamed to SOUND_TRIGGER_*
sndcap field in the sound_procs struct changed to sound_triggers
2023-01-27 22:21:53 -05:00
PatR
47efcd90c7 shop object sanity - buried objects
This fixes the reported sanity check warning about a buried object
within shop boundary staying flagged no_charge after the shopkeeper
leaves the shop.  Leaving the shop to pursue the hero moves unpaid
items off the bill to owed-as-robbery and changes no_charge items
to shop-owned but it wasn't doing the latter for buried objects.

I haven't attempted to test on a level with multiple shopkeepers.
If that was working correctly for unpaid items than I think it
ought to work correctly for no_charge items now.  I'm not sure how
thoroughly the handling for unpaid items was tested though.
2023-01-27 11:01:24 -08:00
nhmall
5401983d76 suppress "set but not used" warning if no soundlib 2023-01-27 09:57:54 -05:00
nhmall
aee2ff57e8 additional Soundeffect, additional SoundAchievement
Also adds a macro SoundeffectEvenIfDeaf for a couple of proposed
special cases where Deafness shouldn't factor in.
2023-01-27 01:25:05 -05:00
nhmall
446044e1d5 1st of a few sequencing changes
rename display_gamewindows() to init_sound_and_display_gamewindows()
(I know that's getting pretty long-named).

move activate_chosen_soundlib() into init_sound_and_display_gamewindows()
from moveloop_preamble().

Also included was a missing break in a switch related to sounds.
2023-01-26 17:15:59 -05:00
PatR
52a44b3255 fix github issue #967 - nearby objects
Issue reported by entrez:  distant_name() used different criteria
for 'nearby' than map_object() and see_nearby_objects(), so it could
mark objects as seen when they were being displayed as generic,
without redisplaying them as a specific.  Generic object with dknown
set leads to confusion.  Example was "a spellbook spellbook".

I think this should fix things, but I've only done a small amount of
testing so far.

Fixes #967
2023-01-26 14:05:03 -08:00
PatR
b684f2c401 offer_real_amulet() tweaks
Mote PR #965.  Add a couple of comments and fix up some formatting.
2023-01-26 13:39:00 -08:00
PatR
cef8206af4 \#version warning fix
Avoid #ifdef/#else/#endif inside expansion of Strcat() macro.

Also, change constructed
|soundlib_nosound, soundlib_macsound, and soundlib_qtsound, user sounds.
to be
|nosound, macsound, qtsound, and user sounds.

OPTIONS=soundlib:somelib doesn't--or won't, when finished being
implemented--include the "soundlib_" prefix in the user-visible
value, and placement of "and" vs "user sounds" was odd.

The code should probably be reorganized so that makedefs can put that
into dat/options or at least have it put a placeholder for the missing
paragraph.
2023-01-26 09:10:24 -08:00
PatR
3a2d6d6d0a pull request #965 - split offering the Amulet
into a separate routine

Pull request from argrath:  move the code used when offering the
Amulet of Yendor on a high altar out of dosacrifice() into a new
routine.

Closes #965
2023-01-26 08:28:27 -08:00
Pasi Kallinen
f61e1e8e23 Tiny chance of breaking iron bars with war hammer
Also add some different sounds to hitting the iron bars,
and make it noisy.
2023-01-26 18:21:53 +02:00
SHIRAKATA Kentaro
38cb1b9096 split offering the real amulet into a separate function 2023-01-26 08:19:39 -08:00
Michael Meyer
7f4e69f885 Fix: use-after-free in dog_eat()
I think moving the m_consume_obj call (which will free the eaten item)
further down should fix this without causing any really wacky message
sequencing issues, but if maintaining the exact order is important
obj->unpaid and its price could be cached before the free instead.
2023-01-26 08:30:00 +02:00
nhmall
7ecb1e0757 fix warning
In file included from makedefs.c:180:
./../src/mdlib.c:92:12: warning: unused function 'count_and_validate_soundlibopts' [-Wunused-function]
static int count_and_validate_soundlibopts(void);
           ^
1 warning generated.

Function definition is in the #ifndef MAKEDEFS_C section, so move the prototype there too.
2023-01-26 00:49:11 -05:00
nhmall
4ac30aa2ec list which soundlib support is compiled in 2023-01-26 00:45:32 -05:00
nhmall
b89d2e0ef1 Fix potential warning in music.c
I saw this included in PR966, but it has nothing to do with the
use-after-free that the pull request is meant to fix. It should
get applied independently of that pull request.
2023-01-25 15:21:30 -05:00
nhmall
24c99e005a add a sounds.c comment in two places 2023-01-25 15:14:27 -05:00
Pasi Kallinen
d19c92281a Give gremlin the property it stole, if possible 2023-01-25 21:55:11 +02:00
nhmall
1b8edf852f more Soundeffects fiddling 2023-01-25 14:23:22 -05:00
Pasi Kallinen
5b8dc1eff7 Split pet ranged attack into separate function 2023-01-25 11:27:14 +02:00
Pasi Kallinen
ed7e344f00 Giants occasionally have a weapon 2023-01-24 20:54:39 +02:00
nhmall
84b9af9151 add a few missing Soundeffects to apply.c 2023-01-24 13:36:33 -05:00
nhmall
5171fcdc1d some macsound instrument play refinements
Also some better core placement of some of the Hero_playnotes calls.
2023-01-24 13:02:29 -05:00
Pasi Kallinen
0cbb9899cb Rename variable from tmp to dmg 2023-01-24 17:02:13 +02:00
Pasi Kallinen
2f40a8c9aa Split hmon_hitmon into multiple functions
hmon_hitmon was the biggest function by far; this makes it far more
manageable.

There should be no change in functionality, and although I didn't
test every case, this was just moving chunks of code and changing
variable names until compiler did not complain anymore.
2023-01-24 15:25:35 +02:00
PatR
641065ee74 some mkmaze.c reformatting 2023-01-24 00:22:23 -08:00
PatR
cc287ebc0c fix sounds warning
Avoid a warning issued when 'nosound' is the only entry in the array
of sound libraries.  Also, panic() if soundlib index is out of bounds.
2023-01-24 00:17:25 -08:00
PatR
0e761836ca fix misplaced parenthesis in end.c 2023-01-23 23:45:19 -08:00
nhmall
cab068d48e Merge branch 'fix-hacklib' of https://github.com/argrath/NetHack into NetHack-3.7 2023-01-24 00:39:10 -05:00
nhmall
46f86343e6 Merge branch 'macsound' into NetHack-3.7 2023-01-23 23:52:07 -05:00
nhmall
3d908c49ef take initial stab at macsound interface
Use macOS AppKit framework routines for a first cut at a
macsound soundlib interface.

Requires WANT_MACSOUND=1 on build.

Nothing has been done to move the stock sounds into the resources
of a bundle, so after building, if you want to try the stock sounds
out:
	cp sound/wav/*.wav ~/Library/Sounds

Because the NSSound macOS routines always do the search, supposedly
the following locations are searched in this order:
   1. the application’s main bundle
   2. ~/Library/Sounds
   3. /Library/Sounds
   4. /Network/Library/Sounds
   5. /System/Library/Sounds

Although not specifically implemented as of yet, it may be pretty
close to being able to put soundeffects wav files (by se_ name)
into ~/Library/Sounds working for the SND_SOUNDEFFECTS_AUTOMAP feature.

Feedback is welcome. Contributions for improving it are even more
welcome.

The new soundlib supporting file is named
sound/macsound/macsound.m since it's got objective C in it.

Known bugs and glitches:

The Hero_playnotes on a set of 5 notes goes too fast, so there
needs to be a slight delay added between the note of a multi-note
play.
2023-01-23 23:50:43 -05:00
SHIRAKATA Kentaro
b8ec2dfc96 Avoid casting time_t to int
As time_t may not fit int, cast -1 to time_t instead.
2023-01-24 13:48:43 +09:00