From 503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0 Mon Sep 17 00:00:00 2001 From: JK2K <39634161+JK2Kgit@users.noreply.github.com> Date: Fri, 20 Aug 2021 13:58:08 +0200 Subject: Slime spawinig in swamps (#5281) * test commit * hook test/ .gitignore * Slime add light limitation * Slime spawning moon light * Casting fix for clang * Removal of redundant changes Extracted moon phases amount to const --- src/MobSpawner.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') 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(std::floor(a_Chunk->GetWorld()->GetWorldAge().count() / 24000)) % AMOUNT_MOON_PHASES; + auto moonThreshold = static_cast(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)) + ) + ) ); } -- cgit v1.2.3