summaryrefslogtreecommitdiffstats
path: root/source/Mobs
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-11-13 11:08:51 +0100
committermadmaxoft <github@xoft.cz>2013-11-13 11:08:51 +0100
commit293051eca89351181f11443e1785617ab58459c8 (patch)
tree50c637b3c2ac3f1848610623156ce96be1b91be5 /source/Mobs
parentcWindow: Fixed item dupe glitch with painting (#278) (diff)
parentBundled fixes [SEE DESC] (diff)
downloadcuberite-293051eca89351181f11443e1785617ab58459c8.tar
cuberite-293051eca89351181f11443e1785617ab58459c8.tar.gz
cuberite-293051eca89351181f11443e1785617ab58459c8.tar.bz2
cuberite-293051eca89351181f11443e1785617ab58459c8.tar.lz
cuberite-293051eca89351181f11443e1785617ab58459c8.tar.xz
cuberite-293051eca89351181f11443e1785617ab58459c8.tar.zst
cuberite-293051eca89351181f11443e1785617ab58459c8.zip
Diffstat (limited to 'source/Mobs')
-rw-r--r--source/Mobs/Horse.cpp8
-rw-r--r--source/Mobs/Monster.cpp95
-rw-r--r--source/Mobs/Monster.h7
3 files changed, 60 insertions, 50 deletions
diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp
index d18887ea4..bb9a4e3f6 100644
--- a/source/Mobs/Horse.cpp
+++ b/source/Mobs/Horse.cpp
@@ -55,10 +55,10 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_World->GetTickRandomNumber(50) == 25)
{
- m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 0);
- m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 2);
- m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 6);
- m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 8);
+ m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 0);
+ m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 2);
+ m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 6);
+ m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 8);
m_Attachee->Detach();
m_bIsRearing = true;
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp
index 9d2be1e29..8a5717e27 100644
--- a/source/Mobs/Monster.cpp
+++ b/source/Mobs/Monster.cpp
@@ -622,65 +622,78 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
-cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size)
+cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
{
cFastRandom Random;
-
cMonster * toReturn = NULL;
- // unspecified size get rand[1,3] for Monsters that need size
+ // Create the mob entity
switch (a_MobType)
{
case mtMagmaCube:
case mtSlime:
{
- if (a_Size == -1)
+ toReturn = new cSlime (Random.NextInt(2) + 1);
+ break;
+ }
+ case mtSkeleton:
+ {
+ // TODO: Actual detection of spawning in Nether
+ toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true);
+ break;
+ }
+ case mtVillager:
+ {
+ int VillagerType = Random.NextInt(6);
+ if (VillagerType == 6)
{
- a_Size = Random.NextInt(2, a_MobType) + 1;
+ // Give farmers a better chance of spawning
+ VillagerType = 0;
}
- if ((a_Size <= 0) || (a_Size >= 4))
+
+ toReturn = new cVillager((cVillager::eVillagerType)VillagerType);
+ break;
+ }
+ case mtHorse:
+ {
+ // Horses take a type (species), a colour, and a style (dots, stripes, etc.)
+ int HorseType = Random.NextInt(7);
+ int HorseColor = Random.NextInt(6);
+ int HorseStyle = Random.NextInt(6);
+ int HorseTameTimes = Random.NextInt(6) + 1;
+
+ if ((HorseType == 5) || (HorseType == 6) || (HorseType == 7))
{
- ASSERT(!"Random for size was supposed to pick in [1..3] and picked outside");
- a_Size = 1;
+ // Increase chances of normal horse (zero)
+ HorseType = 0;
}
+
+ toReturn = new cHorse(HorseType, HorseColor, HorseStyle, HorseTameTimes);
break;
}
- default: break;
- } // switch (a_MobType)
- // Create the mob entity
- switch (a_MobType)
- {
- case mtMagmaCube: toReturn = new cMagmaCube(a_Size); break;
- case mtSlime: toReturn = new cSlime(a_Size); break;
- case mtBat: toReturn = new cBat(); break;
- case mtBlaze: toReturn = new cBlaze(); break;
- case mtCaveSpider: toReturn = new cCavespider(); break;
- case mtChicken: toReturn = new cChicken(); break;
- case mtCow: toReturn = new cCow(); break;
- case mtCreeper: toReturn = new cCreeper(); break;
- case mtEnderman: toReturn = new cEnderman(); break;
- case mtGhast: toReturn = new cGhast(); break;
- // TODO:
- // case cMonster::mtHorse: toReturn = new cHorse(); break;
- case mtMooshroom: toReturn = new cMooshroom(); break;
- case mtOcelot: toReturn = new cOcelot(); break;
- case mtPig: toReturn = new cPig(); break;
- // TODO: Implement sheep color
- case mtSheep: toReturn = new cSheep(0); break;
- case mtSilverfish: toReturn = new cSilverfish(); break;
- // TODO: Implement wither skeleton geration
- case mtSkeleton: toReturn = new cSkeleton(false); break;
- case mtSpider: toReturn = new cSpider(); break;
- case mtSquid: toReturn = new cSquid(); break;
- case mtVillager: toReturn = new cVillager(cVillager::vtFarmer); break;
- case mtWitch: toReturn = new cWitch(); break;
- case mtWolf: toReturn = new cWolf(); break;
- case mtZombie: toReturn = new cZombie(false); break;
- case mtZombiePigman: toReturn = new cZombiePigman(); break;
+ case mtBat: toReturn = new cBat(); break;
+ case mtBlaze: toReturn = new cBlaze(); break;
+ case mtCaveSpider: toReturn = new cCavespider(); break;
+ case mtChicken: toReturn = new cChicken(); break;
+ case mtCow: toReturn = new cCow(); break;
+ case mtCreeper: toReturn = new cCreeper(); break;
+ case mtEnderman: toReturn = new cEnderman(); break;
+ case mtGhast: toReturn = new cGhast(); break;
+ case mtMooshroom: toReturn = new cMooshroom(); break;
+ case mtOcelot: toReturn = new cOcelot(); break;
+ case mtPig: toReturn = new cPig(); break;
+ case mtSheep: toReturn = new cSheep (Random.NextInt(15)); break; // Colour parameter
+ case mtSilverfish: toReturn = new cSilverfish(); break;
+ case mtSpider: toReturn = new cSpider(); break;
+ case mtSquid: toReturn = new cSquid(); break;
+ case mtWitch: toReturn = new cWitch(); break;
+ case mtWolf: toReturn = new cWolf(); break;
+ case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter
+ case mtZombiePigman: toReturn = new cZombiePigman(); break;
default:
{
- ASSERT(!"Unhandled Mob type");
+ ASSERT(!"Unhandled mob type whilst trying to spawn mob!");
}
}
return toReturn;
diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h
index a0002bf4f..29a705d11 100644
--- a/source/Mobs/Monster.h
+++ b/source/Mobs/Monster.h
@@ -153,12 +153,9 @@ public:
/** Creates a new object of the specified mob.
a_MobType is the type of the mob to be created
- a_Size is the size (for mobs with size)
- if a_Size is let to -1 for entities that need size, size will be random
- asserts and returns null if mob type is not specified
- asserts if invalid size for mobs that need size
+ Asserts and returns null if mob type is not specified
*/
- static cMonster * NewMonsterFromType(eType a_MobType, int a_Size = -1);
+ static cMonster * NewMonsterFromType(eType a_MobType);
protected: