objclass.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)objclass.h 3.4     1996/06/16      */
00002 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef OBJCLASS_H
00006 #define OBJCLASS_H
00007 
00008 /* definition of a class of objects */
00009 
00010 struct objclass {
00011         short   oc_name_idx;            /* index of actual name */
00012         short   oc_descr_idx;           /* description when name unknown */
00013         char *  oc_uname;               /* called by user */
00014         Bitfield(oc_name_known,1);
00015         Bitfield(oc_merge,1);   /* merge otherwise equal objects */
00016         Bitfield(oc_uses_known,1); /* obj->known affects full decription */
00017                                 /* otherwise, obj->dknown and obj->bknown */
00018                                 /* tell all, and obj->known should always */
00019                                 /* be set for proper merging behavior */
00020         Bitfield(oc_pre_discovered,1);  /* Already known at start of game; */
00021                                         /* won't be listed as a discovery. */
00022         Bitfield(oc_magic,1);   /* inherently magical object */
00023         Bitfield(oc_charged,1); /* may have +n or (n) charges */
00024         Bitfield(oc_unique,1);  /* special one-of-a-kind object */
00025         Bitfield(oc_nowish,1);  /* cannot wish for this object */
00026 
00027         Bitfield(oc_big,1);
00028 #define oc_bimanual     oc_big  /* for weapons & tools used as weapons */
00029 #define oc_bulky        oc_big  /* for armor */
00030         Bitfield(oc_tough,1);   /* hard gems/rings */
00031 
00032         Bitfield(oc_dir,2);
00033 #define NODIR           1       /* for wands/spells: non-directional */
00034 #define IMMEDIATE       2       /*                   directional */
00035 #define RAY             3       /*                   zap beams */
00036 
00037 #define PIERCE          1       /* for weapons & tools used as weapons */
00038 #define SLASH           2       /* (latter includes iron ball & chain) */
00039 #define WHACK           0
00040 
00041         /*Bitfield(oc_subtyp,3);*/      /* Now too big for a bitfield... see below */
00042 
00043         Bitfield(oc_material,5);
00044 #define LIQUID          1       /* currently only for venom */
00045 #define WAX             2
00046 #define VEGGY           3       /* foodstuffs */
00047 #define FLESH           4       /*   ditto    */
00048 #define PAPER           5
00049 #define CLOTH           6
00050 #define LEATHER         7
00051 #define WOOD            8
00052 #define BONE            9
00053 #define DRAGON_HIDE     10      /* not leather! */
00054 #define IRON            11      /* Fe - includes steel */
00055 #define METAL           12      /* Sn, &c. */
00056 #define COPPER          13      /* Cu - includes brass */
00057 #define SILVER          14      /* Ag */
00058 #define GOLD            15      /* Au */
00059 #define PLATINUM        16      /* Pt */
00060 #define MITHRIL         17
00061 #define PLASTIC         18
00062 #define GLASS           19
00063 #define GEMSTONE        20
00064 #define MINERAL         21
00065 
00066 #define is_organic(otmp)        (objects[otmp->otyp].oc_material <= WOOD)
00067 #define is_metallic(otmp)       (objects[otmp->otyp].oc_material >= IRON && \
00068                                  objects[otmp->otyp].oc_material <= MITHRIL)
00069 
00070 /* primary damage: fire/rust/--- */
00071 /* is_flammable(otmp), is_rottable(otmp) in mkobj.c */
00072 #define is_rustprone(otmp)      (objects[otmp->otyp].oc_material == IRON)
00073 
00074 /* secondary damage: rot/acid/acid */
00075 #define is_corrodeable(otmp)    (objects[otmp->otyp].oc_material == COPPER || objects[otmp->otyp].oc_material == IRON)
00076 
00077 #define is_damageable(otmp) (is_rustprone(otmp) || is_flammable(otmp) || \
00078                                 is_rottable(otmp) || is_corrodeable(otmp))
00079 
00080         schar   oc_subtyp;
00081 #define oc_skill        oc_subtyp   /* Skills of weapons, spellbooks, tools, gems */
00082 #define oc_armcat       oc_subtyp   /* for armor */
00083 #define ARM_SHIELD      1       /* needed for special wear function */
00084 #define ARM_HELM        2
00085 #define ARM_GLOVES      3
00086 #define ARM_BOOTS       4
00087 #define ARM_CLOAK       5
00088 #define ARM_SHIRT       6
00089 #define ARM_SUIT        0
00090 
00091         uchar   oc_oprop;               /* property (invis, &c.) conveyed */
00092         char    oc_class;               /* object class */
00093         schar   oc_delay;               /* delay when using such an object */
00094         uchar   oc_color;               /* color of the object */
00095 
00096         short   oc_prob;                /* probability, used in mkobj() */
00097         unsigned short  oc_weight;      /* encumbrance (1 cn = 0.1 lb.) */
00098         short   oc_cost;                /* base cost in shops */
00099 /* Check the AD&D rules!  The FIRST is small monster damage. */
00100 /* for weapons, and tools, rocks, and gems useful as weapons */
00101         schar   oc_wsdam, oc_wldam;     /* max small/large monster damage */
00102         schar   oc_oc1, oc_oc2;
00103 #define oc_hitbon       oc_oc1          /* weapons: "to hit" bonus */
00104 
00105 #define a_ac            oc_oc1  /* armor class, used in ARM_BONUS in do.c */
00106 #define a_can           oc_oc2          /* armor: used in mhitu.c */
00107 #define oc_level        oc_oc2          /* books: spell level */
00108 
00109         unsigned short  oc_nutrition;   /* food value */
00110 };
00111 
00112 struct objdescr {
00113         const char *oc_name;            /* actual name */
00114         const char *oc_descr;           /* description when name unknown */
00115 };
00116 
00117 extern NEARDATA struct objclass objects[];
00118 extern NEARDATA struct objdescr obj_descr[];
00119 
00120 /*
00121  * All objects have a class. Make sure that all classes have a corresponding
00122  * symbol below.
00123  */
00124 #define RANDOM_CLASS     0      /* used for generating random objects */
00125 #define ILLOBJ_CLASS     1
00126 #define WEAPON_CLASS     2
00127 #define ARMOR_CLASS      3
00128 #define RING_CLASS       4
00129 #define AMULET_CLASS     5
00130 #define TOOL_CLASS       6
00131 #define FOOD_CLASS       7
00132 #define POTION_CLASS     8
00133 #define SCROLL_CLASS     9
00134 #define SPBOOK_CLASS    10      /* actually SPELL-book */
00135 #define WAND_CLASS      11
00136 #define COIN_CLASS      12
00137 #define GEM_CLASS       13
00138 #define ROCK_CLASS      14
00139 #define BALL_CLASS      15
00140 #define CHAIN_CLASS     16
00141 #define VENOM_CLASS     17
00142 #define MAXOCLASSES     18
00143 
00144 #define ALLOW_COUNT     (MAXOCLASSES+1) /* Can be used in the object class */
00145 #define ALL_CLASSES     (MAXOCLASSES+2) /* input to getobj().              */
00146 #define ALLOW_NONE      (MAXOCLASSES+3) /*                                 */
00147 
00148 #define BURNING_OIL     (MAXOCLASSES+1) /* Can be used as input to explode. */
00149 #define MON_EXPLODE     (MAXOCLASSES+2) /* Exploding monster (e.g. gas spore) */
00150 
00151 #if 0   /* moved to decl.h so that makedefs.c won't see them */
00152 extern const char def_oc_syms[MAXOCLASSES];     /* default class symbols */
00153 extern uchar oc_syms[MAXOCLASSES];              /* current class symbols */
00154 #endif
00155 
00156 /* Default definitions of all object-symbols (must match classes above). */
00157 
00158 #define ILLOBJ_SYM      ']'     /* also used for mimics */
00159 #define WEAPON_SYM      ')'
00160 #define ARMOR_SYM       '['
00161 #define RING_SYM        '='
00162 #define AMULET_SYM      '"'
00163 #define TOOL_SYM        '('
00164 #define FOOD_SYM        '%'
00165 #define POTION_SYM      '!'
00166 #define SCROLL_SYM      '?'
00167 #define SPBOOK_SYM      '+'
00168 #define WAND_SYM        '/'
00169 #define GOLD_SYM        '$'
00170 #define GEM_SYM         '*'
00171 #define ROCK_SYM        '`'
00172 #define BALL_SYM        '0'
00173 #define CHAIN_SYM       '_'
00174 #define VENOM_SYM       '.'
00175 
00176 struct fruit {
00177         char fname[PL_FSIZ];
00178         int fid;
00179         struct fruit *nextf;
00180 };
00181 #define newfruit() (struct fruit *)alloc(sizeof(struct fruit))
00182 #define dealloc_fruit(rind) free((genericptr_t) (rind))
00183 
00184 #define OBJ_NAME(obj)  (obj_descr[(obj).oc_name_idx].oc_name)
00185 #define OBJ_DESCR(obj) (obj_descr[(obj).oc_descr_idx].oc_descr)
00186 #endif /* OBJCLASS_H */