Commit Graph

204 Commits

Author SHA1 Message Date
nhmall
9bb96322a8 compile NetHack-3.7 without makedefs-generated .h files
This evolves and hopefully eases the game-build requirements by
removing game-compile dependencies on any header files generated
by the makedefs utility, including:

date.h dependency and its inclusion is removed and comparable functionality
is produced at runtime via new file src/date.c.

pm.h dependency and its inclusion is removed and comparable functionality is
produced by moving the monster definitions from monst.c into new header
file called monsters.h and altering them slightly. The former pm.h header
file #define PM_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

onames.h dependency and	its inclusion is removed and comparable functionality
is produced by moving the object definitions from objects.c into new header
file called objects.h and altering them slightly. The former onames.h header
file #define values are now replaced with appropriate emitted enum entries
during the compiler preprocessing.

artilist.h has been slightly altered, and the former onames.h artifact-related
header file #define ART_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and
onames.h (makedefs -o) for reference purposes. They won't be used during
the compiler.

The other uses for makedefs remain. They are used to prepare external
file content that the game utilizes, not prerequisite code for the
compile:
    makedefs -d    (database)
    makedefs -r    (rumors)
    makedefs -h    (oracles)
    makedefs -s    (epitaphs, engravings, bogusmons)

date.c

Pull the code for date/time stamping from mdlib.c into date.c.
Set date.o to be dependent on source files, header files, and .o files
so that date.o is rebuilt from date.c when any of those changes, thus
ensuring an accurate date/time stamp. It also includes git sha
functionality formerly done by makedefs writing #define directives
into include/date.h. For unix it passes the git info on
the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020)

nethack --dumpenums (optional, but on by default)

Allow developer to obtain some internal enum values from NetHack
without having to resort to an external utility such as
makedefs.

Uncomment #define NODUMPENUMS in config.h to disable this.

The updates to sys/windows/Makefile.gcc have not been tested yet.
2021-08-21 07:59:18 -04:00
Pasi Kallinen
d463a9e258 Reveal branch stairs only after traversing them 2021-07-30 19:40:54 +03:00
Pasi Kallinen
d332720336 Increment editlevel
Added the new branch stairs glyphs, forgot to increment editlevel.
2021-07-27 18:56:50 +03:00
PatR
5a09a01a13 gold dragon and scales
Add two new monsters and two new objects:
 gold dragon
 baby gold dragon
 gold dragon scale mail
 set of gold dragon scales

A couple of variants seem to have added these already, but this came
off my ancient list of monsters to add and was done from scratch.
It's a clone of silver dragon, but instead of having reflection and
breathing cold, a gold dragon emits light and breathes fire; because
of the latter it can be seen with infravision like a red dragon.
Adult gold dragons are lawful as in the AD&D Monster Manual rather
than chaotic as the wiki pages show for the variant versions.

Worn gold dragon scales operate similar to wielded Sunsword:  when
blessed, radius is 3 (same as a lamp), if uncursed, radius is 2, and
if cursed, radius is 1 (but functions as 2 when worn by the hero,
otherwise there would be no tangible effect).  Gold dragon scale mail
gets an extra +1, making blessed gold DSM have a bigger radius than
lamps.  Embedded scales have radius 1 regardless of BUC state; light
for that case comes from the gold dragon monster form the hero is in.
When not worn, gold scales and scale-mail don't emit any light.

The tiles use a mix of yellow (for gold) and red.  The two object
tiles seem reasonable variations of the corresponding silver dragon
ones.  The two monster tiles definitely need work since the silver
ones were mostly cyan and changing that to red did not produce very
good result; subsequent attempt at a mixture was haphazard at best.
2021-07-23 10:41:57 -07:00
Pasi Kallinen
8d2407f1f2 Monsters can gain resistances by eating corpses
This is based on both the EvilHack implementation by
k21971 <keith.simpson1971@gmail.com>, and xNetHack
implementation by copperwater <aosdict@gmail.com>.
2021-05-23 19:03:33 +03:00
Pasi Kallinen
20cbadcf85 Unlock your quest by killing your quest leader
Allow killing your quest leader, just to make games winnable if you
converted before doing the quest.
Boost the quest leaders and give them some equipment. King Arthur
gets Excalibur. Killing quest leader gives really bad luck and
makes your god angry at you, and killing quest guardians gives
smaller penalties.

