From a944ac3b067464db026890e27d0c8dced6c8545e Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Wed, 28 Jun 2017 10:56:50 +0200 Subject: Endermen take damage from rain --- src/Mobs/Enderman.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/Mobs/Enderman.cpp') diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 3c0717f8f..5cfe0d4cd 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -194,14 +194,38 @@ void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) return; } - // TODO take damage in rain - // Take damage when touching water, drowning damage seems to be most appropriate - if (IsSwimming()) + if (CheckRain() || IsSwimming()) { EventLosePlayer(); TakeDamage(dtDrowning, nullptr, 1, 0); // TODO teleport to a safe location } +} + + + + + +bool cEnderman::CheckRain(void) +{ + if (!GetWorld()->IsWeatherRain()) + { + return false; + } + Vector3d coords = GetPosition(); + for (int Y = static_cast(coords.y); Y < cChunkDef::Height; ++Y) + { + BLOCKTYPE Block = m_World->GetBlock(static_cast(coords.x), Y, static_cast(coords.z)); + if (Block != E_BLOCK_AIR) + { + return false; + } + } + return true; } + + + + -- cgit v1.2.3