]> git.lizzy.rs Git - dungeon_game.git/blobdiff - plugins/cherry/cherry.c
Replace dlmopen by dlopen
[dungeon_game.git] / plugins / cherry / cherry.c
index f9987704b93af46fb7d79e9e557f6a255f8360cf..96f0a2aeafe012758b9ac679fb0acb2ffdbc34f2 100644 (file)
@@ -3,11 +3,10 @@
 #include "../game/game.h"
 #include "../score/score.h"
 #include "../inventory/inventory.h"
+#include "../loot/loot.h"
 
 static bool use_cherry(struct itemstack *stack)
 {
-       (void) stack;
-
        add_health(&player, 2);
        return true;
 }
@@ -56,7 +55,7 @@ static struct entity cherry_entity = {
        .on_damage = NULL,
 };
 
-static void spawn_cherry(int x, int y)
+static void spawn_cherry(int x, int y, enum mg_context ctx)
 {
        spawn(cherry_entity, x, y, NULL);
 }
@@ -64,8 +63,16 @@ static void spawn_cherry(int x, int y)
 __attribute__((constructor)) static void init()
 {
        register_air_function((struct generator_function) {
-               .chance = 100,
+               .corridor_chance = 100,
+               .room_chance = 100,
                .callback = &spawn_cherry,
        });
+
+       register_loot((struct loot) {
+               .item = &cherry_item,
+               .chance = 2,
+               .min = 3,
+               .max = 10,
+       });
 }