new mob spawning pt2

This commit is contained in:
darkrose 2015-09-27 18:20:47 +10:00
parent 70636b3b4a
commit 5e04d79991
2 changed files with 13 additions and 6 deletions

View File

@ -609,9 +609,8 @@ void content_mob_init()
f->motion = MM_WANDER;
f->motion_type = MMT_SWIM;
f->moves_silently = true;
f->spawn_min_height = -30;
f->spawn_max_height = -2;
f->spawn_group = 3;
f->spawn_water = true;
f->hp = 5;
f->lifetime = 1200.0;
f->setCollisionBox(aabb3f(-0.25*BS, 0.25*BS, -0.25*BS, 0.25*BS, 0.75*BS, 0.25*BS));
@ -634,8 +633,7 @@ void content_mob_init()
f->motion = MM_SEEKER;
f->motion_type = MMT_SWIM;
f->moves_silently = true;
f->spawn_min_height = -30;
f->spawn_max_height = -2;
f->spawn_water = true;
f->notices_player = true;
f->attack_player_damage = 3;
f->attack_player_range = v3f(1,1,1);

View File

@ -988,10 +988,16 @@ void ServerEnvironment::step(float dtime)
active_object_count_wider += wblock->m_active_objects.size();
}
// TODO: don't spawn if there was a recent one nearby
if (
active_object_count_wider < 2
&& block->has_spawn_area
block->has_spawn_area
&& (
active_object_count_wider < 2
|| (
block->water_spawn
&& active_object_count_wider < 5
)
) && (
block->last_spawn < m_time_of_day-6000
|| block->last_spawn > m_time_of_day+6000
)
@ -1001,6 +1007,7 @@ void ServerEnvironment::step(float dtime)
MapNode n2 = block->getNodeNoEx(block->spawn_area+v3s16(0,2,0));
u8 light = n1.getLightBlend(getDayNightRatio());
if (block->water_spawn) {
printf("waterspawn\n");
if (n1.getContent() != CONTENT_WATERSOURCE || n2.getContent() != CONTENT_WATERSOURCE)
block->has_spawn_area = false;
}else{
@ -1027,6 +1034,7 @@ void ServerEnvironment::step(float dtime)
)
) && (
light >= LIGHT_SPAWN_BRIGHT
|| block->water_spawn
)
) {
mob_spawn_passive(block->spawn_area+block->getPosRelative(),block->water_spawn,this);
@ -1061,6 +1069,7 @@ void ServerEnvironment::step(float dtime)
if (
content_features(n1.getContent()).air_equivalent
&& content_features(n2.getContent()).air_equivalent
&& myrand_range(0,5) == 0
) {
block->spawn_area = p0;
block->has_spawn_area = true;