summaryrefslogtreecommitdiffstats
path: root/src/Generating/DungeonRoomsFinisher.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-12-04 22:04:16 +0100
committerMattes D <github@xoft.cz>2014-12-04 22:04:16 +0100
commitc014f5624c1eda400c08c305978bbcef3f554ff3 (patch)
treefd15deecb2e9afa17443f9b8a8c51676ad6e0145 /src/Generating/DungeonRoomsFinisher.cpp
parentFixed indent. (diff)
parentMerge pull request #1645 from jonfabe/SpectatorModeFixes (diff)
downloadcuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar
cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.gz
cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.bz2
cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.lz
cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.xz
cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.tar.zst
cuberite-c014f5624c1eda400c08c305978bbcef3f554ff3.zip
Diffstat (limited to 'src/Generating/DungeonRoomsFinisher.cpp')
-rw-r--r--src/Generating/DungeonRoomsFinisher.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Generating/DungeonRoomsFinisher.cpp b/src/Generating/DungeonRoomsFinisher.cpp
index 7ab22c2c5..092e232ab 100644
--- a/src/Generating/DungeonRoomsFinisher.cpp
+++ b/src/Generating/DungeonRoomsFinisher.cpp
@@ -7,6 +7,7 @@
#include "DungeonRoomsFinisher.h"
#include "../FastRandom.h"
#include "../BlockEntities/ChestEntity.h"
+#include "../BlockEntities/MobSpawnerEntity.h"
@@ -57,6 +58,22 @@ public:
int SecondChestPos = (FirstChestPos + 2 + (rnd % (NumPositions - 3))) % NumPositions;
m_Chest1 = DecodeChestCoords(FirstChestPos, SizeX, SizeZ);
m_Chest2 = DecodeChestCoords(SecondChestPos, SizeX, SizeZ);
+
+ // Choose what the mobspawner will spawn.
+ // 25% chance for a spider, 25% for a skeleton and 50% chance to get a zombie spawer.
+ int MobType = (a_Noise.IntNoise3DInt(a_OriginX, m_FloorHeight, a_OriginZ) / 7) % 100;
+ if (MobType <= 25)
+ {
+ m_MonsterType = mtSkeleton;
+ }
+ else if (MobType <= 50)
+ {
+ m_MonsterType = mtSpider;
+ }
+ else
+ {
+ m_MonsterType = mtZombie;
+ }
}
protected:
@@ -76,6 +93,8 @@ protected:
/** The (absolute) coords of the second chest. The Y coord represents the chest's Meta value (facing). */
Vector3i m_Chest2;
+ /** The monster type for the mobspawner entity. */
+ eMonsterType m_MonsterType;
/** Decodes the position index along the room walls into a proper 2D position for a chest.
@@ -246,7 +265,9 @@ protected:
)
{
a_ChunkDesc.SetBlockTypeMeta(CenterX, b, CenterZ, E_BLOCK_MOB_SPAWNER, 0);
- // TODO: Set the spawned mob
+ cMobSpawnerEntity * MobSpawner = static_cast<cMobSpawnerEntity *>(a_ChunkDesc.GetBlockEntity(CenterX, b, CenterZ));
+ ASSERT((MobSpawner != nullptr) && (MobSpawner->GetBlockType() == E_BLOCK_MOB_SPAWNER));
+ MobSpawner->SetEntity(m_MonsterType);
}
}
} ;