This is based on both the EvilHack implementation by
k21971 <keith.simpson1971@gmail.com>, and xNetHack
implementation by copperwater <aosdict@gmail.com>.
2021-05-23 11:11:58 +03:00
Pasi Kallinen
2288452278 Monsters can see player resistances
If monsters see you resist something, generally elemental or magical
attack, or if they see you reflect an attack, they learn that and
will adjust their attack accordingly.

Originally from SporkHack, but this version comes via EvilHack with
some minor changes.
2021-05-17 20:01:11 +03:00
Pasi Kallinen
f9aff476c4 Increment editlevel
Just in case, even though changing joined to boolean shouldn't cause problems.
2021-02-19 17:28:43 +02:00
nhmall
046ff4129b bump editlevel 2021-02-10 19:54:10 -05:00
nhmall
18116d4a7b update for 2021 2021-01-01 22:07:54 -05:00
nhmall
0c3b9642e4 pmnames mons gender naming plus a window port interface change
add MALE, FEMALE, and gender-neutral names for individual monster species
to the mons array. The gender-neutral name (NEUTRAL) is mandatory, the
MALE and FEMALE versions are not.

replace code uses of the mname field of permonst with one of the three
potentially-available gender-specific names.

consolidate some separate mons entries that differed only by species into a
single mons entry (caveman, cavewoman and priest,priestess etc.)

consolidate several "* lord" and "* queen/* king" monst entries into
their single species, and allow both genders on some where it makes some
sense (there is probably more work and cleanup to come out of this at some
point, and the chosen gender-neutral name variations are not cast in stone
if someone has better suggestions).

related function or macro additions:
    pmname(pm, gender) to get the gender variation of the permonst name. It
    guards against monsters that haven't got anything except NEUTRAL naming
    and falls back to the NEUTRAL version if FEMALE and MALE versions are
    missing.

    Ugender to obtain the current hero gender.
    Mgender(mtmp) to obtain the gender of a monster

