Separate air_function chances for rooms and corridors
parent
0f4153099c
commit
9d3ecc266d
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue