forked from oerkki/voxelands
give per-mob spawn chances
This commit is contained in:
parent
143806fa91
commit
121b01ccdf
|
@ -97,7 +97,7 @@ void MobFeatures::setAnimationFrames(MobAnimation type, int start, int end)
|
|||
|
||||
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
|
||||
|
||||
bool content_mob_spawn(ServerEnvironment *env, v3s16 pos)
|
||||
bool content_mob_spawn(ServerEnvironment *env, v3s16 pos, u32 active_object_count)
|
||||
{
|
||||
assert(env);
|
||||
Map *map = &env->getMap();
|
||||
|
@ -119,6 +119,8 @@ bool content_mob_spawn(ServerEnvironment *env, v3s16 pos)
|
|||
MobFeatures m = i->second;
|
||||
if (m.spawn_in == CONTENT_IGNORE && m.spawn_on == CONTENT_IGNORE)
|
||||
continue;
|
||||
if (m.spawn_max_nearby_mobs > active_object_count)
|
||||
continue;
|
||||
if (m.spawn_min_height > pos.Y)
|
||||
continue;
|
||||
if (m.spawn_max_height < pos.Y)
|
||||
|
@ -139,6 +141,8 @@ bool content_mob_spawn(ServerEnvironment *env, v3s16 pos)
|
|||
continue;
|
||||
if (m.level > level)
|
||||
continue;
|
||||
if (myrand_range(0,m.spawn_chance) != 0)
|
||||
continue;
|
||||
can.push_back(i->first);
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,8 @@ struct MobFeatures {
|
|||
u8 spawn_max_light;
|
||||
s16 spawn_min_height;
|
||||
s16 spawn_max_height;
|
||||
u8 spawn_max_nearby_mobs;
|
||||
s16 spawn_chance;
|
||||
|
||||
MobFeatures()
|
||||
{
|
||||
|
@ -236,6 +238,8 @@ struct MobFeatures {
|
|||
spawn_max_light = LIGHT_MAX;
|
||||
spawn_min_height = -20000;
|
||||
spawn_max_height = 100;
|
||||
spawn_max_nearby_mobs = 3;
|
||||
spawn_chance = 100;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -258,7 +262,7 @@ inline std::string mobLevelS(u8 level)
|
|||
}
|
||||
|
||||
class ServerEnvironment;
|
||||
bool content_mob_spawn(ServerEnvironment *env, v3s16 pos);
|
||||
bool content_mob_spawn(ServerEnvironment *env, v3s16 pos, u32 active_object_count);
|
||||
|
||||
MobFeatures & content_mob_features(content_t i);
|
||||
void content_mob_init();
|
||||
|
|
|
@ -949,10 +949,8 @@ void ServerEnvironment::step(float dtime)
|
|||
v3s16 p = p0 + block->getPosRelative();
|
||||
MapNode n = block->getNodeNoEx(p0);
|
||||
|
||||
if (active_object_count_wider < 3 && myrand()%100 == 0) {
|
||||
if (content_mob_spawn(this,p))
|
||||
active_object_count_wider++;
|
||||
}
|
||||
if (content_mob_spawn(this,p,active_object_count_wider))
|
||||
active_object_count_wider++;
|
||||
|
||||
switch(n.getContent()) {
|
||||
case CONTENT_GRASS_FOOTSTEPS:
|
||||
|
|
Loading…
Reference in New Issue