Got spiders and other mobs respecting night and day for spawning
This commit is contained in:
parent
16bac5ace9
commit
47283f9daa
@ -533,7 +533,8 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
|
|||||||
|
|
||||||
if (IsLightValid())
|
if (IsLightValid())
|
||||||
{
|
{
|
||||||
cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess);
|
int TimeOfDay = m_World->GetTimeOfDay();
|
||||||
|
cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, TimeOfDay, MaxNbOfSuccess);
|
||||||
if (newMob)
|
if (newMob)
|
||||||
{
|
{
|
||||||
int WorldX, WorldY, WorldZ;
|
int WorldX, WorldY, WorldZ;
|
||||||
|
@ -124,7 +124,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
|
bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, int a_TimeOfDay, EMCSBiome a_Biome)
|
||||||
{
|
{
|
||||||
BLOCKTYPE TargetBlock;
|
BLOCKTYPE TargetBlock;
|
||||||
BLOCKTYPE BlockAbove;
|
BLOCKTYPE BlockAbove;
|
||||||
@ -144,7 +144,7 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
|
|||||||
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
|
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
|
||||||
|
|
||||||
case cMonster::mtBat:
|
case cMonster::mtBat:
|
||||||
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && (!g_BlockTransparent[BlockAbove]);
|
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4 || a_TimeOfDay > 12500) && (TargetBlock == E_BLOCK_AIR) && (!g_BlockTransparent[BlockAbove]);
|
||||||
|
|
||||||
case cMonster::mtChicken:
|
case cMonster::mtChicken:
|
||||||
case cMonster::mtCow:
|
case cMonster::mtCow:
|
||||||
@ -153,7 +153,7 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
|
|||||||
case cMonster::mtSheep:
|
case cMonster::mtSheep:
|
||||||
{
|
{
|
||||||
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
||||||
(BlockBelow == E_BLOCK_GRASS) && (SkyLight >= 9);
|
(BlockBelow == E_BLOCK_GRASS) && (SkyLight >= 9) && (a_TimeOfDay <= 12500);
|
||||||
}
|
}
|
||||||
|
|
||||||
case cMonster::mtOcelot:
|
case cMonster::mtOcelot:
|
||||||
@ -168,34 +168,42 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
|
|||||||
BLOCKTYPE BlockTop;
|
BLOCKTYPE BlockTop;
|
||||||
a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 2, a_RelZ, BlockTop);
|
a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 2, a_RelZ, BlockTop);
|
||||||
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (BlockTop == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (BlockTop == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
||||||
(SkyLight <= 7) && (BlockLight <= 7);
|
((SkyLight <= 7) || a_TimeOfDay > 12500 ) && (BlockLight <= 7) ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cMonster::mtSpider:
|
case cMonster::mtSpider:
|
||||||
{
|
{
|
||||||
bool CanSpawn = true;
|
bool CanSpawn = true;
|
||||||
for (int x = -1; x < 2; ++x)
|
bool HaveFloor = false;
|
||||||
|
for (int x = 0; x < 2; ++x)
|
||||||
{
|
{
|
||||||
for(int z = -1; z < 2; ++x)
|
for(int z = 0; z < 2; ++z)
|
||||||
{
|
{
|
||||||
CanSpawn = a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY, a_RelZ + z, TargetBlock);
|
CanSpawn = a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY, a_RelZ + z, TargetBlock);
|
||||||
CanSpawn = CanSpawn && (TargetBlock == E_BLOCK_AIR);
|
CanSpawn = CanSpawn && (TargetBlock == E_BLOCK_AIR);
|
||||||
if (!CanSpawn)
|
if (!CanSpawn)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!HaveFloor)
|
||||||
|
{
|
||||||
|
a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY - 1, a_RelZ + z, TargetBlock);
|
||||||
|
HaveFloor = HaveFloor || !g_BlockTransparent[TargetBlock];
|
||||||
}
|
}
|
||||||
return CanSpawn && (!g_BlockTransparent[BlockBelow]) && (SkyLight <= 7) && (BlockLight <= 7);
|
}
|
||||||
|
}
|
||||||
|
return CanSpawn && HaveFloor && ((SkyLight <= 7) || a_TimeOfDay > 12500) && (BlockLight <= 7);
|
||||||
|
|
||||||
}
|
}
|
||||||
case cMonster::mtCreeper:
|
case cMonster::mtCreeper:
|
||||||
case cMonster::mtZombie:
|
case cMonster::mtZombie:
|
||||||
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
||||||
(SkyLight <= 7) && (BlockLight <= 7) && (m_Random.NextInt(2,a_Biome) == 0);
|
((SkyLight <= 7) || a_TimeOfDay > 12500) && (BlockLight <= 7) && (m_Random.NextInt(2,a_Biome) == 0);
|
||||||
|
|
||||||
case cMonster::mtSlime:
|
case cMonster::mtSlime:
|
||||||
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
||||||
(a_RelY <= 40);
|
((a_RelY <= 40) || a_Biome == biSwampland);
|
||||||
case cMonster::mtGhast:
|
case cMonster::mtGhast:
|
||||||
case cMonster::mtZombiePigman:
|
case cMonster::mtZombiePigman:
|
||||||
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
|
||||||
@ -212,7 +220,7 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize)
|
cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int a_TimeOfDay, int& a_MaxPackSize)
|
||||||
{
|
{
|
||||||
cMonster* toReturn = NULL;
|
cMonster* toReturn = NULL;
|
||||||
if (m_NewPack)
|
if (m_NewPack)
|
||||||
@ -234,7 +242,7 @@ cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_Biome))
|
if (CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_TimeOfDay, a_Biome))
|
||||||
{
|
{
|
||||||
cMonster * newMob = cMonster::NewMonsterFromType(m_MobType);
|
cMonster * newMob = cMonster::NewMonsterFromType(m_MobType);
|
||||||
if (newMob)
|
if (newMob)
|
||||||
|
@ -39,7 +39,7 @@ public :
|
|||||||
// if this is the first of a Pack : determine the type of monster
|
// if this is the first of a Pack : determine the type of monster
|
||||||
// BlockType & BlockMeta are used to decide what kind of Mob can Spawn here
|
// BlockType & BlockMeta are used to decide what kind of Mob can Spawn here
|
||||||
// MaxPackSize is set to the maximal size for a pack this type of mob
|
// MaxPackSize is set to the maximal size for a pack this type of mob
|
||||||
cMonster * TryToSpawnHere(const cChunk * a_Chunk, int A_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize);
|
cMonster * TryToSpawnHere(const cChunk * a_Chunk, int A_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int a_TimeOfDay, int& a_MaxPackSize);
|
||||||
|
|
||||||
// mark the beginning of a new Pack
|
// mark the beginning of a new Pack
|
||||||
// all mobs of the same Pack are the same type
|
// all mobs of the same Pack are the same type
|
||||||
@ -53,7 +53,7 @@ public :
|
|||||||
|
|
||||||
protected :
|
protected :
|
||||||
// return true if specified type of mob can spawn on specified block
|
// return true if specified type of mob can spawn on specified block
|
||||||
bool CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
|
bool CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, int a_TimeOfDay, EMCSBiome a_Biome);
|
||||||
|
|
||||||
// return a random type that can spawn on specified biome.
|
// return a random type that can spawn on specified biome.
|
||||||
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
|
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
|
||||||
|
Loading…
Reference in New Issue
Block a user