While the code can safely refer directly to pmnames[NEUTRAL] safely in the
code because it always exists, the other two (pmnames[MALE] and
pmnames[FEMALE] may not exist so use:
    pmname(ptr, gidx)
      where -ptr is a permonst *
            -gidx is an index into the pmnames array field of the
             permonst struct
pmname() checks for a valid index and checks for null-pointers for
pmnames[MALE] and pmnames[FEMALE], and will fall back to pmnames[NEUTRAL] if
the pointer requested if the requested variation is unavailable, or if the
gidx is out-of-range.

Allow code to specify makemon flags to request female or male (via MM_MALE
and MM_FEMALE flags respectively)to makedefs, since the species alone doesn't
distinguish male/female anymore. Specifying MM_MALE or MM_FEMALE won't
override the pm M2_MALE and M2_FEMALE flags on a mons[] entry.

male and female tiles have been added to win/share/monsters.txt.
The majority are duplicated placeholders except for those that were
separate mons entries before. Perhaps someone will contribute artwork in the
future to make the male and female variations visually distinguishable.

tilemapping via has the MALE tile indexes in the glyph2tile[]
array produced at build time. If a window port has information that the
FEMALE tile is required, it just has to increment the index returned
from the glyph2tile[] array by 1.

statues already preserved gender of the monster through STATUE_FEMALE
and STATUE_MALE, so ensure that pmnames takes that into consideration.

I expect some refinement will be required after broad play-testing puts it to
the test.

    consolidate caveman,cavewoman and priest,priestess monst.c entries etc

This commit will require a bump of editlevel in patchlevel.h because it alters
the index numbers of the monsters due to the consolidation of some. Those
index numbers are saved in some other structures, even though the mons[] array
itself is not part of the savefile.

Window Port Interface Change

Also add a parameter to print_glyph to convey additional information beyond
the glyph to the window ports. Every single window port was calling back to
mapglyph for the information anyway, so just included it in the interface and
produce the information right in the display core.

The mapglyph() function uses will be eliminated, although there are still some
in the code yet to be dealt with.

win32, tty, x11, Qt, msdos window ports have all had adjustments done to
utilize the new parameter instead of calling mapglyph, but some of those
window ports have not been thoroughly tested since the changes.

Interface change additional info:

    print_glyph(window, x, y, glyph, bkglyph, *glyphmod)
            -- Print the glyph at (x,y) on the given window.  Glyphs are
               integers at the interface, mapped to whatever the window-
               port wants (symbol, font, color, attributes, ...there's
               a 1-1 map between glyphs and distinct things on the map).
            -- bkglyph is a background glyph for potential use by some
               graphical or tiled environments to allow the depiction
               to fall against a background consistent with the grid
               around x,y. If bkglyph is NO_GLYPH, then the parameter
               should be ignored (do nothing with it).
                -- glyphmod provides extended information about the glyph
               that window ports can use to enhance the display in
               various ways.
                    unsigned int glyphmod[NUM_GLYPHMOD]
               where:
                    glyphmod[GM_TTYCHAR]  is the text characters associated
                                          with the original NetHack display.

                    glyphmod[GM_FLAGS]    are the special flags that denote
                                          additional information that window
                                          ports can use.

                    glyphmod[GM_COLOR] is the text character
                                       color associated with the original
                                       NetHack display.

Support for including the glyphmod info in the display glyph buffer
alongside the glyph itself was added and is the default operation.
That can be turned off by defining UNBUFFERED_GLYPHMOD at compile time.
With UNBUFFERED_GLYPHMOD operation, a call will be placed to map_glyphmod()
immediately prior to every print_glyph() call.
2020-12-26 11:23:23 -05:00
PatR
4cf6727b4e re-implement pull req #334 - sorting discoveries
The pull request changed \ and ` output to unconditionally show
discoveries in alphabetical order.  That's nearly useless except
when looking at prediscovered weapons and armor that fighter
types start out knowing.

This allows the player to choose sorting order via the new
'sortdiscoveries' option.  In addition to setting it via
config file or 'O', it can be set via 'm' prefix for \ and `.
Choices are:
 o - sort by class, by order of discovery in class (default);
 s - sort by 'sortloot' classification which groups sub-class
     items (so all helmets before any other armor, then all
     gloves, then boots, and so on); within each sub-class, or
     whole class for classes which don't subdivide so usefully,
     partly-discovered types (where a name has been assigned)
     come before fully ID'd types;
 c - sort by class, alphabetically within class;
 a - sort alphabetically across all classes.

Turned out to be a large amount of work for fairly little gain,
although I suspect that 'sortdiscoveries:s' will eventually be
more popular than the default.

Invalidates existing save files so that current sort setting can
persist across save/restore cycles.

Closes #334
2020-12-19 17:45:49 -08:00
Pasi Kallinen
0462a2088c Increment EDITLEVEL
Forgot to increment EDITLEVEL when I did the stairs change,
and again after fixing the Oracle bones stairs. Lets do it now.
2020-12-05 19:38:20 +02:00
nhmall
0d6481ad8c spelling correction tidbit
Closes #415
2020-11-28 08:59:03 -05:00
Pasi Kallinen
deb730d9b5 More hypothetical type mismatches 2020-11-15 13:51:47 +02:00
Pasi Kallinen
289c8d654d Futureproofing hypothetical type mismatches
If we ever want huge maps with COLNO or ROWNO larger than signed char,
this will at least allow the game to compile and start when typedef'ing
xchar to int. Trying to use huge maps exposes more bugs.
2020-11-14 13:53:09 +02:00
Pasi Kallinen
6ec55a3624 Rework stairs structure
Use a linked list to store stair and ladder information, instead
of having fixed up/down stairs/ladders and a single "special" (branch)
stair.

Breaks saves and bones.

Adds information to migrating objects and monsters for the dungeon
and level where they are migrating from.
2020-11-13 20:27:17 +02:00
Pasi Kallinen
c9ac5bc48a Increase EDITLEVEL post Zombie Apocalypse
I forgot to increase EDITLEVEL, as the Zombie Apocalypse added a timeout
routine, messing up saves and bones.
2020-11-04 11:36:52 +02:00
Pasi Kallinen
40648503b2 Increment EDITLEVEL due to safe_wait 2020-10-02 19:11:15 +03:00
nhmall
3cecb97da6 consolidate build status /patchlevel info settings in one place - patchlevel.h 2020-07-06 09:12:22 -04:00
nhmall
62d9c49338 fixes entry for removal of SYSFLAGS and MFLOPPY 2020-07-05 08:58:09 -04:00
PatR
8801ec34eb fix github pull request #355 - Sokoban cheating
Track sokoban cheating (taking actions that incur a luck penalty).
The pull request only reported the number of times (possibly zero)
that the player broke nethack's sokoban rules when reporting the
"you obtained the Sokoban prize" achievement, which is when the
count is most meaningful, but this implements it as a full-fledged
conduct instead.  This way the #conduct command can be used after
"creative nethacking" to check immediately whether an action has
violated the Sokoban rules so a player willing to put in a bit of
effort can eventually learn which actions have a negative impact.

The new conduct is only shown during games where the character has
entered the Sokoban branch, but once that has happened it gets shown
no matter the location at the time of #conduct or end of game.

Most of this wasn't in the pull request:  expanding the Guidebook to
give more information about sokoban and its conduct.

Bump EDITLEVEL to invalidate to-be-3.7 save files because u.uconduct
has been extended.

Fixes #355
2020-07-03 02:21:30 -07:00
PatR
a51e44e532 move lua context out of dungeons[]
and out of save files so restore doesn't need to clear stale data.
Behavior should be the same as before, except that when entering
the endgame branch and discarding the main dungeon and its other
branches, lua theme context is now discarded for those too.
2020-05-05 18:06:00 -07:00
PatR
b8da4e9294 amulet tiles
Replace the octagonal amulet placeholder for the two new tiles.
Give the "cubical amulet" a hint of being cube shaped and rename
"pentagonal amulet" to "perforated amulet" because it's easier to
draw that way.

Bump EDITLEVEL now for the extra objects and monsters because I
forgot to do so earlier.
2020-05-03 16:34:54 -07:00
PatR
e63fed627c obj->oextra->{omid,olong}
Change obj->oextra->omid from a usually-Null pointer field in
oextra to a simple 'unsigned' that doesn't need any allocation
beyond obj->oextra itself.  Value 0 means that it is not in use;
it is used to hold a monst.m_id and those are always non-zero.

Delete unused obj->oextra->olong.  'olong' used to be the last
field in struct obj, put there to force alignment of anything
which followed it back when obj structures were over-allocated to
append extra information.  It had a comment about being used for
temporary gold but whatever that was, temporary gold was gone long
before obj->oextra got introduced.

Bump EDITLEVEL since this invalidates existing 3.7 save files.

Remove a bunch of tabs from obj.h and save.c.
2020-04-24 09:29:52 -07:00
Pasi Kallinen
9b74ea0b22 Shaped and themed rooms
Allows creating shaped or themed rooms for the Dungeons of Doom
via lua script.

Invalidates bones and saves.

Makefiles updated for unix/linux by adding themerms.lua, but other
OSes need to have that added.
2020-04-18 19:55:09 +03:00
nhmall
2af37f44d4 Merge March 2020 changes into NetHack 3.7 2020-03-06 10:59:50 -05:00
nhmall
e20024e42b March 2020 updates 2020-03-06 10:31:51 -05:00
nhmall
abdd3254ae updates for 3.6 March 2020 2020-03-04 10:41:57 -05:00
PatR
804499d9be add some new, easier achievements
Introduce eight achievements that can be attained by more players.
 Entered Gnomish Mines  - self explanatory
 Entered Mine Town      - the town portion, not just the level
 Entered a shop         - any tended shop on any level
 Entered a temple       - likewise for temple
 Consulted the Oracle   - bought at least one major or minor oracle
 Read a Discworld Novel - read at least one passage
 Entered Sokoban        - like mines
 Entered the Big Room   - not always possible since not always present

The novel and bigroom ones aren't always achieveable since novels are
only guaranteed if a book or scroll shop gets created and bigroom is
only guaranteed in wizard mode.  No one ever claimed that every
possible achievement can be attained in a single game.  (If one for
entering the Fort Ludios level--or perhaps entering the Fort itself--
eventually gets add, that won't be possible in every game either.)

The mine town one probably needs some tweaking.  Two of the town's
seven variants have no town boundary (despite a rectangular area of
pre-defined map) and at present simply arriving on either of those
levels is enough to be credited with the entered-town achievement.

Bump EDITLEVEL because u.uachieved[] has increased in size.  This
time it has been expanded to the maximum that xlogfile's bitmask of
achievements can handle, enough for up to 9 more achievements without
another EDITLEVEL increment.
2020-02-12 14:35:37 -08:00
nhmall
1566063b4c bump editlevel
the code in pr298 altered the sound bit for one existing monster
2020-02-10 22:12:38 -05:00
PatR
d462bdffca redo achievement tracking
Instead of an assortment of bits, assign numeric indices to the
potential achievements and keep an array of those in the order they
were attained.  So disclosure might show the same subset occurring
differently in different games depending on the player's actions.
The encoded field in xlogfile doesn't care about that and remains
the same.

Modifies 'struct u', so EDITLEVEL has been incremented and existing
save files are invalidated.
2020-02-10 00:17:54 -08:00
PatR
fb05f30167 update EDITLEVEL for achievement tracking 2020-01-30 18:28:55 -08:00
PatR
ea8248e3c6 new 'mention_decor' option
Somewhat similar to 'mention_walls', 'mention_decor' is a way to
request additional feedback when moving around the map.  It reports
furniture or unusual terrain when you step on that.  Normally stepping
on furniture only mentions it when it is covered by object(s).  And
moving onto (rather than into) water or lava or ice doesn't bother
saying anything at all.  With the new option set there will be a
message.  It uses Norep so won't repeat when moving from one water
spot to another or one lava spot to another or one ice spot to another
unless there has been at least one intervening message.  There is also
a one-shot message when moving from water or lava or ice onto ordinary
terrain (not Norep, just once since there's no land to land message).

Having the verbose flag Off doesn't inhibit these new messages but it
does shorten them: "A fountain." instead of "There is a fountain here."

The Guidebook gets a new subsection "Movement feedback" of the "Rooms
and corridors" section and it covers more than just 'mention_decor'.
As usual, Guidebook.tex is untested.

'mention_decor' persists across save/restore, so 'struct flags' has
changed and EDITLEVEL is being bumped, hence save files are invalided.
2020-01-29 09:47:36 -08:00
nhmall
efd0911f89 Merge recent changes into NetHack-3.7 2020-01-27 16:49:31 -05:00
nhmall
4302b7404c more typo propagation 2020-01-27 12:56:34 -05:00
nhmall
3c968a09a3 Merge 'NetHack-3.6' updates into NetHack-3.7-Jan2020 2020-01-25 23:45:38 -05:00
nhmall
9e165b9e2a release prep bits 2020-01-25 23:42:36 -05:00
nhmall
97b74e6f7b Merge branch 'NetHack-3.7' into NetHack-3.7-Jan2020 2020-01-24 17:27:48 -05:00
PatR
0166239a22 simplify achievement tracking for special objects
This turned out to be a lot more work than I anticipated, but it is
definitely simpler (other than having #wizmakemap take achievements
away if you replace the level that contains the 'prize', which wasn't
handled before).

I cheated and made Mine's End into a no-bones level because the new
flagging scheme for luckstone, bag, and amulet can't carry over from
one game to another.  It probably should have been no-bones all along.
Sokoban didn't have this issue because it's already no-bones.

Existing save files are invalidated.
2020-01-24 13:54:23 -08:00
nhmall
36bb4334e8 Merge fixes from 'NetHack-3.6' into NetHack-3.7-Jan2020 2020-01-20 21:33:20 -05:00
nhmall
b6efb765dc update README and patchlevel.h 2020-01-20 16:58:12 -05:00
PatR
d19cab4d98 implicit_uncursed, mention_walls
Move 'implicit_uncursed' and 'mention_walls' from iflags to flags to
make their current setting persist across save/restore.  Invalidates
existing save files.
2020-01-17 04:03:14 -08:00
nhmall
d5174323eb Merge 'NetHack-3.6' updates into NetHack-3.7-Jan2020 2020-01-14 22:09:29 -05:00
nhmall
a6c46bbd85 housekeeping items for 3.6.5 - first pass 2020-01-14 11:35:06 -05:00
Patric Mueller
5267a50c7e Move enhance_tip into context and don't show tip if #enhance has been used before
Breaks save and bones compatibility.
2020-01-06 00:50:32 +01:00
nhmall
218cbe9ea6 2020 2020-01-01 10:12:16 -05:00
Pasi Kallinen
7e07cef197 Lua struct obj improvements
If the core frees the obj struct referred by lua, don't free it,
just mark it as OBJ_LUAFREE - lua will free it in gc once all
the references to it are gone.
2020-01-01 13:25:59 +02:00
nhmall
a4dfac2cec pull requests #174 and #128 for hallucinatory traps and autounlock
Pull requests:
hallucinatory traps
autounlock

This breaks existing save files.

Closes #174
Closes #228
2019-12-27 09:05:27 -05:00
Pasi Kallinen
6d8d3a9557 Add lua object references
Whenever a lua script references a core struct obj, increment a counter
in the obj struct. Core code will not free the obj, if there are any
lua references pointing to it, just makes it free-floating.
When lua script ends, the lua gc will free the free-floating objects.

Also exposes u.inventory to lua.

Breaks save and bones compat.
2019-12-26 19:15:24 +02:00