diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-06-28 12:59:09 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-06-28 12:59:09 +0200 |
commit | bef84b4821724c7119a3cb007d9e1265a56a27f0 (patch) | |
tree | be97c10e8101eafeccc2d8da03a98f399b3b08d3 | |
parent | Added generic entity-collecting. (diff) | |
download | cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.tar cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.tar.gz cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.tar.bz2 cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.tar.lz cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.tar.xz cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.tar.zst cuberite-bef84b4821724c7119a3cb007d9e1265a56a27f0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Monster.cpp | 2 | ||||
-rw-r--r-- | src/Mobs/Sheep.cpp | 41 | ||||
-rw-r--r-- | src/Mobs/Sheep.h | 2 |
3 files changed, 42 insertions, 3 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 5843ca5a6..5ffd645b3 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -900,7 +900,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) 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 mtSheep: toReturn = new cSheep(); break; case mtSilverfish: toReturn = new cSilverfish(); break; case mtSnowGolem: toReturn = new cSnowGolem(); break; case mtSpider: toReturn = new cSpider(); break; diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 5a6b760af..cc7315a86 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -5,6 +5,7 @@ #include "../BlockID.h" #include "../Entities/Player.h" #include "../World.h" +#include "FastRandom.h" @@ -16,6 +17,43 @@ cSheep::cSheep(int a_Color) : m_WoolColor(a_Color), m_TimeToStopEating(-1) { + // Generate random wool color. + if (m_WoolColor == -1) + { + cFastRandom Random; + int Chance = Random.NextInt(101); + + if (Chance <= 81) + { + // White + m_WoolColor = 0; + } + else if (Chance <= 86) + { + // Black + m_WoolColor = 15; + } + else if (Chance <= 91) + { + // Grey + m_WoolColor = 7; + } + else if (Chance <= 96) + { + // Light grey + m_WoolColor = 8; + } + else if (Chance <= 99) + { + // Brown + m_WoolColor = 12; + } + else + { + // Pink + m_WoolColor = 6; + } + } } @@ -37,7 +75,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSheep::OnRightClicked(cPlayer & a_Player) { const cItem & EquippedItem = a_Player.GetEquippedItem(); - if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared)) + if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && !IsSheared() && !IsBaby()) { m_IsSheared = true; m_World->BroadcastEntityMetadata(*this); @@ -51,6 +89,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) int NumDrops = m_World->GetTickRandomNumber(2) + 1; Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); + m_World->BroadcastSoundEffect("mob.sheep.shear", POSX_TOINT * 8, POSY_TOINT * 8, POSZ_TOINT * 8, 1.0f, 1.0f); } else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage)) { diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 402e8e61c..14da81364 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -13,7 +13,7 @@ class cSheep : typedef cPassiveMonster super; public: - cSheep(int a_Color); + cSheep(int a_Color = -1); CLASS_PROTODEF(cSheep); |