home · contact · privacy
In TODO, fix wrong term.
[plomrogue] / src / server / map_object_actions.h
1 /* src/server/map_object_actions.h
2  *
3  * Actions that can be performed my map objects / "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 MAP_OBJECT_ACTIONS_H
9 #define MAP_OBJECT_ACTIONS_H
10
11 #include <stdint.h> /* uint8_t, uint23_t */
12 #include <stdio.h> /* FILE */
13 struct MapObj;
14 struct EntrySkeleton;
15
16
17
18 struct MapObjAct
19 {
20     uint8_t id; /* unique id of map object action; must be >0 */
21     struct MapObjAct * next;
22     void (* func) (struct MapObj *); /* function called after .effort turns */
23     char * name; /* human-readable identifier */
24     uint8_t effort; /* how many turns the action takes */
25 };
26
27
28
29 /* Read-in to "entry" multi-line entry from MapObjAct config "file", using
30  * pre-allocated "line", "linemax" and "context" as input for err_try_fgets().
31  */
32 extern void read_map_object_action(char * line, uint32_t linemax,char * context,
33                                    struct EntrySkeleton * entry, FILE * file);
34
35 /* Free MapObjAct * chain starting at "moa". */
36 extern void free_map_object_actions(struct MapObjAct * moa);
37
38 /* Return world.map_obj_acts MapObjAct.id for "name". */
39 extern uint8_t get_moa_id_by_name(char * name);
40
41 /* Actor "mo" does nothing. */
42 extern void actor_wait(struct MapObj * mo);
43
44 /* Actor "mo" tries to move one step in direction described by char mo->arg
45  * (where east is '6', north '8') etc. Move either succeeds, or another actor is
46  * encountered and hit (which leads ot its lifepoint decreasing by one and
47  * eventually death), or the move fails due to an impassable target square.
48  */
49 extern void actor_move(struct MapObj * mo);
50
51 /* Actor "mo" tries to drop from inventory object indexed by number mo->args. */
52 extern void actor_drop(struct MapObj * mo);
53
54 /* Actor "mo" tries to pick up topmost object from ground into its inventory. */
55 extern void actor_pick(struct MapObj * mo);
56
57 /* Actor "mo" tries to use inventory object indexed by number mo->args.
58  * (Currently the only valid use is consuming items defined as consumable.)
59  */
60 extern void actor_use(struct MapObj * mo);
61
62
63
64 #endif