summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Villager.cpp
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2018-02-03 12:24:19 +0100
committerAlexander Harkness <me@bearbin.net>2020-04-10 01:50:45 +0200
commit8438def87e40e43fd66d38dbf8cc287cea7de29b (patch)
tree647b7674cca3df58507e5311e5578d14084bc691 /src/Mobs/Villager.cpp
parentRe-enable darwin download from easyinstall.sh script (diff)
downloadcuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.tar
cuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.tar.gz
cuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.tar.bz2
cuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.tar.lz
cuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.tar.xz
cuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.tar.zst
cuberite-8438def87e40e43fd66d38dbf8cc287cea7de29b.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Villager.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 9558ba536..eca8ed2b6 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -107,6 +107,26 @@ void cVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+
+void cVillager::KilledBy(TakeDamageInfo & a_TDI)
+{
+ super::KilledBy(a_TDI);
+
+ // TODO: 0% chance on Easy, 50% chance on Normal and 100% chance on Hard
+ if (GetRandomProvider().RandBool(0.5) && (a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsMob()))
+ {
+ eMonsterType MonsterType = (static_cast<cMonster *>(a_TDI.Attacker)->GetMobType());
+ if ((MonsterType == mtZombie) || (MonsterType == mtZombieVillager))
+ {
+ m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtZombieVillager, false);
+ }
+ }
+}
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// Farmer functions:
@@ -203,7 +223,17 @@ bool cVillager::IsBlockFarmable(BLOCKTYPE a_BlockType)
{
return true;
}
+ default: return false;
}
- return false;
}
+
+
+
+
+cVillager::eVillagerType cVillager::GetRandomProfession()
+{
+ int Profession = GetRandomProvider().RandInt(cVillager::eVillagerType::vtMax - 1);
+
+ return static_cast<cVillager::eVillagerType>(Profession);
+}