home · contact · privacy
Fixed bug that led to endless loop in nearest_enemy_dir().
[plomrogue] / src / map_object_actions.h
index 6034611a7df36ddc4d0f8851f5278a72329f6b17..0d594d324d0f3a709e76ed3f3b5307ba48573b0b 100644 (file)
@@ -1,50 +1,58 @@
 /* map_object_actions.h
  *
- * Routines for the actions available to map objects.
+ * 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 <stdint.h> /* for uint8_t */
+struct MapObj;
 
 
-#include "yx_uint16.h" /* for yx_uint16 coordinates */
-struct World;
-struct Map;
-struct Monster;
 
+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 */
+};
 
 
-/* Try to move "monster" in random direction. On contact with other monster,
- * only bump. On contact with player, fight / reduce player's hitpoints,
- * and thereby potentially trigger the player's death. Update the log for any
- * contact action.
- */
-extern void move_monster(struct World * world, struct Monster * monster);
-
 
+/* Init MapObjAct chain at world.map_obj_acts from config/map_object_actions. */
+extern void init_map_object_actions();
 
-/* Try to move player in direction "d". On contact with monster, fight / reduce
- * monster's hitpoints, and thereby potentially trigger the monster's death,
- * create a corpse and increment the player's score by the amount of hitpoints
- * the monster started with. Update the log on whatever the player did and turn
- * control over to the enemy.
- */
-extern void move_player (struct World * world, enum dir d);
+/* 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);
 
-/* Make player wait one turn, i.e. only update_log with a "you wait" message
- * and turn control over to the enemy.
+/* 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 player_wait(struct World * world);
+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);
 
-/* Check if coordinate pos on (or beyond) map is accessible to map object
- * movement.
+/* Actor "mo" tries to use inventory object indexed by number mo->args.
+ * (Currently the only valid use is consuming "MAGIC MEAT".)
  */
-extern char is_passable (struct Map * map, struct yx_uint16 pos);
+extern void actor_use(struct MapObj * mo);