X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fmap_object_actions.h;h=0d594d324d0f3a709e76ed3f3b5307ba48573b0b;hb=c3d87a1dee96775443fdf73c53e1350af7ca5fc2;hp=d67e8bb5d595c75a74b05d71d35f979627578daf;hpb=e4f2a14c7385d99d49cf831cd3fd92234caf71b5;p=plomrogue diff --git a/src/map_object_actions.h b/src/map_object_actions.h index d67e8bb..0d594d3 100644 --- a/src/map_object_actions.h +++ b/src/map_object_actions.h @@ -1,15 +1,59 @@ +/* map_object_actions.h + * + * Actions that can be performed my map objects / "actors". Note that apart + * from the consequences described below, each action may also trigger log + * messages and other minor stuff if the actor is equal to the player. + */ + #ifndef MAP_OBJECT_ACTIONS_H #define MAP_OBJECT_ACTIONS_H -#include "yx_uint16.h" +#include /* for uint8_t */ +struct MapObj; + + + +struct MapObjAct +{ + struct MapObjAct * next; + uint8_t id; /* unique id of map object action */ + char * name; /* human-readable identifier */ + uint8_t effort; /* how many turns the action takes */ + void (* func) (struct MapObj *); /* function called after .effort turns */ +}; + + + +/* Init MapObjAct chain at world.map_obj_acts from config/map_object_actions. */ +extern void init_map_object_actions(); + +/* Free MapObjAct * chain starting at "moa". */ +extern void free_map_object_actions(struct MapObjAct * moa); + +/* Return world.map_obj_acts MapObjAct.id for "name". */ +extern uint8_t get_moa_id_by_name(char * name); + +/* Actor "mo" does nothing. */ +extern void actor_wait(struct MapObj * mo); + +/* Actor "mo" tries to move one step in direction described by char mo->arg + * (where east is 'E', north 'N') etc. Move either succeeds, or another actor is + * encountered and hit (which leads ot its lifepoint decreasing by one and + * eventually death), or the move fails due to an impassable target square. + */ +extern void actor_move(struct MapObj * mo); + +/* Actor "mo" tries to drop from inventory object indexed by number mo->args. */ +extern void actor_drop(struct MapObj * mo); + +/* Actor "mo" tries to pick up object from ground into its inventory. */ +extern void actor_pick(struct MapObj * mo); + +/* Actor "mo" tries to use inventory object indexed by number mo->args. + * (Currently the only valid use is consuming "MAGIC MEAT".) + */ +extern void actor_use(struct MapObj * mo); -struct World; -struct Map; -struct Monster; -extern char is_passable (struct Map *, struct yx_uint16); -extern void move_monster (struct World *, struct Monster *); -extern void move_player (struct World *, char); -extern void player_wait(struct World *); #endif