Source:Objclass.h

The objclass.h file contains C-language declarations for objects. It is a header file and part of the source code for NetHack 3.4.3.

Top of file
/*     SCCS Id: @(#)objclass.h 3.4     1996/06/16      */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */


 * 1) ifndef OBJCLASS_H
 * 2) define OBJCLASS_H

/* definition of a class of objects */

struct objclass
struct objclass { short  oc_name_idx;            /* index of actual name */ short  oc_descr_idx;           /* description when name unknown */ char * oc_uname;               /* called by user */ Bitfield(oc_name_known,1); Bitfield(oc_merge,1);  /* merge otherwise equal objects */ Bitfield(oc_uses_known,1); /* obj->known affects full decription */ /* otherwise, obj->dknown and obj->bknown */ /* tell all, and obj->known should always */ /* be set for proper merging behavior */ Bitfield(oc_pre_discovered,1); /* Already known at start of game; */ /* won't be listed as a discovery. */       Bitfield(oc_magic,1);   /* inherently magical object */ Bitfield(oc_charged,1); /* may have +n or (n) charges */ Bitfield(oc_unique,1); /* special one-of-a-kind object */ Bitfield(oc_nowish,1); /* cannot wish for this object */

Bitfield(oc_big,1); Bitfield(oc_tough,1);  /* hard gems/rings */
 * 1) define oc_bimanual    oc_big  /* for weapons & tools used as weapons */
 * 2) define oc_bulky       oc_big  /* for armor */

Bitfield(oc_dir,2);
 * 1) define NODIR          1       /* for wands/spells: non-directional */
 * 2) define IMMEDIATE      2       /*                   directional */
 * 3) define RAY            3       /*                   zap beams */


 * 1) define PIERCE         1       /* for weapons & tools used as weapons */
 * 2) define SLASH          2       /* (latter includes iron ball & chain) */
 * 3) define WHACK          0

/*Bitfield(oc_subtyp,3);*/     /* Now too big for a bitfield... see below */

Bitfield(oc_material,5);
 * 1) define LIQUID         1       /* currently only for venom */
 * 2) define WAX            2
 * 3) define VEGGY          3       /* foodstuffs */
 * 4) define FLESH          4       /*   ditto    */
 * 5) define PAPER          5
 * 6) define CLOTH          6
 * 7) define LEATHER        7
 * 8) define WOOD           8
 * 9) define BONE           9
 * 10) define DRAGON_HIDE    10      /* not leather! */
 * 11) define IRON           11      /* Fe - includes steel */
 * 12) define METAL          12      /* Sn, &c. */
 * 13) define COPPER         13      /* Cu - includes brass */
 * 14) define SILVER         14      /* Ag */
 * 15) define GOLD           15      /* Au */
 * 16) define PLATINUM       16      /* Pt */
 * 17) define MITHRIL        17
 * 18) define PLASTIC        18
 * 19) define GLASS          19
 * 20) define GEMSTONE       20
 * 21) define MINERAL        21

objects[otmp->otyp].oc_material <= MITHRIL)
 * 1) define is_organic(otmp)       (objects[otmp->otyp].oc_material <= WOOD)
 * 2) define is_metallic(otmp)      (objects[otmp->otyp].oc_material >= IRON && \

/* primary damage: fire/rust/--- */ /* is_flammable(otmp), is_rottable(otmp) in mkobj.c */
 * 1) define is_rustprone(otmp)     (objects[otmp->otyp].oc_material == IRON)

/* secondary damage: rot/acid/acid */
 * 1) define is_corrodeable(otmp)   (objects[otmp->otyp].oc_material == COPPER || objects[otmp->otyp].oc_material == IRON)

is_rottable(otmp) || is_corrodeable(otmp))
 * 1) define is_damageable(otmp) (is_rustprone(otmp) || is_flammable(otmp) || \

schar  oc_subtyp;
 * 1) define oc_skill       oc_subtyp   /* Skills of weapons, spellbooks, tools, gems */
 * 2) define oc_armcat      oc_subtyp   /* for armor */
 * 3) define ARM_SHIELD     1       /* needed for special wear function */
 * 4) define ARM_HELM       2
 * 5) define ARM_GLOVES     3
 * 6) define ARM_BOOTS      4
 * 7) define ARM_CLOAK      5
 * 8) define ARM_SHIRT      6
 * 9) define ARM_SUIT       0

