diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 6589e002a..271045491 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -1,6 +1,7 @@ #include #include "spells/shipcurse.h" #include "monster.h" +#include "monsters.h" #include #include @@ -28,7 +29,6 @@ static int tolua_levitate_ship(lua_State * L) } extern void spawn_undead(void); -extern void spawn_dragons(void); extern void plan_monsters(struct faction *f); static int tolua_planmonsters(lua_State * L) diff --git a/src/monsters.c b/src/monsters.c index 2fc2fcde3..67bf9370d 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -20,6 +20,8 @@ #include #include +#include "monsters.h" + #include "economy.h" #include "chaos.h" #include "give.h" @@ -883,7 +885,16 @@ static int nrand(int start, int sub) return res; } -/** Drachen und Seeschlangen können entstehen */ +unit *spawn_seaserpent(region *r, faction *f) { + unit *u = create_unit(r, f, 1, get_race(RC_SEASERPENT), 0, NULL, NULL); + fset(u, UFL_ISNEW | UFL_MOVED); + equip_unit(u, get_equipment("monster_seaserpent")); + return u; +} + +/** + * Drachen und Seeschlangen können entstehen + */ void spawn_dragons(void) { region *r; @@ -892,13 +903,12 @@ void spawn_dragons(void) for (r = regions; r; r = r->next) { unit *u; - if (fval(r->terrain, SEA_REGION) && rng_int() % 10000 < 1) { - u = create_unit(r, monsters, 1, get_race(RC_SEASERPENT), 0, NULL, NULL); - fset(u, UFL_ISNEW | UFL_MOVED); - equip_unit(u, get_equipment("monster_seaserpent")); + if (fval(r->terrain, SEA_REGION)) { + if (rng_int() % 10000 < 1) { + u = spawn_seaserpent(r, monsters); + } } - - if ((r->terrain == newterrain(T_GLACIER) + else if ((r->terrain == newterrain(T_GLACIER) || r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_DESERT)) && rng_int() % 10000 < (5 + 100 * chaosfactor(r))) { diff --git a/src/monsters.h b/src/monsters.h new file mode 100644 index 000000000..02e41c0a4 --- /dev/null +++ b/src/monsters.h @@ -0,0 +1,8 @@ +#pragma once + +struct unit; +struct region; +struct faction; + +struct unit *spawn_seaserpent(struct region *r, struct faction *f); +void spawn_dragons(void);