home · contact · privacy
Server: Internally, rename "map object" stuff to "thing" stuff.
[plomrogue] / src / server / things.h
1 /* src/server/things.h
2  *
3  * Structs for things and their type definitions, and routines to initialize
4  * these and load and save them from/to files.
5  */
6
7 #ifndef THINGS_H
8 #define THINGS_H
9
10 #include <stdint.h> /* uint8_t */
11 #include "../common/yx_uint8.h" /* yx_uint8 structs */
12
13
14
15 struct Thing
16 {
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 */
27 };
28
29 struct ThingType
30 {
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? */
39 };
40
41
42
43 /* Free thing types chain starting at "tt_start". */
44 extern void free_thing_types(struct ThingType * tt_start);
45
46 /* Add thing(s) ("n": how many?) of "type" to map on random position(s). New
47  * animate things are never placed in the same square with other animate ones.
48  */
49 extern void add_things(uint8_t type, uint8_t n);
50
51 /* Free things in things chain starting at "t_start. */
52 extern void free_things(struct Thing * t_start);
53
54 /* Move thing of "id" from "source" inventory to "target" inventory. */
55 extern void own_thing(struct Thing ** target, struct Thing ** source,
56                       uint8_t id);
57
58 /* Get pointer to the Thing struct that represents the player. */
59 extern struct Thing * get_player();
60
61 /* Get pointer to the thing type of identifier "def_id". */
62 extern struct ThingType * get_thing_type(uint8_t id);
63
64 /* Move not only "t" to "pos", but also all things owned by it. */
65 extern void set_thing_position(struct Thing * t, struct yx_uint8 pos);
66
67
68
69 #endif