Endermen take damage from rain
This commit is contained in:
parent
0c0bfe54bb
commit
a944ac3b06
@ -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<int>(coords.y); Y < cChunkDef::Height; ++Y)
|
||||
{
|
||||
BLOCKTYPE Block = m_World->GetBlock(static_cast<int>(coords.x), Y, static_cast<int>(coords.z));
|
||||
if (Block != E_BLOCK_AIR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -29,6 +29,8 @@ public:
|
||||
|
||||
/** Returns if the current sky light level is sufficient for the enderman to become aggravated */
|
||||
bool CheckLight(void);
|
||||
/** Returns if the enderman gets hit by the rain */
|
||||
bool CheckRain(void);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user