PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/object/object.h

https://bitbucket.org/ekolis/jackband
C Header | 300 lines | 233 code | 36 blank | 31 comment | 6 complexity | a36d22693620c5dfe2db5d7434928de9 MD5 | raw file
  1. #ifndef INCLUDED_OBJECT_H
  2. #define INCLUDED_OBJECT_H
  3. /*** Variables ***/
  4. /** Maximum number of scroll titles generated */
  5. #define MAX_TITLES 50
  6. /** The titles of scrolls, ordered by sval. */
  7. extern char scroll_adj[MAX_TITLES][16];
  8. /*** Constants ***/
  9. /**
  10. * Modes for object_desc().
  11. */
  12. typedef enum
  13. {
  14. ODESC_BASE = 0x00, /*!< Only describe the base name */
  15. ODESC_COMBAT = 0x01, /*!< Also show combat bonuses */
  16. ODESC_EXTRA = 0x02, /*!< Show charges/inscriptions/pvals */
  17. ODESC_FULL = ODESC_COMBAT | ODESC_EXTRA,
  18. /*!< Show entire description */
  19. ODESC_STORE = 0x04, /*!< This is an in-store description */
  20. ODESC_PLURAL = 0x08, /*!< Always pluralise */
  21. ODESC_SINGULAR = 0x10, /*!< Always singular */
  22. ODESC_SPOIL = 0x20, /*!< Display regardless of player knowledge */
  23. ODESC_PREFIX = 0x40 /* */
  24. } odesc_detail_t;
  25. /**
  26. * Modes for item lists in "show_inven()" "show_equip()" and "show_floor()"
  27. */
  28. typedef enum
  29. {
  30. OLIST_NONE = 0x00, /* No options */
  31. OLIST_WINDOW = 0x01, /* Display list in a sub-term (left-align) */
  32. OLIST_QUIVER = 0x02, /* Display quiver lines */
  33. OLIST_GOLD = 0x04, /* Include gold in the list */
  34. OLIST_WEIGHT = 0x08, /* Show item weight */
  35. OLIST_PRICE = 0x10, /* Show item price */
  36. OLIST_FAIL = 0x20 /* Show device failure */
  37. } olist_detail_t;
  38. /**
  39. * Modes for object_info()
  40. */
  41. typedef enum
  42. {
  43. OINFO_NONE = 0x00, /* No options */
  44. OINFO_TERSE = 0x01, /* Keep descriptions brief, e.g. for dumps */
  45. OINFO_SUBJ = 0x02, /* Describe object from the character's POV */
  46. OINFO_FULL = 0x04, /* Treat object as if fully IDd */
  47. OINFO_DUMMY = 0x08 /* Object does not exist (e.g. knowledge menu) */
  48. } oinfo_detail_t;
  49. /**
  50. * Pseudo-ID markers.
  51. */
  52. typedef enum
  53. {
  54. INSCRIP_NULL = 0, /*!< No pseudo-ID status */
  55. INSCRIP_STRANGE = 1, /*!< Item that has mixed combat bonuses */
  56. INSCRIP_AVERAGE = 2, /*!< Item with no interesting features */
  57. INSCRIP_MAGICAL = 3, /*!< Item with combat bonuses */
  58. INSCRIP_SPLENDID = 4, /*!< Obviously good item */
  59. INSCRIP_EXCELLENT = 5, /*!< Ego-item */
  60. INSCRIP_SPECIAL = 6, /*!< Artifact */
  61. INSCRIP_UNKNOWN = 7,
  62. INSCRIP_MAX /*!< Maximum number of pseudo-ID markers */
  63. } obj_pseudo_t;
  64. /*** Functions ***/
  65. /* identify.c */
  66. extern s32b object_last_wield;
  67. bool object_is_known(const object_type *o_ptr);
  68. bool object_is_known_artifact(const object_type *o_ptr);
  69. bool object_is_known_cursed(const object_type *o_ptr);
  70. bool object_is_known_blessed(const object_type *o_ptr);
  71. bool object_is_known_not_artifact(const object_type *o_ptr);
  72. bool object_is_not_known_consistently(const object_type *o_ptr);
  73. bool object_was_worn(const object_type *o_ptr);
  74. bool object_was_fired(const object_type *o_ptr);
  75. bool object_was_sensed(const object_type *o_ptr);
  76. bool object_flavor_is_aware(const object_type *o_ptr);
  77. bool object_flavor_was_tried(const object_type *o_ptr);
  78. bool object_effect_is_known(const object_type *o_ptr);
  79. bool object_pval_is_visible(const object_type *o_ptr);
  80. bool object_ego_is_visible(const object_type *o_ptr);
  81. bool object_attack_plusses_are_visible(const object_type *o_ptr);
  82. bool object_defence_plusses_are_visible(const object_type *o_ptr);
  83. bool object_flag_is_known(const object_type *o_ptr, int flag);
  84. bool object_high_resist_is_possible(const object_type *o_ptr);
  85. void object_flavor_aware(object_type *o_ptr);
  86. void object_flavor_tried(object_type *o_ptr);
  87. void object_notice_everything(object_type *o_ptr);
  88. void object_notice_indestructible(object_type *o_ptr);
  89. void object_notice_ego(object_type *o_ptr);
  90. void object_notice_sensing(object_type *o_ptr);
  91. void object_sense_artifact(object_type *o_ptr);
  92. void object_notice_effect(object_type *o_ptr);
  93. void object_notice_slay(object_type *o_ptr, int flag);
  94. void object_notice_attack_plusses(object_type *o_ptr);
  95. bool object_notice_flag(object_type *o_ptr, int flag);
  96. bool object_notice_flags(object_type *o_ptr, bitflag flags[OF_SIZE]);
  97. bool object_notice_curses(object_type *o_ptr);
  98. void object_notice_on_defend(void);
  99. void object_notice_on_wield(object_type *o_ptr);
  100. void object_notice_on_firing(object_type *o_ptr);
  101. void wieldeds_notice_flag(int flag);
  102. void wieldeds_notice_on_attack(void);
  103. void object_repair_knowledge(object_type *o_ptr);
  104. bool object_FA_would_be_obvious(const object_type *o_ptr);
  105. obj_pseudo_t object_pseudo(const object_type *o_ptr);
  106. void sense_inventory(void);
  107. bool easy_know(const object_type *o_ptr);
  108. bool object_check_for_ident(object_type *o_ptr);
  109. bool object_name_is_visible(const object_type *o_ptr);
  110. void object_know_all_flags(object_type *o_ptr);
  111. /* obj-desc.c */
  112. void object_kind_name(char *buf, size_t max, int k_idx, bool easy_know);
  113. size_t object_desc(char *buf, size_t max, const object_type *o_ptr, odesc_detail_t mode);
  114. /* obj-info.c */
  115. extern const slay_t slay_table[];
  116. size_t num_slays(void);
  117. void object_info_header(const object_type *o_ptr);
  118. bool object_info(const object_type *o_ptr, oinfo_detail_t mode);
  119. bool object_info_chardump(const object_type *o_ptr);
  120. bool object_info_spoil(const object_type *o_ptr);
  121. /* obj-make.c */
  122. void free_obj_alloc(void);
  123. bool init_obj_alloc(void);
  124. s16b get_obj_num(int level, bool good);
  125. void object_prep(object_type *o_ptr, int k_idx, int lev, aspect rand_aspect);
  126. void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great);
  127. bool make_object(object_type *j_ptr, int lev, bool good, bool great);
  128. void make_gold(object_type *j_ptr, int lev, int coin_type);
  129. void set_ego_xtra_sustain(bitflag flags[OF_SIZE]);
  130. void set_ego_xtra_resist(bitflag flags[OF_SIZE]);
  131. void set_ego_xtra_power(bitflag flags[OF_SIZE]);
  132. /* obj-ui.c */
  133. void show_inven(olist_detail_t mode);
  134. void show_equip(olist_detail_t mode);
  135. void show_floor(const int *floor_list, int floor_num, olist_detail_t mode);
  136. bool verify_item(cptr prompt, int item);
  137. bool get_item(int *cp, cptr pmt, cptr str, int mode);
  138. /* obj-util.c */
  139. void flavor_init(void);
  140. void reset_visuals(bool unused);
  141. void object_flags(const object_type *o_ptr, bitflag flags[OF_SIZE]);
  142. void object_flags_known(const object_type *o_ptr, bitflag flags[OF_SIZE]);
  143. char index_to_label(int i);
  144. s16b label_to_inven(int c);
  145. s16b label_to_equip(int c);
  146. bool wearable_p(const object_type *o_ptr);
  147. s16b wield_slot(const object_type *o_ptr);
  148. bool slot_can_wield_item(int slot, const object_type *o_ptr);
  149. const char *mention_use(int slot);
  150. cptr describe_use(int i);
  151. bool item_tester_okay(const object_type *o_ptr);
  152. int scan_floor(int *items, int max_size, int y, int x, int mode);
  153. void excise_object_idx(int o_idx);
  154. void delete_object_idx(int o_idx);
  155. void delete_object(int y, int x);
  156. void compact_objects(int size);
  157. void wipe_o_list(void);
  158. s16b o_pop(void);
  159. object_type *get_first_object(int y, int x);
  160. object_type *get_next_object(const object_type *o_ptr);
  161. bool is_blessed(const object_type *o_ptr);
  162. s32b object_value(const object_type *o_ptr, int qty, int verbose);
  163. bool object_similar(const object_type *o_ptr, const object_type *j_ptr);
  164. void object_absorb(object_type *o_ptr, const object_type *j_ptr);
  165. void object_wipe(object_type *o_ptr);
  166. void object_copy(object_type *o_ptr, const object_type *j_ptr);
  167. void object_copy_amt(object_type *dst, object_type *src, int amt);
  168. s16b floor_carry(int y, int x, object_type *j_ptr);
  169. void drop_near(object_type *j_ptr, int chance, int y, int x, bool verbose);
  170. void acquirement(int y1, int x1, int level, int num, bool great);
  171. void inven_item_charges(int item);
  172. void inven_item_describe(int item);
  173. void inven_item_increase(int item, int num);
  174. void save_quiver_size(void);
  175. void inven_item_optimize(int item);
  176. void floor_item_charges(int item);
  177. void floor_item_describe(int item);
  178. void floor_item_increase(int item, int num);
  179. void floor_item_optimize(int item);
  180. bool inven_carry_okay(const object_type *o_ptr);
  181. bool inven_stack_okay(const object_type *o_ptr);
  182. s16b inven_carry(object_type *o_ptr);
  183. s16b inven_takeoff(int item, int amt);
  184. void inven_drop(int item, int amt);
  185. void combine_pack(void);
  186. void reorder_pack(void);
  187. void open_quiver_slot(int slot);
  188. void sort_quiver(void);
  189. int get_use_device_chance(const object_type *o_ptr);
  190. void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt);
  191. void reduce_charges(object_type *o_ptr, int amt);
  192. int number_charging(const object_type *o_ptr);
  193. bool recharge_timeout(object_type *o_ptr);
  194. unsigned check_for_inscrip(const object_type *o_ptr, const char *inscrip);
  195. int lookup_kind(int tval, int sval);
  196. bool lookup_reverse(s16b k_idx, int *tval, int *sval);
  197. int lookup_name(int tval, const char *name);
  198. int lookup_artifact_name(const char *name);
  199. int lookup_sval(int tval, const char *name);
  200. int tval_find_idx(const char *name);
  201. const char *tval_find_name(int tval);
  202. artifact_type *artifact_of(const object_type *o_ptr);
  203. object_kind *object_kind_of(const object_type *o_ptr);
  204. bool obj_is_staff(const object_type *o_ptr);
  205. bool obj_is_wand(const object_type *o_ptr);
  206. bool obj_is_rod(const object_type *o_ptr);
  207. bool obj_is_potion(const object_type *o_ptr);
  208. bool obj_is_scroll(const object_type *o_ptr);
  209. bool obj_is_food(const object_type *o_ptr);
  210. bool obj_is_light(const object_type *o_ptr);
  211. bool obj_is_ring(const object_type *o_ptr);
  212. bool obj_is_ammo(const object_type *o_ptr);
  213. bool obj_has_charges(const object_type *o_ptr);
  214. bool obj_can_zap(const object_type *o_ptr);
  215. bool obj_is_activatable(const object_type *o_ptr);
  216. bool obj_can_activate(const object_type *o_ptr);
  217. bool obj_can_refill(const object_type *o_ptr);
  218. bool obj_can_browse(const object_type *o_ptr);
  219. bool obj_can_takeoff(const object_type *o_ptr);
  220. bool obj_can_wear(const object_type *o_ptr);
  221. bool obj_has_inscrip(const object_type *o_ptr);
  222. u16b object_effect(const object_type *o_ptr);
  223. object_type *object_from_item_idx(int item);
  224. bool obj_needs_aim(object_type *o_ptr);
  225. bool get_item_okay(int item);
  226. int scan_items(int *item_list, size_t item_list_max, int mode);
  227. bool item_is_available(int item, bool (*tester)(const object_type *), int mode);
  228. extern void display_itemlist(void);
  229. extern void display_object_idx_recall(s16b o_idx);
  230. extern void display_object_kind_recall(s16b k_idx);
  231. bool pack_is_full(void);
  232. bool pack_is_overfull(void);
  233. void pack_overflow(void);
  234. /* obj-power.c and randart.c */
  235. s32b object_power(const object_type *o_ptr, int verbose, ang_file *log_file, bool known);
  236. /*
  237. * Some constants used in randart generation and power calculation
  238. * - thresholds for limiting to_hit, to_dam and to_ac
  239. * - fudge factor for rescaling ammo cost
  240. * (a stack of this many equals a weapon of the same damage output)
  241. */
  242. #define INHIBIT_POWER 20000
  243. #define HIGH_TO_AC 26
  244. #define VERYHIGH_TO_AC 36
  245. #define INHIBIT_AC 56
  246. #define HIGH_TO_HIT 16
  247. #define VERYHIGH_TO_HIT 26
  248. #define HIGH_TO_DAM 16
  249. #define VERYHIGH_TO_DAM 26
  250. #define AMMO_RESCALER 20 /* this value is also used for torches */
  251. #define sign(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0))
  252. #define LOG_PRINT(string) \
  253. do { if (verbose) \
  254. file_putf(log_file, (string)); \
  255. } while (0);
  256. #define LOG_PRINT1(string, value) \
  257. do { if (verbose) \
  258. file_putf(log_file, (string), (value)); \
  259. } while (0);
  260. #define LOG_PRINT2(string, val1, val2) \
  261. do { if (verbose) \
  262. file_putf(log_file, (string), (val1), (val2)); \
  263. } while (0);
  264. #endif /* !INCLUDED_OBJECT_H */