home · contact · privacy
Dead shoggoths corpse to "magic meat" that can now be "used" i.e. consumed for hitpoi...
authorChristian Heller <c.heller@plomlompom.de>
Sat, 9 Nov 2013 04:48:57 +0000 (05:48 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 9 Nov 2013 04:48:57 +0000 (05:48 +0100)
README
config/commands
config/defs
config/windows/Win_c
src/control.c
src/main.c
src/map_object_actions.c
src/map_object_actions.h
src/misc.c

diff --git a/README b/README
index 08428c0ce951e37342b9a5dcc8c91f7b110e944b..dfcf65e9e5bc6019917f8c287fdffde247984937 100644 (file)
--- a/README
+++ b/README
@@ -8,7 +8,9 @@ bizarre fashion.
 You can move around a player and meet a number of different enemies. They move
 randomly and will only accidentally hit you. You have 5 hitpoints to lose before
 death; they have either 1, 3 or 9. Your score grows by killing enemies, to the
-amount of hitpoints each killed enemy started with.
+amount of hitpoints each killed enemy started with. Dead enemies become dirt,
+skeletons or "magic meat"--such objects can be collected, and "magic meat" can
+be consumed to gain hitpoints.
 
 The map gets generated randomly, too.
 
index ba35ecb15674960fc4aaa3a15424b21db56dbaeb..9368f0b6231d351a07cf872879b53bb6fb6417df 100644 (file)
@@ -48,3 +48,4 @@
 48 pick pick up object from ground
 49 inv_d inventory selection down
 50 inv_u inventory selection up
+51 use use selected inventory object
index 4689c6c60f21d8ada00eede5278a1a280717e2f4..f114ce295a8a5946f2e5415cce809abfcfd91176 100644 (file)
@@ -1,6 +1,7 @@
 0 5 @ 5 HUMAN
 1 4 a 1 ANT
 2 5 z 3 ZOMBIE
-3 5 S 9 SHOGGOTH
+3 6 S 9 SHOGGOTH
 4 4 # 0 DIRT
 5 4 % 0 SKELETON
+6 4 m 0 MAGIC MEAT
index d6b2588b7ec371829524c1a246fb9a9f63b1cdbc..b513c697ec3cd5b2dfa987967e54de9b0aa63b94 100644 (file)
@@ -5,3 +5,4 @@ c
 100 drop
 259 inv_u
 258 inv_d
+117 use
index b282bc6e95a7dc385ea6c75710dcb8feefecce9b..cb5ed3bebd116cb34823f3ded1a99f2b41e0598b 100644 (file)
@@ -171,6 +171,7 @@ extern uint8_t player_control_by_id(int action)
     if (   try_cmd_0args('i', action, "wait", player_wait)
         || try_cmd_0args('i', action, "drop", player_drop)
         || try_cmd_0args('i', action, "pick", player_pick)
+        || try_cmd_0args('i', action, "use", player_use)
         || try_cmd_1args('i', action, "player_u", move_player, 'N')
         || try_cmd_1args('i', action, "player_d", move_player, 'S')
         || try_cmd_1args('i', action, "player_r", move_player, 'E')
index b27cf5d5724bfd446b484e90ba045d95ca019b43..88d90d2844dc1e51b48205101933a1791b974bc4 100644 (file)
@@ -180,7 +180,8 @@ int main(int argc, char *argv[])
                 {
                     break;
                 }
-                if (is_command_id_shortdsc(action, "drop"))
+                if (   is_command_id_shortdsc(action, "drop")
+                    || is_command_id_shortdsc(action, "use"))
                 {
                     world.inventory_select = getc(file);
                 }
@@ -203,7 +204,8 @@ int main(int argc, char *argv[])
                 action = getc(file);
                 if (EOF != action)
                 {
-                    if (is_command_id_shortdsc(action, "drop"))
+                    if (   is_command_id_shortdsc(action, "drop")
+                        || is_command_id_shortdsc(action, "use"))
                     {
                         world.inventory_select = getc(file);
                     }
index 98759973da99b8e6737cc2319927a7f81e94719d..9d1721e936fab21bd8e6c3634812f409e9adb6e9 100644 (file)
@@ -206,3 +206,47 @@ extern void player_pick()
     }
     turn_over(get_command_id("pick"));
 }
+
+
+
+extern void player_use()
+{
+    struct MapObj * player = get_player();
+    if (NULL == player->owns)
+    {
+        update_log("\nYou try to use an object, but you own none.");
+        world.old_inventory_select = 0;
+    }
+    else
+    {
+        uint8_t i = 0;
+        struct MapObj * selected = player->owns;
+        for (; i != world.inventory_select; i++, selected = selected->next);
+        struct MapObjDef * mod = get_map_object_def(selected->type);
+        if (!strcmp("MAGIC MEAT", mod->name))
+        {
+            struct MapObj * next = selected->next;
+            free(selected);
+            if (0 < world.inventory_select)
+            {
+                world.old_inventory_select = world.inventory_select;
+                world.inventory_select--;
+                for (i = 0, selected = player->owns;
+                     i != world.inventory_select;
+                     i++, selected = selected->next);
+                selected->next = next;
+            }
+            else
+            {
+                player->owns = next;
+            }
+            player->lifepoints++;
+            update_log("\nYou consume MAGIC MEAT.");
+            }
+        else
+        {
+            update_log("\nYou try to use this object, but fail.");
+        }
+    }
+    turn_over(get_command_id("use"));
+}
index 8e0af47a928ba30e2097ad117c3d292132d4c116..7cc98433b19ccbe2dfe7d9f9b71c3a7692bfe6d2 100644 (file)
@@ -41,6 +41,9 @@ extern void player_drop();
 /* Make player pick up map object from ground. */
 extern void player_pick();
 
+/* Make player use object indexed by world.inventory_select. */
+extern void player_use();
+
 
 
 #endif
index 9aa609d1fafd3b8f2776d61fc60f954be42fe4a1..48ced07e635ead0f98b102380b416a735040cbd5 100644 (file)
@@ -222,7 +222,8 @@ extern void turn_over(char action)
         }
         try_fclose(file_old, f_name);
         exit_err(write_uint8(action, file_new), err_write);
-        if (is_command_id_shortdsc(action, "drop"))
+        if (   is_command_id_shortdsc(action, "drop")
+            || is_command_id_shortdsc(action, "use"))
         {
             uint8_t inventory_select = world.old_inventory_select;
             exit_err(write_uint8(inventory_select, file_new), err_write);