awful comment fixing, randomizer fix
This commit is contained in:
parent
8c3b9ae15b
commit
83d4bec369
@ -974,7 +974,7 @@ cFinishGenPassiveMobs::cFinishGenPassiveMobs(int a_Seed, cIniFile & a_IniFile, e
|
|||||||
}
|
}
|
||||||
} // switch (dimension)
|
} // switch (dimension)
|
||||||
m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage);
|
m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage);
|
||||||
if (m_AnimalProbability < 0 || m_AnimalProbability > 100)
|
if ((m_AnimalProbability < 0) || (m_AnimalProbability > 100))
|
||||||
{
|
{
|
||||||
LOGWARNING("[Animals]: AnimalSpawnChunkPercentage is invalid, using the default of \"%d\".", DefaultAnimalSpawnChunkPercentage);
|
LOGWARNING("[Animals]: AnimalSpawnChunkPercentage is invalid, using the default of \"%d\".", DefaultAnimalSpawnChunkPercentage);
|
||||||
}
|
}
|
||||||
@ -1001,7 +1001,7 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try spawning a pack center 10 times, should get roughly the same probability */
|
// Try spawning a pack center 10 times, should get roughly the same probability
|
||||||
for (int Tries = 0; Tries < 10; Tries++)
|
for (int Tries = 0; Tries < 10; Tries++)
|
||||||
{
|
{
|
||||||
int PackCenterX = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
|
int PackCenterX = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
|
||||||
@ -1010,8 +1010,8 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
int OffsetX = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
|
int OffsetX = (m_Noise.IntNoise2DInt(chunkX + chunkZ, Tries) / 7) % cChunkDef::Width;
|
||||||
int OffsetZ = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
|
int OffsetZ = (m_Noise.IntNoise2DInt(chunkX, chunkZ + Tries) / 7) % cChunkDef::Width;
|
||||||
TrySpawnAnimals(a_ChunkDesc, OffsetX, a_ChunkDesc.GetHeight(OffsetX, OffsetZ), OffsetZ, RandomMob);
|
TrySpawnAnimals(a_ChunkDesc, OffsetX, a_ChunkDesc.GetHeight(OffsetX, OffsetZ), OffsetZ, RandomMob);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1026,11 +1026,16 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
|
|||||||
|
|
||||||
bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, eMonsterType AnimalToSpawn)
|
bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, eMonsterType AnimalToSpawn)
|
||||||
{
|
{
|
||||||
|
if ((a_RelY >= cChunkDef::Height - 1) || (a_RelY <= 0))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BLOCKTYPE BlockAtHead = a_ChunkDesc.GetBlockType(a_RelX, a_RelY + 1, a_RelZ);
|
BLOCKTYPE BlockAtHead = a_ChunkDesc.GetBlockType(a_RelX, a_RelY + 1, a_RelZ);
|
||||||
BLOCKTYPE BlockAtFeet = a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ);
|
BLOCKTYPE BlockAtFeet = a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ);
|
||||||
BLOCKTYPE BlockUnderFeet = a_ChunkDesc.GetBlockType(a_RelX, a_RelY - 1, a_RelZ);
|
BLOCKTYPE BlockUnderFeet = a_ChunkDesc.GetBlockType(a_RelX, a_RelY - 1, a_RelZ);
|
||||||
|
|
||||||
/** Check block below (opaque, grass, water), and above (air) */
|
// Check block below (opaque, grass, water), and above (air)
|
||||||
if (AnimalToSpawn == mtSquid && BlockAtFeet != E_BLOCK_WATER)
|
if (AnimalToSpawn == mtSquid && BlockAtFeet != E_BLOCK_WATER)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -1087,53 +1092,61 @@ eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
|
|||||||
// No animals
|
// No animals
|
||||||
case biNether:
|
case biNether:
|
||||||
case biEnd:
|
case biEnd:
|
||||||
|
{
|
||||||
return mtInvalidType;
|
return mtInvalidType;
|
||||||
|
}
|
||||||
// Squid only
|
// Squid only
|
||||||
case biOcean:
|
case biOcean:
|
||||||
case biFrozenOcean:
|
case biFrozenOcean:
|
||||||
case biFrozenRiver:
|
case biFrozenRiver:
|
||||||
case biRiver:
|
case biRiver:
|
||||||
case biDeepOcean:
|
case biDeepOcean:
|
||||||
|
{
|
||||||
ListOfSpawnables.insert(MobIter, mtSquid);
|
ListOfSpawnables.insert(MobIter, mtSquid);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
// Mooshroom only
|
// Mooshroom only
|
||||||
case biMushroomIsland:
|
case biMushroomIsland:
|
||||||
case biMushroomShore:
|
case biMushroomShore:
|
||||||
|
{
|
||||||
ListOfSpawnables.insert(MobIter, mtMooshroom);
|
ListOfSpawnables.insert(MobIter, mtMooshroom);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case biJungle:
|
case biJungle:
|
||||||
case biJungleHills:
|
case biJungleHills:
|
||||||
case biJungleEdge:
|
case biJungleEdge:
|
||||||
case biJungleM:
|
case biJungleM:
|
||||||
case biJungleEdgeM:
|
case biJungleEdgeM:
|
||||||
|
{
|
||||||
ListOfSpawnables.insert(MobIter, mtOcelot);
|
ListOfSpawnables.insert(MobIter, mtOcelot);
|
||||||
|
}
|
||||||
case biPlains:
|
case biPlains:
|
||||||
case biSunflowerPlains:
|
case biSunflowerPlains:
|
||||||
case biSavanna:
|
case biSavanna:
|
||||||
case biSavannaPlateau:
|
case biSavannaPlateau:
|
||||||
case biSavannaM:
|
case biSavannaM:
|
||||||
case biSavannaPlateauM:
|
case biSavannaPlateauM:
|
||||||
|
{
|
||||||
ListOfSpawnables.insert(MobIter, mtHorse);
|
ListOfSpawnables.insert(MobIter, mtHorse);
|
||||||
// ListOfSpawnables.insert(mtDonkey);
|
// ListOfSpawnables.insert(mtDonkey);
|
||||||
|
}
|
||||||
// Wolves only
|
// Wolves only
|
||||||
case biForest:
|
case biForest:
|
||||||
case biTaiga:
|
case biTaiga:
|
||||||
case biMegaTaiga:
|
case biMegaTaiga:
|
||||||
case biColdTaiga:
|
case biColdTaiga:
|
||||||
case biColdTaigaM:
|
case biColdTaigaM:
|
||||||
|
{
|
||||||
ListOfSpawnables.insert(MobIter, mtWolf);
|
ListOfSpawnables.insert(MobIter, mtWolf);
|
||||||
|
}
|
||||||
// All other mobs
|
// All other mobs
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
ListOfSpawnables.insert(MobIter, mtChicken);
|
ListOfSpawnables.insert(MobIter, mtChicken);
|
||||||
ListOfSpawnables.insert(MobIter, mtCow);
|
ListOfSpawnables.insert(MobIter, mtCow);
|
||||||
ListOfSpawnables.insert(MobIter, mtPig);
|
ListOfSpawnables.insert(MobIter, mtPig);
|
||||||
ListOfSpawnables.insert(MobIter, mtSheep);
|
ListOfSpawnables.insert(MobIter, mtSheep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ListOfSpawnables.empty())
|
if (ListOfSpawnables.empty())
|
||||||
|
@ -318,28 +318,28 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** This class populates generated chunks with packs of biome-dependant animals
|
|
||||||
Animals: cows, sheep, pigs, mooshrooms, squid, horses, wolves, ocelots
|
|
||||||
*/
|
|
||||||
class cFinishGenPassiveMobs :
|
class cFinishGenPassiveMobs :
|
||||||
public cFinishGen
|
public cFinishGen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/** This class populates generated chunks with packs of biome-dependant animals
|
||||||
|
Animals: cows, sheep, pigs, mooshrooms, squid, horses, wolves, ocelots
|
||||||
|
*/
|
||||||
cFinishGenPassiveMobs(int a_Seed, cIniFile & a_IniFile, eDimension a_Dimension);
|
cFinishGenPassiveMobs(int a_Seed, cIniFile & a_IniFile, eDimension a_Dimension);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
cNoise m_Noise;
|
cNoise m_Noise;
|
||||||
int m_AnimalProbability; /** Chance, [0..100], that an animal pack will be generated in a chunk */
|
int m_AnimalProbability; // Chance, [0..100], that an animal pack will be generated in a chunk
|
||||||
|
|
||||||
/** cFinishGen override: */
|
// cFinishGen override:
|
||||||
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
|
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
|
||||||
|
|
||||||
/** Tries to spawn a mob in the center of the pack. If successful, spawns 0-5 more. */
|
// Returns false if an animal cannot spawn at given coords, else adds it to the chunk's entity list and returns true
|
||||||
bool TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int x, int y, int z, eMonsterType AnimalToSpawn);
|
bool TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int x, int y, int z, eMonsterType AnimalToSpawn);
|
||||||
|
|
||||||
/** Gets a random mob from biome-dependant list */
|
// Gets a random animal from biome-dependant list
|
||||||
eMonsterType GetRandomMob(cChunkDesc & a_ChunkDesc);
|
eMonsterType GetRandomMob(cChunkDesc & a_ChunkDesc);
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user