home · contact · privacy
Server: Internally, rename "map object" stuff to "thing" stuff.
[plomrogue] / src / server / thing_actions.h
1 /* src/server/thing_actions.h
2  *
3  * Actions that can be performed by living things / "actors". Note that apart
4  * from the consequences described below, each action may also trigger log
5  * messages and other minor stuff if the actor is equal to the player.
6  */
7
8 #ifndef THING_ACTIONS_H
9 #define THING_ACTIONS_H
10
11 #include <stdint.h> /* uint8_t */
12 struct Thing;
13
14
15
16 struct ThingAction
17 {
18     uint8_t id; /* identifies action in Thing.command; therefore must be >0 */
19     struct ThingAction * next;
20     void (* func) (struct Thing *); /* function called after .effort turns */
21     char * name; /* human-readable identifier */
22     uint8_t effort; /* how many turns the action takes */
23 };
24
25
26
27 /* Free ThingAction * chain starting at "ta". */
28 extern void free_thing_actions(struct ThingAction * ta);
29
30 /* Return world.thing_actions ThingAction.id for "name". */
31 extern uint8_t get_thing_action_id_by_name(char * name);
32
33 /* Actor "t" does nothing. */
34 extern void actor_wait(struct Thing * t);
35
36 /* Actor "t" tries to move one step in direction described by char t->arg (where
37  * north-east is 'e', east 'd' etc.) Move either succeeds, or another actor is
38  * encountered and hit (which leads ot its lifepoint decreasing by one and
39  * eventually death), or the move fails due to an impassable target square. On
40  * success, update thing's field of view map.
41  */
42 extern void actor_move(struct Thing * t);
43
44 /* Actor "t" tries to drop from inventory thing indexed by number t->args. */
45 extern void actor_drop(struct Thing * t);
46
47 /* Actor "t" tries to pick up topmost thing from ground into its inventory. */
48 extern void actor_pick(struct Thing * t);
49
50 /* Actor "t" tries to use thing in inventory indexed by number t->args.
51  * (Currently the only valid use is consuming items defined as consumable.)
52  */
53 extern void actor_use(struct Thing * t);
54
55
56
57 #endif