diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-14 21:03:36 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-14 21:03:36 +0200 |
commit | 9d3ecc266d2e06f6cc8f2a310543b16edb8cbd56 (patch) | |
tree | b56ee1d3e61e3091b44ea186f86e44bceb58be06 | |
parent | 0f4153099c2a0d8fa4480dcd690820976df4a939 (diff) | |
download | dungeon_game-9d3ecc266d2e06f6cc8f2a310543b16edb8cbd56.tar.xz |
Separate air_function chances for rooms and corridors
-rw-r--r-- | plugins/apple/apple.c | 3 | ||||
-rw-r--r-- | plugins/cherry/cherry.c | 3 | ||||
-rw-r--r-- | plugins/game/game.c | 2 | ||||
-rw-r--r-- | plugins/game/game.h | 3 | ||||
-rw-r--r-- | plugins/monster/monster.c | 3 |
5 files changed, 9 insertions, 5 deletions
diff --git a/plugins/apple/apple.c b/plugins/apple/apple.c index 6adff08..8fbaf5b 100644 --- a/plugins/apple/apple.c +++ b/plugins/apple/apple.c @@ -42,7 +42,8 @@ static void spawn_apple(int x, int y, enum mg_context ctx) __attribute__((constructor)) static void init() { register_air_function((struct generator_function) { - .chance = 25, + .corridor_chance = 25, + .room_chance = 50, .callback = &spawn_apple, }); } diff --git a/plugins/cherry/cherry.c b/plugins/cherry/cherry.c index 1f96aca..1b0ac8a 100644 --- a/plugins/cherry/cherry.c +++ b/plugins/cherry/cherry.c @@ -62,7 +62,8 @@ static void spawn_cherry(int x, int y, enum mg_context ctx) __attribute__((constructor)) static void init() { register_air_function((struct generator_function) { - .chance = 100, + .corridor_chance = 100, + .room_chance = 100, .callback = &spawn_cherry, }); } diff --git a/plugins/game/game.c b/plugins/game/game.c index adcb59a..cc6d21d 100644 --- a/plugins/game/game.c +++ b/plugins/game/game.c @@ -334,7 +334,7 @@ static void mapgen_set_air(int x, int y, enum mg_context ctx) for (struct list *ptr = air_functions; ptr != NULL; ptr = ptr->next) { struct generator_function *func = ptr->element; - if (rand() % func->chance == 0) + if (rand() % (ctx == MG_CTX_CORRIDOR ? func->corridor_chance : func->room_chance) == 0) func->callback(x, y, ctx); } } diff --git a/plugins/game/game.h b/plugins/game/game.h index 74fea1c..656217e 100644 --- a/plugins/game/game.h +++ b/plugins/game/game.h @@ -71,7 +71,8 @@ enum mg_context struct generator_function { - int chance; + int corridor_chance; + int room_chance; void (*callback)(int x, int y, enum mg_context ctx); }; diff --git a/plugins/monster/monster.c b/plugins/monster/monster.c index a9e725c..d140005 100644 --- a/plugins/monster/monster.c +++ b/plugins/monster/monster.c @@ -68,7 +68,8 @@ static void spawn_monster(int x, int y, enum mg_context ctx) __attribute__((constructor)) static void init() { register_air_function((struct generator_function) { - .chance = 50, + .corridor_chance = 50, + .room_chance = 200, .callback = &spawn_monster, }); } |