summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-09 10:50:38 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-09 10:50:38 +0200
commit372dbbb994a1414369fe38367d458a0c32866a79 (patch)
tree5cd564fbb0c4b7c0b47f3cb64594c34f9361f1dc /src/Mobs
parentUpdated generator prefabs to current Gallery contents. (diff)
parentAdded extra space before comments (diff)
downloadcuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar
cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.gz
cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.bz2
cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.lz
cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.xz
cuberite-372dbbb994a1414369fe38367d458a0c32866a79.tar.zst
cuberite-372dbbb994a1414369fe38367d458a0c32866a79.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Creeper.cpp22
-rw-r--r--src/Mobs/Skeleton.cpp5
-rw-r--r--src/Mobs/Zombie.cpp5
3 files changed, 24 insertions, 8 deletions
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index a7b97f604..b9041bd5a 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -67,9 +67,27 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
- if ((a_Killer != NULL) && (a_Killer->IsProjectile()))
+ if ((a_Killer != NULL) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0))
{
- if (((cMonster *)((cProjectileEntity *)a_Killer)->GetCreator())->GetMobType() == mtSkeleton)
+ class cProjectileCreatorCallback : public cEntityCallback
+ {
+ public:
+ cProjectileCreatorCallback(void)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if (a_Entity->IsMob() && ((cMonster *)a_Entity)->GetMobType() == mtSkeleton)
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ cProjectileCreatorCallback PCC;
+ if (GetWorld()->DoWithEntityByID(((cProjectileEntity *)a_Killer)->GetCreatorUniqueID(), PCC))
{
// 12 music discs. TickRand starts from 0 to 11. Disk IDs start at 2256, so add that. There.
AddRandomDropItem(a_Drops, 1, 1, (short)m_World->GetTickRandomNumber(11) + 2256);
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index e3357185d..0641a3d57 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -49,11 +49,10 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSkeleton::MoveToPosition(const Vector3f & a_Position)
{
- // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement.
+ // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
!IsOnFire() &&
- (m_World->GetTimeOfDay() < 13187) &&
- (m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15)
+ (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8)
)
{
m_bMovingToDestination = false;
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index f19e096ee..725790ed9 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -44,11 +44,10 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cZombie::MoveToPosition(const Vector3f & a_Position)
{
- // If the destination is in the sun and if it is not night AND the zombie isn't on fire then block the movement.
+ // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
!IsOnFire() &&
- (m_World->GetTimeOfDay() < 13187) &&
- (m_World->GetBlockSkyLight((int)a_Position.x, (int)a_Position.y, (int)a_Position.z) == 15)
+ (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8)
)
{
m_bMovingToDestination = false;