diff options
author | Bond-009 <bond.009@outlook.com> | 2018-02-03 12:24:19 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2020-04-10 01:50:45 +0200 |
commit | 8438def87e40e43fd66d38dbf8cc287cea7de29b (patch) | |
tree | 647b7674cca3df58507e5311e5578d14084bc691 /src/Mobs/ZombieVillager.cpp | |
parent | Re-enable darwin download from easyinstall.sh script (diff) | |
download | cuberite-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 'src/Mobs/ZombieVillager.cpp')
-rw-r--r-- | src/Mobs/ZombieVillager.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/Mobs/ZombieVillager.cpp b/src/Mobs/ZombieVillager.cpp new file mode 100644 index 000000000..9d17e6038 --- /dev/null +++ b/src/Mobs/ZombieVillager.cpp @@ -0,0 +1,87 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "ZombieVillager.h" +#include "../World.h" +#include "../LineBlockTracer.h" +#include "../Entities/Player.h" + + + + + +cZombieVillager::cZombieVillager(cVillager::eVillagerType a_Profession) : + super("ZombieVillager", mtZombieVillager, "entity.zombie_villager.hurt", "entity.zombie_villager.death", "entity.ambient", 0.6, 1.8), + m_ConversionTime(-1), + m_Profession(a_Profession) +{ + SetBurnsInDaylight(true); +} + + + + + +void cZombieVillager::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + unsigned int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ROTTEN_FLESH); + cItems RareDrops; + RareDrops.Add(cItem(E_ITEM_IRON)); + RareDrops.Add(cItem(E_ITEM_CARROT)); + RareDrops.Add(cItem(E_ITEM_POTATO)); + AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); + AddRandomArmorDropItem(a_Drops, LootingLevel); + AddRandomWeaponDropItem(a_Drops, LootingLevel); +} + + + + + +void cZombieVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) +{ + super::Tick(a_Dt, a_Chunk); + if (!IsTicking()) + { + // The base class tick destroyed us + return; + } + + LOGD("Conversion time: %d", m_ConversionTime); + + if (m_ConversionTime == 0) + { + m_World->BroadcastSoundEffect("entity.zombie_villager.cure", GetPosition(), 1.0f, 1.0f); + Destroy(); + m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtVillager, false); + } + else if (m_ConversionTime > 0) + { + m_ConversionTime--; + } +} + + + + + +void cZombieVillager::OnRightClicked(cPlayer & a_Player) +{ + super::OnRightClicked(a_Player); + + const cItem & EquippedItem = a_Player.GetEquippedItem(); + if ((EquippedItem.m_ItemType == E_ITEM_GOLDEN_APPLE) && GetEntityEffect(cEntityEffect::effWeakness) != nullptr) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + + m_ConversionTime = 6000; + } +} |