Skip to content

Commit

Permalink
Dungeons spawners now spawn mobs
Browse files Browse the repository at this point in the history
25% for a spider, 25% for a skeleton and 50% for a zombie spawner.
  • Loading branch information
NiLSPACE committed Dec 1, 2014
1 parent 1bf0827 commit c0b08a6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Generating/DungeonRoomsFinisher.cpp
Expand Up @@ -7,6 +7,7 @@
#include "DungeonRoomsFinisher.h"
#include "../FastRandom.h"
#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/MobSpawnerEntity.h"



Expand Down Expand Up @@ -57,6 +58,22 @@ class cDungeonRoom :
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.
NOISE_DATATYPE MobType = a_Noise.IntNoise3D(a_OriginX, m_FloorHeight, a_OriginZ);
if (MobType <= -0.5)
{
m_MonsterType = mtSkeleton;
}
else if (MobType <= 0)
{
m_MonsterType = mtSpider;
}
else
{
m_MonsterType = mtZombie;
}
}

protected:
Expand All @@ -76,6 +93,8 @@ class cDungeonRoom :
/** 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.
Expand Down Expand Up @@ -246,7 +265,9 @@ class cDungeonRoom :
)
{
a_ChunkDesc.SetBlockTypeMeta(CenterX, b, CenterZ, E_BLOCK_MOB_SPAWNER, 0);
// TODO: Set the spawned mob
cMobSpawnerEntity * MobSpawner = (cMobSpawnerEntity *)a_ChunkDesc.GetBlockEntity(CenterX, b, CenterZ);
ASSERT((MobSpawner != nullptr) && (MobSpawner->GetBlockType() == E_BLOCK_MOB_SPAWNER));
MobSpawner->SetEntity(m_MonsterType);
}
}
} ;
Expand Down

0 comments on commit c0b08a6

Please sign in to comment.