split out seaserpent creation for testing

This commit is contained in:
Enno Rehling 2016-08-31 11:35:07 +02:00
parent 61a1cfa141
commit 9a72157cf3
3 changed files with 26 additions and 8 deletions

View File

@ -1,6 +1,7 @@
#include <platform.h>
#include "spells/shipcurse.h"
#include "monster.h"
#include "monsters.h"
#include <kernel/equipment.h>
#include <kernel/faction.h>
@ -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)

View File

@ -20,6 +20,8 @@
#include <platform.h>
#include <kernel/config.h>
#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))) {

8
src/monsters.h Normal file
View File

@ -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);