Source-editing tutorials?

G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

I know, check the source-diving guide.. But is anyone else interested
in making a series of example files for EVERYTHING needed to add
something? (EX: Everything needed for a new monster, item, class,
level, item class, command.. et cetera.)
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

Yeah, you kinda forgot about adding the tile-definitions, the
description (Yes, I know how already.), et cetera. It's not just addin'
on in.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

On 2005-02-19, Arcane Cossack <arcanecossack@gmail.com> wrote:
> I know, check the source-diving guide.. But is anyone else interested
> in making a series of example files for EVERYTHING needed to add
> something? (EX: Everything needed for a new monster, item, class,
> level, item class, command.. et cetera.)

well some of these are pretty trivial-- i.e. for a new monster,
you just add an entry to monst.c, with the MON macro..
Im pretty sure (but have never tried) that adding an item is just
a matter of making an appropriate entry in objects.c

The others are slightly more invovled and some examples could be
useful...

--
Andrew D. Hilton
UPenn Phd Student
 

nephi

Distinguished
Jul 2, 2001
4
0
18,510
Archived from groups: rec.games.roguelike.nethack (More info?)

"Arcane Cossack" <arcanecossack@gmail.com> wrote in
news:1108833070.669191.67500@f14g2000cwb.googlegroups.com:

> I know, check the source-diving guide.. But is anyone else interested
> in making a series of example files for EVERYTHING needed to add
> something? (EX: Everything needed for a new monster, item, class,
> level, item class, command.. et cetera.)
>

Here's a write up I did a while ago for creating a new role:

How to Implement a New Role in Nethack

This is a short description of the absolute minimum you must do to
implement a new character role in Nethack 3.4.3. Once you've done the
minimum, you'll probably want to do more in order to further
differentiate your role. All of this assumes you are comfortable
modifying and compiling the code.

You must modify the following files:
artilist.h
attrib.c
monst.c
role.c
u_init.c
quest.txt

You must create the following file:
myrole.des (where you replace 'myrole' with your role's name of course)

-----

artilist.h

Adding the new role's quest artifact

Find the list of the other quest artifacts starting with this comment:
/*
* The artifacts for the quest dungeon, all self-willed.
*/

Stick your artifact where your role goes alphabetically. Use the A macro
defined at the top of the file.

Example: Monk quest artifact

A("The Eyes of the Overworld", LENSES,
(SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL|SPFX_XRAY), 0, 0,
NO_ATTK, NO_DFNS, CARY(AD_MAGM),
ENLIGHTENING, A_NEUTRAL, PM_MONK, NON_PM, 2500L ),

Description of fields in order:

Name: obvious

Base type: The type of object that the artifact is a special instance of

Artifact flags 1: See artifact.h for a list of these. As a minimum you
should have SPFX_NOGEN|SPFX_RESTR|SPFX_INTEL. Also put here special
effects from wearing/wielding the item, e.g. SPFX_XRAY means that the
player gets X-ray vision while wearing The Eyes of the Overworld.

Artifacts flags 2: More flags. Put here any effects you get just from
having the item in your inventory. For example, The Eye of Aethiopica has
SPFX_EREGEN in this field so you get power regeneration just from holding
it.

Monster type: If the artifact is attuned to attack a specific monster or
race, it goes here. Example: Dragonbane has S_DRAGON in this field, and
Demonbane has M2_DEMON.

Attack: If your artifact is a weapon this is where you put its attack
bonuses. Use one of the macros at the top of artilist.h. Example: PHYS
(3,6) means that your weapon has a d3 bonus to hit and a d6 bonus to
damage. FIRE(5,0) means that your weapon does fire damage (like Fire
Brand) and has a d5 bonus to hit and does double damage (0 means double).

Defense: If your artifact gives a special defense when wielding/wearing,
mark it here. Example: Magicbane has DFNS(AD_MAGM).

Carry: Put any defenses gained from carrying the artifact here. Example:
The Mitre of Holiness has CARY(AD_FIRE).

Invoke: What the artifact does when invoked. Example: The Heart of
Ahriman has LEVITATION in this field. If you want an invocation power
that doesn't currently exist, do this:
1. Add a new #define at the end of artifact.h. ( #define MY_INVOKE
(LAST_PROP+10) )
2. Add a new case to the big switch block in the arti_invoke
function in artifact.c.
case MY_INVOKE:
whatever();
break;

Alignment: The default alignment of your new role. If this role can
choose more than one alignment, don't put more than one alignment! The
artifact will automatically be adjusted to the player's alignment when
the game is initialized.

Role: PM_MYROLE

Race: If you artifact is also tuned to a specific race, mark it here.
Example: Sting has PM_ELF here.