uchar  oc_oprop;               /* property (invis, &c.) conveyed */ char   oc_class;               /* object class */ schar  oc_delay;               /* delay when using such an object */ uchar  oc_color;               /* color of the object */

short  oc_prob;                /* probability, used in mkobj */ unsigned short oc_weight;      /* encumbrance (1 cn = 0.1 lb.) */ short  oc_cost;                /* base cost in shops */ /* Check the AD&D rules! The FIRST is small monster damage. */ /* for weapons, and tools, rocks, and gems useful as weapons */ schar  oc_wsdam, oc_wldam;     /* max small/large monster damage */ schar  oc_oc1, oc_oc2;
 * 1) define oc_hitbon      oc_oc1          /* weapons: "to hit" bonus */


 * 1) define a_ac           oc_oc1  /* armor class, used in ARM_BONUS in do.c */
 * 2) define a_can          oc_oc2          /* armor: used in mhitu.c */
 * 3) define oc_level       oc_oc2          /* books: spell level */

unsigned short oc_nutrition;   /* food value */ };

object descriptions
struct objdescr { const char *oc_name;           /* actual name */ const char *oc_descr;          /* description when name unknown */ };

extern NEARDATA struct objclass objects[]; extern NEARDATA struct objdescr obj_descr[];

object classes
/* * All objects have a class. Make sure that all classes have a corresponding * symbol below. */
 * 1) define RANDOM_CLASS    0      /* used for generating random objects */
 * 2) define ILLOBJ_CLASS    1
 * 3) define WEAPON_CLASS    2
 * 4) define ARMOR_CLASS     3
 * 5) define RING_CLASS      4
 * 6) define AMULET_CLASS    5
 * 7) define TOOL_CLASS      6
 * 8) define FOOD_CLASS      7
 * 9) define POTION_CLASS    8
 * 10) define SCROLL_CLASS    9
 * 11) define SPBOOK_CLASS   10      /* actually SPELL-book */
 * 12) define WAND_CLASS     11
 * 13) define COIN_CLASS     12
 * 14) define GEM_CLASS      13
 * 15) define ROCK_CLASS     14
 * 16) define BALL_CLASS     15
 * 17) define CHAIN_CLASS    16
 * 18) define VENOM_CLASS    17
 * 19) define MAXOCLASSES    18


 * 1) define ALLOW_COUNT    (MAXOCLASSES+1) /* Can be used in the object class */
 * 2) define ALL_CLASSES    (MAXOCLASSES+2) /* input to getobj.              */
 * 3) define ALLOW_NONE     (MAXOCLASSES+3) /*                                 */


 * 1) define BURNING_OIL    (MAXOCLASSES+1) /* Can be used as input to explode. */
 * 2) define MON_EXPLODE    (MAXOCLASSES+2) /* Exploding monster (e.g. gas spore) */

extern const char def_oc_syms[MAXOCLASSES];    /* default class symbols */ extern uchar oc_syms[MAXOCLASSES];             /* current class symbols */
 * 1) if 0  /* moved to decl.h so that makedefs.c won't see them */
 * 1) endif

/* Default definitions of all object-symbols (must match classes above). */


 * 1) define ILLOBJ_SYM     ']'     /* also used for mimics */
 * 2) define WEAPON_SYM     ')'
 * 3) define ARMOR_SYM      '['
 * 4) define RING_SYM       '='
 * 5) define AMULET_SYM     '"'
 * 6) define TOOL_SYM       '('
 * 7) define FOOD_SYM       '%'
 * 8) define POTION_SYM     '!'
 * 9) define SCROLL_SYM     '?'
 * 10) define SPBOOK_SYM     '+'
 * 11) define WAND_SYM       '/'
 * 12) define GOLD_SYM       '$'
 * 13) define GEM_SYM        '*'
 * 14) define ROCK_SYM       '`'
 * 15) define BALL_SYM       '0'
 * 16) define CHAIN_SYM      '_'
 * 17) define VENOM_SYM      '.'

user-defineable fruit data
struct fruit { char fname[PL_FSIZ]; int fid; struct fruit *nextf; };
 * 1) define newfruit (struct fruit *)alloc(sizeof(struct fruit))
 * 2) define dealloc_fruit(rind) free((genericptr_t) (rind))

object name and description macros

 * 1) define OBJ_NAME(obj) (obj_descr[(obj).oc_name_idx].oc_name)
 * 2) define OBJ_DESCR(obj) (obj_descr[(obj).oc_descr_idx].oc_descr)