Re: How do I get started making a patch?



Ed_the_robot@xxxxxxxxx wrote:
Well, here it is: my first post to a Usenet group!

I have a few questions on making a patch:

Assuming I have no knowledge whatsoever on programming, how can I go
about making a patch that adds, say, a new class?

If that's too complex for a patching newbie, then how about several
monsters and a couple of new rooms?

You really need some knowledge about C coding before you can try
adding anything complex such as a new class. Adding a new special
room is easier, but still needs some code changes. Adding a new
monster is easiest of those three, if you're not adding new types
of attacks, resistances and whatnot.


Off the top of my head:


To add a new monster (only reusing existing abilities):

1. Edit src/monst.c to add the monster's data. The fields in the
gigantic array are described in include/permonst.h, and the
flags used in there are in include/monflag.h

2. Add a tile for the monster to win/share/monsters.txt




To add a new special room (like beehive and so on):

1. Edit inclde/mkroom.h and add the room number, like
#define MYROOM 14
_before_ the SHOPBASE definition, and renumbering the
room definitions that come after it.

2. Edit the levelflags struct in include/rm.h and add
Bitfield(has_myroom,1);
in it.

3. Edit check_special_room() in src/hack.c and add something
like this in there in the proper place:
case MYROOM:
You("enter a strange room!");
break;
and slightly later in the same function add something like
case MYROOM:
level.flags.has_myroom = 0;
break;

4. Edit clear_level_structures() in src/mklev.c adding
level.flags.has_myroom = 0;
somewhere near where the other lines like it are.

5. Also in src/mklev.c, near the end of makelevel(), add
something like this:
else if (u_depth > 11 && !rn2(6)) mkroom(MYROOM);
in the block where other lines like that are.
u_depth > 11 means that the dungeon level must be deeper
than 11 levels from top of dungeon and rn2(6) must be zero
before your level is created in the dungeon level.
rn2(6) returns a random value between 0 to 5, inclusive.

6. Edit mkroom() in src/mkroom.c, by adding a line like this:
case MYROOM: mkzoo(MYROOM); break;
near where there are lines like it.

7. (This is the part that requires most coding.)
Also in src/mkroom.c, edit fill_zoo() by adding cases
for your special room, so that it will get stocked with
monsters and whatever you want. Look how the other zoo-like
rooms are done in fill_zoo(). Also remember to add the
case MYROOM:
level.flags.has_myroom = 0;
break;
near the end of that function, where there are other lines like
that.

8. Edit dosounds() in src/sounds.c and add the ambient sounds when
a your room is on a level, for example:
if (level.flags.has_myroom && !rn2(400)) {
static const char * const myroom_msg[4] = {
"first random sound.",
"second random sound.",
"third random sound.",
"fourth, hallucinatory, random sound!",
};
You_hear(myroom_msg[rn2(3)+hallu]);
}

9. Edit fill_room() in src/sp_lev.c and add something like this:
case MYROOM:
level.flags.has_myroom = TRUE;
break;

10. Edit util/lev_main.c and add your room to the room_types array
for example adding a line like this in it:
{ "myroom", MYROOM },


....Hmmm, I think that's it, unless I forget something.
Not much explanations in there, but I think that shows how easy it is =)


Adding a new class is much, much more complex.


--
Pasi Kallinen
paxed@xxxxxxx
http://bilious.homelinux.org/ -- NetHack Patch Database
.



Relevant Pages

  • Re: ActiveX & KB:912945
    ... I use a proprietary web tool to perform HTML edits for a site, ... Our main edit ... cumulative patch, ... happen before installation of the 912945 patch, ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Binary "Database" for a game - please help
    ... > easily create an editor to edit the records in this file, ... > regarding that specific monster. ... > text boxes as I browsed through them. ... > binary files, but that's about it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [9fans] Patch notification emails
    ... > often are not verbatim copies of what was in the patch. ... > I probably edit at least half of the incoming patch code ...
    (comp.os.plan9)
  • Re: [ANN] XPN 1.0.0 released
    ... Here's the DIY method: ... You can apply these changes with a "patch" command, or edit xpn.py by ...
    (news.software.readers)
  • Re: [PATCH] forcedeth: disable irq at first before schedule rx
    ... Impact: clean up ... schedule it later after disable it. ... I had to edit this patch to make it apply properly. ...
    (Linux-Kernel)