__attribute__((constructor)) static void init()
{
register_air_function((struct generator_function) {
- .chance = 25,
+ .corridor_chance = 25,
+ .room_chance = 50,
.callback = &spawn_apple,
});
}
__attribute__((constructor)) static void init()
{
register_air_function((struct generator_function) {
- .chance = 100,
+ .corridor_chance = 100,
+ .room_chance = 100,
.callback = &spawn_cherry,
});
}
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);
}
}
struct generator_function
{
- int chance;
+ int corridor_chance;
+ int room_chance;
void (*callback)(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,
});
}