From 718eb227abe3b9a0e5277d663e32c6e10d51ab52 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 19 Sep 2014 23:00:54 +0200 Subject: Implemented mob spawner. --- src/MobSpawner.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/MobSpawner.cpp') diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index db05b70af..2350ffe85 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -126,8 +126,9 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome) { + cFastRandom Random; BLOCKTYPE TargetBlock = E_BLOCK_AIR; - if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock)) + if (a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock)) { if ((a_RelY + 1 > cChunkDef::Height) || (a_RelY - 1 < 0)) { @@ -177,7 +178,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (BlockBelow == E_BLOCK_GRASS) || (BlockBelow == E_BLOCK_LEAVES) || (BlockBelow == E_BLOCK_NEW_LEAVES) ) && (a_RelY >= 62) && - (m_Random.NextInt(3, a_Biome) != 0) + (Random.NextInt(3, a_Biome) != 0) ); } @@ -238,7 +239,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (!cBlockInfo::IsTransparent(BlockBelow)) && (SkyLight <= 7) && (BlockLight <= 7) && - (m_Random.NextInt(2, a_Biome) == 0) + (Random.NextInt(2, a_Biome) == 0) ); } @@ -262,7 +263,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!cBlockInfo::IsTransparent(BlockBelow)) && - (m_Random.NextInt(20, a_Biome) == 0) + (Random.NextInt(20, a_Biome) == 0) ); } @@ -322,8 +323,8 @@ cMonster* cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, // Make sure we are looking at the right chunk to spawn in a_Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ); - - if (CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_Biome)) + + if ((m_AllowedTypes.find(m_MobType) != m_AllowedTypes.end()) && CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_Biome)) { cMonster * newMob = cMonster::NewMonsterFromType(m_MobType); if (newMob) -- cgit v1.2.3 From ae47c00547f7bfd114f10aa2696f08b38ce3aea2 Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Mon, 1 Dec 2014 22:11:28 -0800 Subject: added spawning rule to mooshroom --- src/MobSpawner.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/MobSpawner.cpp') diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index a1d375e9e..b8f64807e 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -285,6 +285,19 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R ) ); } + + case mtMooshroom: + { + return ( + (TargetBlock == E_BLOCK_AIR) && + (BlockAbove == E_BLOCK_AIR) && + (!cBlockInfo::IsTransparent(BlockBelow)) && + ( + a_Biome == biMushroomShore || + a_Biome == biMushroomIsland + ) + ); + } default: { -- cgit v1.2.3 From 865b56766526906200cab7027b852f4b03dd89d6 Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Mon, 1 Dec 2014 22:13:52 -0800 Subject: extra formatting parentheses --- src/MobSpawner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/MobSpawner.cpp') diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index b8f64807e..6014cceb6 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -293,8 +293,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (BlockAbove == E_BLOCK_AIR) && (!cBlockInfo::IsTransparent(BlockBelow)) && ( - a_Biome == biMushroomShore || - a_Biome == biMushroomIsland + (a_Biome == biMushroomShore) || + (a_Biome == biMushroomIsland) ) ); } -- cgit v1.2.3 From 14bc241ec1e485421cf960db7f3b7c39237d9742 Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Tue, 2 Dec 2014 11:10:20 -0800 Subject: updated mooshroom check for mycelium --- src/MobSpawner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/MobSpawner.cpp') diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 6014cceb6..e477e2dac 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -291,7 +291,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R return ( (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && - (!cBlockInfo::IsTransparent(BlockBelow)) && + (BlockBelow == E_BLOCK_MYCELIUM) && ( (a_Biome == biMushroomShore) || (a_Biome == biMushroomIsland) -- cgit v1.2.3 From 44644ae0254bf3659c0995575041e2f656f20398 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 5 Dec 2014 12:56:53 +0100 Subject: Fixed reported parentheses around comparisons. --- src/MobSpawner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/MobSpawner.cpp') diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index e477e2dac..ee9e569a7 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -61,7 +61,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) { std::set allowedMobs; - if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore) + if ((a_Biome == biMushroomIsland) || (a_Biome == biMushroomShore)) { addIfAllowed(mtMooshroom, allowedMobs); } @@ -84,7 +84,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) addIfAllowed(mtCreeper, allowedMobs); addIfAllowed(mtSquid, allowedMobs); - if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean) + if ((a_Biome != biDesert) && (a_Biome != biBeach) && (a_Biome != biOcean)) { addIfAllowed(mtSheep, allowedMobs); addIfAllowed(mtPig, allowedMobs); @@ -93,11 +93,11 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) addIfAllowed(mtEnderman, allowedMobs); addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule - if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills) + if ((a_Biome == biForest) || (a_Biome == biForestHills) || (a_Biome == biTaiga) || (a_Biome == biTaigaHills)) { addIfAllowed(mtWolf, allowedMobs); } - else if (a_Biome == biJungle || a_Biome == biJungleHills) + else if ((a_Biome == biJungle) || (a_Biome == biJungleHills)) { addIfAllowed(mtOcelot, allowedMobs); } -- cgit v1.2.3