Cost: Base cost

-----

attrib.c

Adding experience level associated intrinsics

Find the list of role based intrinsics near the top. Insert a new entry
for your role. Name it something like myrole_abil.

Example Barbarian:

bar_abil[] = { { 1, &(HPoison_resistance), "", "" },
{ 7, &(HFast), "quick", "slow" },
{ 15, &(HStealth), "stealthy", "" },
{ 0, 0, 0, 0 } },


This means that at level 1, Barbarians have poison resistance. No
messages are associated with intrinsics at level 1 (obviously). At level
7 they gain Speed. The message given is "You feel quick!". If they lose
this ability due to level drain the message given is "You feel slow!". At
level 15 they get Stealth with the message "You feel stealthy!". The loss
message is not specified which means that it defaults to "You feel less
stealthy!".
Don't forget the array terminator! { 0, 0, 0, 0 } }

Now go to the adjabil function near the bottom of the file. Inside the
switch block add your role:

case PM_MYROLE: abil = myrole_abil; break;

-----

monst.c

There are four new monsters that you must define: a "character class"
monster, the Quest Leader, the Quest Nemesis, and the Quest Guardian.
(I'm not going to give all the details for creating new monsters here.)

Go down to near the bottom of the file and find this comment:
/*
* character classes
*/
Add a character class monster in the correct place alphabetically. Don't
forget to put in any level 1 intrinsics, e.g. MR_POISON for healers. The
name of the monster is the same as the name of your role. If your role
has a different name for female versions (e.g. priests and priestesses),
you must make two character monster types.

Just below this section is the Quest Leader section. Add your Quest
Leader in the right spot. Since the QL is usually a tough version of your
role, be sure to give him/her/it the intrinsics a high level character of
your role would have.

Next you will find the Quest Nemeses. Add yours here. The monk's QN,
Master Kaen, is generally considered the toughest one of all, so you
probably shouldn't make yours tougher than him.

Finally add the Quest Guardian monster. These guys are basically the same
as the character class monster but a few levels higher (level 5).

-----

role.c

Adding the basic role definition

At the top of this file is the array of role definitions. Add yours in
the correct alphabetical order. Exception: If your new role begins with
the same letter as an existing role, you should probably add yours AFTER
the existing one. That way in the role selection menu, the existing role
will be selected with a lower case letter and your new one with an upper
case letter. If there are already two roles that start with your role's
letter, you'll have to modify the menu code.

Explanation of role structure:
Example Knight:

{ {"Knight", 0}, {
{"Gallant", 0},
{"Esquire", 0},
{"Bachelor", 0},
{"Sergeant", 0},
{"Knight", 0},
{"Banneret", 0},
{"Chevalier", "Chevaliere"},
{"Seignieur", "Dame"},
{"Paladin", 0} },
"Lugh", "_Brigit", "Manannan Mac Lir", /* Celtic */
"Kni", "Camelot Castle", "the Isle of Glass",
PM_KNIGHT, NON_PM, PM_PONY,
PM_KING_ARTHUR, PM_PAGE, PM_IXOTH,
PM_QUASIT, PM_OCHRE_JELLY, S_IMP, S_JELLY,
ART_MAGIC_MIRROR_OF_MERLIN,
MH_HUMAN | ROLE_MALE|ROLE_FEMALE | ROLE_LAWFUL,
/* Str Int Wis Dex Con Cha */
{ 13, 7, 14, 8, 10, 17 },
{ 30, 15, 15, 10, 20, 10 },
/* Init Lower Higher */
{ 14, 0, 0, 8, 2, 0 }, /* Hit points */
{ 1, 4, 0, 1, 0, 2 },10, /* Energy */
10, 8,-2, 0, 9, A_WIS, SPE_TURN_UNDEAD, -4
},

Explanation of fields in order:

Name of role: First the male version, then the female if it is different
(0 otherwise).

Rank titles: There are nine of these. As with the role name, there are
male and female versions.

Deities: Their order is Lawful, Neutral, Chaotic. If the god is a
goddess, prepend an underscore to her name.

Three letter abbreviation for your role: Usually the first three letters
of the name.

Name of the Quest home level

Name of the Quest locate level

Character (male) monster type: This is the (male) character class monster
defined in monst.c.

Character (female) monster type: This is the female character class
monster, if it is different than the male one, otherwise NON_PM.

Preferred pet type: e.g. PM_PONY for knights. Specify PM_NON if defaults
should be used.

Quest Leader, Quest Guardian, Quest Nemesis: as defined in monst.c.

Quest Enemy 1, 2: Specific quest enemies, e.g. PM_BUGBEAR (NON_PM if
random).

Quest Enemy Symbol 1, 2: Quest enemies by class (e.g. S_SNAKE).

Quest Artifact

Role flags: Allowed races, alignments and genders. See you.h.

Base Attributes: Lowest initial attributes.

Attribute Distribution: Distribution of initial attributes. A higher
number means points are more likely to be allocated to that attribute.

Hitpoint advancement: {a,b,c,d,e,f}. a is the fixed number of hitpoints
you start out with, b is a random modifer. c is the fixed number you gain
at "low" levels, d the random modifier. e is the fixed number you gain at
"high" levels, f the random modifier.

Power advancement: Same meaning as with hitpoints.

Cutoff xp level: The level at which you become "high" level.

Spelbase: Base penalty for casting spells.
Spelheal: Penalty (or negative for bonus) for casting "emergency" spells.
Spelshld: Penalty for wearing any shield
Spelarmr: Penalty for wearing metal armor
Spelstat: Which stat (A_) is used for spellcasting
Spelspec: Spell (SPE_) the role excels at
Spelsbon: Penalty (- for bonus) for that spell

In general, look to existing roles for examples of what values to give
your new role.

If your role has a special hello or goodbye message (e.g. Aloha for
tourists) change the Hello and Goodbye functions at the bottom of the
file.

-----

u_init.c

Defining your role's starting inventory

At the top of this file you will find the initial inventory array. Add
your entry in the appropriate place.
Examples are the best way to explain how to make an entry:

{ MACE, 1, WEAPON_CLASS, 1, 1 }
One blessed +1 Mace

{ BULLWHIP, 2, WEAPON_CLASS, 1, UNDEF_BLESS }
One +2 bullwhip randomly blessed or uncursed.

{ FOOD_RATION, 0, FOOD_CLASS, 3, 0 }
Three uncursed food rations

{ UNDEF_TYP, UNDEF_SPE, WAND_CLASS, 1, UNDEF_BLESS }
One random wand with random charges randomly blessed or uncursed.

Define your role's max weapon and spell skill levels. These are the
structs that look like this:
static const struct def_skill Skill_Mon[] = {
{ P_QUARTERSTAFF, P_BASIC }, { P_SPEAR, P_BASIC },
{ P_JAVELIN, P_BASIC }, { P_CROSSBOW, P_BASIC },
{ P_SHURIKEN, P_BASIC },
{ P_ATTACK_SPELL, P_BASIC }, { P_HEALING_SPELL, P_EXPERT },
{ P_DIVINATION_SPELL, P_BASIC },{ P_ENCHANTMENT_SPELL, P_BASIC },
{ P_CLERIC_SPELL, P_SKILLED }, { P_ESCAPE_SPELL, P_BASIC },
{ P_MATTER_SPELL, P_BASIC },
{ P_MARTIAL_ARTS, P_GRAND_MASTER },
{ P_NONE, 0 }
};
It's pretty self explanatory.

Now go to the u_init function halfway down. Find the role-based switch
block. Here is where you can further specialize the starting inventory.
At the very least you need this:

case PM_MYROLE:
ini_inv(Myrole);
skill_init(Skill_Myrole);
break;

But you'll probably want to customize it a bit more. Look at the other
roles for examples and ideas. For instance, if you want your role to have
a 20% chance of starting with a lamp, add this line:
if(!rn2(10)) ini_inv(Lamp);

If you want to randomize the quantity of a particular item try this:
Back in the initial inventory struct put a #define like this:

static struct trobj Myrole[] = {
#define MYC_SHURIKEN 0 /* index */
{ SHURIKEN, 0, WEAPON_CLASS, 10, UNDEF_BLESS }, /* quan is variable
*/

now in u_init()
Myrole[MYC_SHURIKEN].trquan = rn1(10, 5);
Make sure you do this before you call ini_inv(Myrole), otherwise it will
have no effect.

One more thing in role.c: Go down a little farther to
restricted_spell_discipline(). Add your role to the switch block:
case PM_MYROLE: skills = Skill_Myrole; break;

-----

quest.txt [in the dat directory]

This is the file that defines all Quest related text. Your best bet is to
look at the other roles and build yours by judicious cutting and pasting.
At the bottom of the file you can the meanings of all the control
characters (%c, %H etc.)

-----

myrole.des [in the dat directory]

You also need to make a .des file to define the layout of all the quest
levels. I won't go into how to make levels here. Again, look at the des
files of other roles for examples and inspiration.

-----

--
Nephi
"You are covered with rice."
Check out my patches at http://www.geocities.com/zindorsky
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

> well some of these are pretty trivial-- i.e. for a new monster,
> you just add an entry to monst.c, with the MON macro..
> Im pretty sure (but have never tried) that adding an item is just
> a matter of making an appropriate entry in objects.c

Don't forget the tiles for the Qt port.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

Martin Read wrote:

> My approach in producing a Nethack variant would be "Graphical ports can
> are not supported; IANA graphical artist. If you want pictures of the
> new monsters, find someone who is and get them to draw you some."
>
> If I was feeling *really generous*, the new stuff would get placeholder
> tiles consisting of the appopriate ascii character in the appropriate
> colour.

If I *were* a graphic artist, and I were to design a NetHack tile set,
that's what mine would look like (although I'd include DEC/IBM style line
drawing tiles, and I might introduce a few minor variants to distinguish
some items that currently look alike).

--
Benjamin Lewis

I regret to say that we of the FBI are powerless to act in cases of
oral-genital intimacy, unless it has in some way obstructed interstate
commerce. -- J. Edgar Hoover
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

Benjamin Schieder <blindcoder@scavenger.homeip.net> wrote:
>Don't forget the tiles for the Qt port.

My approach in producing a Nethack variant would be "Graphical ports can
are not supported; IANA graphical artist. If you want pictures of the
new monsters, find someone who is and get them to draw you some."

If I was feeling *really generous*, the new stuff would get placeholder
tiles consisting of the appopriate ascii character in the appropriate
colour.
--
Martin Read - my opinions are my own. share them if you wish.
My roguelike games page (including my BSD-licenced roguelike) can be found at:
http://www.chiark.greenend.org.uk/~mpread/roguelikes.html
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

"Arcane Cossack" <arcanecossack@gmail.com> wrote in
news:1108833070.669191.67500@f14g2000cwb.googlegroups.com:

> I know, check the source-diving guide.. But is anyone else interested
> in making a series of example files for EVERYTHING needed to add
> something? (EX: Everything needed for a new monster, item, class,
> level, item class, command.. et cetera.)
>

I made this one a few months ago. It has some errors (it's only version
0.1), but on the large scale, it's correct:

http://terpy.net/nethack-add-monster-v0.1.html

--
~ Cyde Weys ~
So say we all.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

Seraphim wrote:

> Didn't someone do this a while ago? That is, didn't someone produce a
> tile set where all the monsters were represented by Ascii letters of the
> correct color, but with small differences that allowed one to tell
> something like a mind flayer, and a master mind flayer appart?

I think someone made an ASCII tileset for noegnud; I'm not sure if they made
these differences or not.

A few other differences I'd like to see might be to distinguish between
useful and less useful items, e.g. bags vs. leashes, keys vs. tin openers,
etc., for those occasions when one is, say, desperately searching for a
sack.

I'd prefer to readily distinguish a dwarf lord from a mind flayer than I
would a MF from a MMF.

--
Benjamin Lewis

I regret to say that we of the FBI are powerless to act in cases of
oral-genital intimacy, unless it has in some way obstructed interstate
commerce. -- J. Edgar Hoover
 

seraphim

Distinguished
Mar 27, 2003
184
0
18,680
Archived from groups: rec.games.roguelike.nethack (More info?)

Benjamin Lewis <bclewis@cs.sfu.ca> wrote in
news:yy7or7j9hkbm.fsf@marge.cs.sfu.ca:

> Martin Read wrote:
>
>> My approach in producing a Nethack variant would be "Graphical
>> ports can are not supported; IANA graphical artist. If you want
>> pictures of the new monsters, find someone who is and get them to
>> draw you some."
>>
>> If I was feeling *really generous*, the new stuff would get
>> placeholder tiles consisting of the appopriate ascii character in
>> the appropriate colour.
>
> If I *were* a graphic artist, and I were to design a NetHack tile
> set, that's what mine would look like (although I'd include DEC/IBM
> style line drawing tiles, and I might introduce a few minor variants
> to distinguish some items that currently look alike).

Didn't someone do this a while ago? That is, didn't someone produce a
tile set where all the monsters were represented by Ascii letters of the
correct color, but with small differences that allowed one to tell
something like a mind flayer, and a master mind flayer appart?
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

begin quoting Seraphim <gme6@cornell.edu>:
>Didn't someone do this a while ago? That is, didn't someone produce a
>tile set where all the monsters were represented by Ascii letters of the
>correct color, but with small differences that allowed one to tell
>something like a mind flayer, and a master mind flayer appart?

Yes, and it's very impressive.

http://www.olywa.net/cook/nhack.htm is the site.
--
David Damerell <damerell@chiark.greenend.org.uk> flcl?
Today is Leicesterday, February.