3 * Structs for things and their type definitions, and routines to initialize
4 * these and load and save them from/to files.
10 #include <stdint.h> /* uint8_t */
11 #include "../common/yx_uint8.h" /* yx_uint8 structs */
17 struct Thing * next; /* pointer to next one in things chain */
18 struct Thing * owns; /* chain of things owned / in inventory */
19 struct yx_uint8 pos; /* coordinate on map */
20 uint8_t * fov_map; /* map of the thing's field of view */
21 uint8_t id; /* individual thing's unique identifier */
22 uint8_t type; /* ID of appropriate thing definition */
23 uint8_t lifepoints; /* 0: thing is inanimate; >0: hitpoints */
24 uint8_t command; /* thing's current action; 0 if none */
25 uint8_t arg; /* optional field for .command argument */
26 uint8_t progress; /* turns already passed to realize .command */
31 uint8_t id; /* thing type identifier / sets .type */
32 struct ThingType * next;
33 char char_on_map; /* thing symbol to appear on map */
34 char * name; /* string to describe thing in game log */
35 uint8_t corpse_id; /* type to change thing into upon destruction */
36 uint8_t lifepoints; /* default start value for thing's .lifepoints */
37 uint8_t consumable; /* can be eaten if !0, for so much hitpoint win */
38 uint8_t start_n; /* how many of these does the map start with? */
43 /* Return thing of "id" in chain at "ptr", search inventories too if "deep". */
44 extern struct Thing * get_thing(struct Thing * ptr, uint8_t id, uint8_t deep);
46 /* Free thing types chain starting at "tt_start". */
47 extern void free_thing_types(struct ThingType * tt_start);
49 /* Add thing of "id" and "type" to map on random passable position (positions
50 * which contain an actor are not deemed passable) if "find_pos", else on y=0,
51 * x=0. If "id" is >= 0 and <= UINT8_MAX, use lowest unused id. Return thing.
53 extern struct Thing * add_thing(int16_t id, uint8_t type, uint8_t find_pos);
55 /* Add thing(s) ("n": how many?) of "type" to map on random position(s). New
56 * animate things are never placed in the same square with other animate ones.
58 extern void add_things(uint8_t type, uint8_t n);
60 /* Free things in things chain starting at "t_start. */
61 extern void free_things(struct Thing * t_start);
63 /* Move thing of "id" from "source" inventory to "target" inventory. */
64 extern void own_thing(struct Thing ** target, struct Thing ** source,
67 /* Get pointer to the Thing struct that represents the player. */
68 extern struct Thing * get_player();
70 /* Get pointer to the thing type of identifier "def_id". */
71 extern struct ThingType * get_thing_type(uint8_t id);
73 /* Move not only "t" to "pos", but also all things owned by it. */
74 extern void set_thing_position(struct Thing * t, struct yx_uint8 pos);