summaryrefslogtreecommitdiffstats
path: root/src/MobSpawner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MobSpawner.cpp')
-rw-r--r--src/MobSpawner.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index c04467fd3..b66179898 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -208,12 +208,29 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType
case mtMagmaCube:
case mtSlime:
{
+ const int AMOUNT_MOON_PHASES = 8;
+ auto maxLight = Random.RandInt(0, 7);
+ auto moonPhaseNumber = static_cast<int>(std::floor(a_Chunk->GetWorld()->GetWorldAge().count() / 24000)) % AMOUNT_MOON_PHASES;
+ auto moonThreshold = static_cast<float>(std::abs(moonPhaseNumber - (AMOUNT_MOON_PHASES / 2)) / (AMOUNT_MOON_PHASES / 2));
return
(
(TargetBlock == E_BLOCK_AIR) &&
(BlockAbove == E_BLOCK_AIR) &&
- ((!cBlockInfo::IsTransparent(BlockBelow)) || (a_DisableSolidBelowCheck)) &&
- ((a_RelPos.y <= 40) || (a_Biome == biSwampland))
+ (
+ (!cBlockInfo::IsTransparent(BlockBelow)) ||
+ (a_DisableSolidBelowCheck)) &&
+ (
+ (a_RelPos.y <= 40) ||
+ (
+ (a_Biome == biSwampland) &&
+ (a_RelPos.y >= 50) &&
+ (a_RelPos.y <= 70) &&
+ (SkyLight <= maxLight) &&
+ (BlockLight <= maxLight) &&
+ (Random.RandBool(moonThreshold)) &&
+ (Random.RandBool(0.5))
+ )
+ )
);
}