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