Source:NetHack 3.6.1/include/objclass.h

From NetHackWiki
(Redirected from Source:Objclass.h)
Jump to: navigation, search

Below is the full text to objclass.h from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/include/objclass.h#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1.  /* NetHack 3.6	objclass.h	$NHDT-Date: 1462067744 2016/05/01 01:55:44 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.16 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /*-Copyright (c) Pasi Kallinen, 2018. */
  4.  /* NetHack may be freely redistributed.  See license for details. */
  5.  
  6.  #ifndef OBJCLASS_H
  7.  #define OBJCLASS_H
  8.  
  9.  /* [misnamed] definition of a type of object */
  10.  enum obj_material_types {
  11.      LIQUID = 1, /* currently only for venom */
  12.      WAX,
  13.      VEGGY, /* foodstuffs */
  14.      FLESH, /*   ditto    */
  15.      PAPER,
  16.      CLOTH,
  17.      LEATHER,
  18.      WOOD,
  19.      BONE,
  20.      DRAGON_HIDE, /* not leather! */
  21.      IRON,        /* Fe - includes steel */
  22.      METAL,       /* Sn, &c. */
  23.      COPPER,      /* Cu - includes brass */
  24.      SILVER,      /* Ag */
  25.      GOLD,        /* Au */
  26.      PLATINUM,    /* Pt */
  27.      MITHRIL,
  28.      PLASTIC,
  29.      GLASS,
  30.      GEMSTONE,
  31.      MINERAL
  32.  };
  33.  
  34.  enum obj_armor_types {
  35.      ARM_SUIT = 0,
  36.      ARM_SHIELD,        /* needed for special wear function */
  37.      ARM_HELM,
  38.      ARM_GLOVES,
  39.      ARM_BOOTS,
  40.      ARM_CLOAK,
  41.      ARM_SHIRT
  42.  };
  43.  
  44.  struct objclass {
  45.      short oc_name_idx;              /* index of actual name */
  46.      short oc_descr_idx;             /* description when name unknown */
  47.      char *oc_uname;                 /* called by user */
  48.      Bitfield(oc_name_known, 1);
  49.      Bitfield(oc_merge, 1);          /* merge otherwise equal objects */
  50.      Bitfield(oc_uses_known, 1);     /* obj->known affects full description;
  51.                                         otherwise, obj->dknown and obj->bknown
  52.                                         tell all, and obj->known should always
  53.                                         be set for proper merging behavior. */
  54.      Bitfield(oc_pre_discovered, 1); /* Already known at start of game;
  55.                                         won't be listed as a discovery. */
  56.      Bitfield(oc_magic, 1);          /* inherently magical object */
  57.      Bitfield(oc_charged, 1);        /* may have +n or (n) charges */
  58.      Bitfield(oc_unique, 1);         /* special one-of-a-kind object */
  59.      Bitfield(oc_nowish, 1);         /* cannot wish for this object */
  60.  
  61.      Bitfield(oc_big, 1);
  62.  #define oc_bimanual oc_big /* for weapons & tools used as weapons */
  63.  #define oc_bulky oc_big    /* for armor */
  64.      Bitfield(oc_tough, 1); /* hard gems/rings */
  65.  
  66.      Bitfield(oc_dir, 2);
  67.  #define NODIR 1     /* for wands/spells: non-directional */
  68.  #define IMMEDIATE 2 /*               directional */
  69.  #define RAY 3       /*               zap beams */
  70.  
  71.  #define PIERCE 1 /* for weapons & tools used as weapons */
  72.  #define SLASH 2  /* (latter includes iron ball & chain) */
  73.  #define WHACK 0
  74.  
  75.      /*Bitfield(oc_subtyp,3);*/ /* Now too big for a bitfield... see below */
  76.  
  77.      Bitfield(oc_material, 5); /* one of obj_material_types */
  78.  
  79.  #define is_organic(otmp) (objects[otmp->otyp].oc_material <= WOOD)
  80.  #define is_metallic(otmp)                    \
  81.      (objects[otmp->otyp].oc_material >= IRON \
  82.       && objects[otmp->otyp].oc_material <= MITHRIL)
  83.  
  84.  /* primary damage: fire/rust/--- */
  85.  /* is_flammable(otmp), is_rottable(otmp) in mkobj.c */
  86.  #define is_rustprone(otmp) (objects[otmp->otyp].oc_material == IRON)
  87.  
  88.  /* secondary damage: rot/acid/acid */
  89.  #define is_corrodeable(otmp)                   \
  90.      (objects[otmp->otyp].oc_material == COPPER \
  91.       || objects[otmp->otyp].oc_material == IRON)
  92.  
  93.  #define is_damageable(otmp)                                        \
  94.      (is_rustprone(otmp) || is_flammable(otmp) || is_rottable(otmp) \
  95.       || is_corrodeable(otmp))
  96.  
  97.      schar oc_subtyp;
  98.  #define oc_skill oc_subtyp  /* Skills of weapons, spellbooks, tools, gems */
  99.  #define oc_armcat oc_subtyp /* for armor */
  100.  
  101.      uchar oc_oprop; /* property (invis, &c.) conveyed */
  102.      char oc_class;  /* object class */
  103.      schar oc_delay; /* delay when using such an object */
  104.      uchar oc_color; /* color of the object */
  105.  
  106.      short oc_prob;            /* probability, used in mkobj() */
  107.      unsigned short oc_weight; /* encumbrance (1 cn = 0.1 lb.) */
  108.      short oc_cost;            /* base cost in shops */
  109.      /* Check the AD&D rules!  The FIRST is small monster damage. */
  110.      /* for weapons, and tools, rocks, and gems useful as weapons */
  111.      schar oc_wsdam, oc_wldam; /* max small/large monster damage */
  112.      schar oc_oc1, oc_oc2;
  113.  #define oc_hitbon oc_oc1 /* weapons: "to hit" bonus */
  114.  
  115.  #define a_ac oc_oc1     /* armor class, used in ARM_BONUS in do.c */
  116.  #define a_can oc_oc2    /* armor: used in mhitu.c */
  117.  #define oc_level oc_oc2 /* books: spell level */
  118.  
  119.      unsigned short oc_nutrition; /* food value */
  120.  };
  121.  
  122.  struct class_sym {
  123.      char sym;
  124.      const char *name;
  125.      const char *explain;
  126.  };
  127.  
  128.  struct objdescr {
  129.      const char *oc_name;  /* actual name */
  130.      const char *oc_descr; /* description when name unknown */
  131.  };
  132.  
  133.  extern NEARDATA struct objclass objects[];
  134.  extern NEARDATA struct objdescr obj_descr[];
  135.  
  136.  /*
  137.   * All objects have a class. Make sure that all classes have a corresponding
  138.   * symbol below.
  139.   */
  140.  enum obj_class_types {
  141.      RANDOM_CLASS = 0, /* used for generating random objects */
  142.      ILLOBJ_CLASS,
  143.      WEAPON_CLASS,
  144.      ARMOR_CLASS,
  145.      RING_CLASS,
  146.      AMULET_CLASS,
  147.      TOOL_CLASS,
  148.      FOOD_CLASS,
  149.      POTION_CLASS,
  150.      SCROLL_CLASS,
  151.      SPBOOK_CLASS, /* actually SPELL-book */
  152.      WAND_CLASS,
  153.      COIN_CLASS,
  154.      GEM_CLASS,
  155.      ROCK_CLASS,
  156.      BALL_CLASS,
  157.      CHAIN_CLASS,
  158.      VENOM_CLASS,
  159.  
  160.      MAXOCLASSES
  161.  };
  162.  
  163.  #define ALLOW_COUNT (MAXOCLASSES + 1) /* Can be used in the object class    */
  164.  #define ALL_CLASSES (MAXOCLASSES + 2) /* input to getobj().                 */
  165.  #define ALLOW_NONE  (MAXOCLASSES + 3)
  166.  
  167.  #define BURNING_OIL (MAXOCLASSES + 1) /* Can be used as input to explode.   */
  168.  #define MON_EXPLODE (MAXOCLASSES + 2) /* Exploding monster (e.g. gas spore) */
  169.  
  170.  #if 0 /* moved to decl.h so that makedefs.c won't see them */
  171.  extern const struct class_sym
  172.          def_oc_syms[MAXOCLASSES];       /* default class symbols */
  173.  extern uchar oc_syms[MAXOCLASSES];      /* current class symbols */
  174.  #endif
  175.  
  176.  /* Default definitions of all object-symbols (must match classes above). */
  177.  
  178.  #define ILLOBJ_SYM ']' /* also used for mimics */
  179.  #define WEAPON_SYM ')'
  180.  #define ARMOR_SYM '['
  181.  #define RING_SYM '='
  182.  #define AMULET_SYM '"'
  183.  #define TOOL_SYM '('
  184.  #define FOOD_SYM '%'
  185.  #define POTION_SYM '!'
  186.  #define SCROLL_SYM '?'
  187.  #define SPBOOK_SYM '+'
  188.  #define WAND_SYM '/'
  189.  #define GOLD_SYM '$'
  190.  #define GEM_SYM '*'
  191.  #define ROCK_SYM '`'
  192.  #define BALL_SYM '0'
  193.  #define CHAIN_SYM '_'
  194.  #define VENOM_SYM '.'
  195.  
  196.  struct fruit {
  197.      char fname[PL_FSIZ];
  198.      int fid;
  199.      struct fruit *nextf;
  200.  };
  201.  #define newfruit() (struct fruit *) alloc(sizeof(struct fruit))
  202.  #define dealloc_fruit(rind) free((genericptr_t)(rind))
  203.  
  204.  #define OBJ_NAME(obj) (obj_descr[(obj).oc_name_idx].oc_name)
  205.  #define OBJ_DESCR(obj) (obj_descr[(obj).oc_descr_idx].oc_descr)
  206.  #endif /* OBJCLASS_H */