abstract
| - Below is the full text to obj.h from the source code of NetHack 3.3.0. To link to a particular line, write [[NetHack 3.3.0/obj.h#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)obj.h 3.3 1999/03/13 */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef OBJ_H 6. #define OBJ_H 7. 8. /* #define obj obj_nh */ /* uncomment for SCO UNIX, which has a conflicting 9. * typedef for "obj" in */ 10. 11. union vptrs { 12. struct obj *v_nexthere; /* floor location lists */ 13. struct obj *v_ocontainer; /* point back to container */ 14. struct monst *v_ocarry; /* point back to carrying monst */ 15. }; 16. 17. struct obj { 18. struct obj *nobj; 19. union vptrs v; 20. #define nexthere v.v_nexthere 21. #define ocontainer v.v_ocontainer 22. #define ocarry v.v_ocarry 23. 24. struct obj *cobj; /* contents list for containers */ 25. unsigned o_id; 26. xchar ox,oy; 27. short otyp; /* object class number */ 28. unsigned owt; 29. long quan; /* number of items */ 30. 31. schar spe; /* quality of weapon, armor or ring (+ or -) 32. number of charges for wand ( >= -1 ) 33. marks your eggs, spinach tins 34. royal coffers for a court ( == 2) 35. tells which fruit a fruit is 36. special for uball and amulet %% BAH */ 37. char oclass; /* object class */ 38. char invlet; /* designation in inventory */ 39. char oartifact; /* artifact array index */ 40. 41. xchar where; /* where the object thinks it is */ 42. #define OBJ_FREE 0 /* object not attached to anything */ 43. #define OBJ_FLOOR 1 /* object on floor */ 44. #define OBJ_CONTAINED 2 /* object in a container */ 45. #define OBJ_INVENT 3 /* object in the hero's inventory */ 46. #define OBJ_MINVENT 4 /* object in a monster inventory */ 47. #define OBJ_MIGRATING 5 /* object sent off to another level */ 48. #define OBJ_BURIED 6 /* object buried */ 49. #define OBJ_ONBILL 7 /* object on shk bill */ 50. #define NOBJ_STATES 8 51. xchar timed; /* # of fuses (timers) attached to this obj */ 52. 53. Bitfield(cursed,1); 54. Bitfield(blessed,1); 55. Bitfield(unpaid,1); /* on some bill */ 56. Bitfield(no_charge,1); /* if shk shouldn't charge for this */ 57. Bitfield(known,1); /* exact nature known */ 58. Bitfield(dknown,1); /* color or text known */ 59. Bitfield(bknown,1); /* blessing or curse known */ 60. Bitfield(rknown,1); /* rustproof or not known */ 61. 62. Bitfield(oeroded,2); /* rusted/burnt weapon/armor */ 63. Bitfield(oeroded2,2); /* corroded/rotted weapon/armor */ 64. #define greatest_erosion(otmp) (int)((otmp)->oeroded > (otmp)->oeroded2 ? (otmp)->oeroded : (otmp)->oeroded2) 65. #define MAX_ERODE 3 66. #define orotten oeroded /* rotten food */ 67. #define odiluted oeroded /* diluted potions */ 68. Bitfield(oerodeproof,1); /* erodeproof weapon/armor */ 69. Bitfield(olocked,1); /* object is locked */ 70. Bitfield(obroken,1); /* lock has been broken */ 71. Bitfield(otrapped,1); /* container is trapped */ 72. #define opoisoned otrapped /* object (weapon) is coated with poison */ 73. 74. Bitfield(recharged,3); /* number of times it's been recharged */ 75. Bitfield(lamplit,1); /* a light-source -- can be lit */ 76. #ifdef INVISIBLE_OBJECTS 77. Bitfield(oinvis,1); /* invisible */ 78. #endif 79. Bitfield(greased,1); /* covered with grease */ 80. Bitfield(oattached,2); /* obj struct has special attachment */ 81. #define OATTACHED_NOTHING 0 82. #define OATTACHED_MONST 1 /* monst struct in oextra */ 83. #define OATTACHED_UNUSED2 2 84. #define OATTACHED_UNUSED3 3 85. 86. Bitfield(in_use,1); /* for magic items before useup items */ 87. /* 7 free bits */ 88. 89. int corpsenm; /* type of corpse is mons[corpsenm] */ 90. #define leashmon corpsenm /* gets m_id of attached pet */ 91. #define spestudied corpsenm /* how many times a spellbook has been studied */ 92. unsigned oeaten; /* nutrition left in food, if partly eaten */ 93. long age; /* creation date */ 94. 95. uchar onamelth; /* length of name (following oxlth) */ 96. short oxlth; /* length of following data */ 97. /* in order to prevent alignment problems oextra should 98. be (or follow) a long int */ 99. long owornmask; 100. long oextra[1]; /* used for name of ordinary objects - length 101. is flexible; amount for tmp gold objects */ 102. }; 103. 104. #define newobj(xl) (struct obj *)alloc((unsigned)(xl) + sizeof(struct obj)) 105. #define ONAME(otmp) (((char *)(otmp)->oextra) + (otmp)->oxlth) 106. 107. /* Weapons and weapon-tools */ 108. /* KMH -- now based on skill categories. Formerly: 109. * #define is_sword(otmp) (otmp->oclass == WEAPON_CLASS && \ 110. * objects[otmp->otyp].oc_wepcat == WEP_SWORD) 111. * #define is_blade(otmp) (otmp->oclass == WEAPON_CLASS && \ 112. * (objects[otmp->otyp].oc_wepcat == WEP_BLADE || \ 113. * objects[otmp->otyp].oc_wepcat == WEP_SWORD)) 114. * #define is_weptool(o) ((o)->oclass == TOOL_CLASS && \ 115. * objects[(o)->otyp].oc_weptool) 116. * #define is_multigen(otyp) (otyp <= SHURIKEN) 117. * #define is_poisonable(otyp) (otyp <= BEC_DE_CORBIN) 118. */ 119. #define is_blade(otmp) (otmp->oclass == WEAPON_CLASS && \ 120. objects[otmp->otyp].oc_skill >= P_DAGGER && \ 121. objects[otmp->otyp].oc_skill <= P_SABER) 122. #define is_axe(otmp) ((otmp->oclass == WEAPON_CLASS || \ 123. otmp->oclass == TOOL_CLASS) && \ 124. objects[otmp->otyp].oc_skill == P_AXE) 125. #define is_pick(otmp) ((otmp->oclass == WEAPON_CLASS || \ 126. otmp->oclass == TOOL_CLASS) && \ 127. objects[otmp->otyp].oc_skill == P_PICK_AXE) 128. #define is_sword(otmp) (otmp->oclass == WEAPON_CLASS && \ 129. objects[otmp->otyp].oc_skill >= P_SHORT_SWORD && \ 130. objects[otmp->otyp].oc_skill <= P_SABER) 131. #define is_pole(otmp) ((otmp->oclass == WEAPON_CLASS || \ 132. otmp->oclass == TOOL_CLASS) && \ 133. (objects[otmp->otyp].oc_skill == P_POLEARMS || \ 134. objects[otmp->otyp].oc_skill == P_LANCE)) 135. #define is_spear(otmp) (otmp->oclass == WEAPON_CLASS && \ 136. objects[otmp->otyp].oc_skill >= P_SPEAR && \ 137. objects[otmp->otyp].oc_skill <= P_JAVELIN) 138. #define is_launcher(otmp) (otmp->oclass == WEAPON_CLASS && \ 139. objects[otmp->otyp].oc_skill >= P_BOW && \ 140. objects[otmp->otyp].oc_skill <= P_CROSSBOW) 141. #define is_ammo(otmp) ((otmp->oclass == WEAPON_CLASS || \ 142. otmp->oclass == GEM_CLASS) && \ 143. objects[otmp->otyp].oc_skill >= -P_CROSSBOW && \ 144. objects[otmp->otyp].oc_skill <= -P_BOW) 145. #define ammo_and_launcher(otmp,ltmp) \ 146. (is_ammo(otmp) && (ltmp) && \ 147. objects[(otmp)->otyp].oc_skill == -objects[(ltmp)->otyp].oc_skill) 148. #define is_missile(otmp) ((otmp->oclass == WEAPON_CLASS || \ 149. otmp->oclass == TOOL_CLASS) && \ 150. objects[otmp->otyp].oc_skill >= -P_BOOMERANG && \ 151. objects[otmp->otyp].oc_skill <= -P_DART) 152. #define is_weptool(o) ((o)->oclass == TOOL_CLASS && \ 153. objects[(o)->otyp].oc_skill != P_NONE) 154. #define bimanual(otmp) ((otmp->oclass == WEAPON_CLASS || \ 155. otmp->oclass == TOOL_CLASS) && \ 156. objects[otmp->otyp].oc_bimanual) 157. #define is_multigen(otmp) (otmp->oclass == WEAPON_CLASS && \ 158. objects[otmp->otyp].oc_skill >= -P_SHURIKEN && \ 159. objects[otmp->otyp].oc_skill <= -P_BOW) 160. #define is_poisonable(otmp) (otmp->oclass == WEAPON_CLASS && \ 161. objects[otmp->otyp].oc_skill >= -P_SHURIKEN && \ 162. objects[otmp->otyp].oc_skill <= -P_BOW) 163. 164. /* Armor */ 165. #define is_shield(otmp) (otmp->oclass == ARMOR_CLASS && \ 166. objects[otmp->otyp].oc_armcat == ARM_SHIELD) 167. #define is_helmet(otmp) (otmp->oclass == ARMOR_CLASS && \ 168. objects[otmp->otyp].oc_armcat == ARM_HELM) 169. #define is_boots(otmp) (otmp->oclass == ARMOR_CLASS && \ 170. objects[otmp->otyp].oc_armcat == ARM_BOOTS) 171. #define is_gloves(otmp) (otmp->oclass == ARMOR_CLASS && \ 172. objects[otmp->otyp].oc_armcat == ARM_GLOVES) 173. #define is_cloak(otmp) (otmp->oclass == ARMOR_CLASS && \ 174. objects[otmp->otyp].oc_armcat == ARM_CLOAK) 175. #define is_shirt(otmp) (otmp->oclass == ARMOR_CLASS && \ 176. objects[otmp->otyp].oc_armcat == ARM_SHIRT) 177. #define is_suit(otmp) (otmp->oclass == ARMOR_CLASS && \ 178. objects[otmp->otyp].oc_armcat == ARM_SUIT) 179. 180. /* Eggs and other food */ 181. #define MAX_EGG_HATCH_TIME 200 /* longest an egg can remain unhatched */ 182. #define stale_egg(egg) ((monstermoves - (egg)->age) > (2*MAX_EGG_HATCH_TIME)) 183. #define ofood(o) ((o)->otyp == CORPSE || (o)->otyp == EGG || (o)->otyp == TIN) 184. #define polyfodder(obj) (ofood(obj) && \ 185. pm_to_cham((obj)->corpsenm) != CHAM_ORDINARY) 186. #define mlevelgain(obj) (ofood(obj) && (obj)->corpsenm == PM_WRAITH) 187. #define mhealup(obj) (ofood(obj) && (obj)->corpsenm == PM_NURSE) 188. 189. /* Containers */ 190. #define carried(o) ((o)->where == OBJ_INVENT) 191. #define mcarried(o) ((o)->where == OBJ_MINVENT) 192. #define Has_contents(o) (/* (Is_container(o) || (o)->otyp == STATUE) && */ \ 193. (o)->cobj != (struct obj *)0) 194. #define Is_container(o) ((o)->otyp >= LARGE_BOX && (o)->otyp <= BAG_OF_TRICKS) 195. #define Is_box(otmp) (otmp->otyp == LARGE_BOX || otmp->otyp == CHEST) 196. #define Is_mbag(otmp) (otmp->otyp == BAG_OF_HOLDING || \ 197. otmp->otyp == BAG_OF_TRICKS) 198. 199. /* Light sources */ 200. #define Is_candle(otmp) (otmp->otyp == TALLOW_CANDLE || \ 201. otmp->otyp == WAX_CANDLE) 202. #define MAX_OIL_IN_FLASK 400 /* maximum amount of oil in a potion of oil */ 203. 204. /* Flags for get_obj_location(). */ 205. #define CONTAINED_TOO 0x1 206. #define BURIED_TOO 0x2 207. 208. #endif /* OBJ_H */
|