summaryrefslogtreecommitdiffstats
path: root/source/Mobs/Monster.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-05 22:40:08 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-09-06 17:50:20 +0200
commite8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0 (patch)
treed8c5be799168cd1c50a170e549db2b3812c7b9f6 /source/Mobs/Monster.cpp
parentRemoved TimedWait from cEvent. (diff)
downloadcuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.tar
cuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.tar.gz
cuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.tar.bz2
cuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.tar.lz
cuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.tar.xz
cuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.tar.zst
cuberite-e8d1ed36c5dcf92639ca5969213a58a6c6ed0dc0.zip
Diffstat (limited to '')
-rw-r--r--source/Mobs/Monster.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp
index 9ae91f1e0..11b530968 100644
--- a/source/Mobs/Monster.cpp
+++ b/source/Mobs/Monster.cpp
@@ -15,6 +15,7 @@
#include "../Vector3i.h"
#include "../Vector3d.h"
#include "../Tracer.h"
+#include "../Chunk.h"
// #include "../../iniFile/iniFile.h"
@@ -100,6 +101,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
+ // Burning in daylight
+ HandleDaylightBurning(a_Chunk);
+
HandlePhysics(a_Dt,a_Chunk);
BroadcastMovementUpdate();
@@ -473,3 +477,35 @@ void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned
+
+void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
+{
+ if (!m_BurnsInDaylight)
+ {
+ return;
+ }
+
+ int RelY = (int)floor(GetPosY());
+ if ((RelY < 0) || (RelY >= cChunkDef::Height))
+ {
+ // Outside the world
+ return;
+ }
+
+ int RelX = (int)floor(GetPosX()) - a_Chunk.GetPosX() * cChunkDef::Width;
+ int RelZ = (int)floor(GetPosZ()) - a_Chunk.GetPosZ() * cChunkDef::Width;
+ if (
+ (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
+ (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
+ (GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
+ !IsOnFire() // Not already burning
+ )
+ {
+ // Burn for 100 ticks, then decide again
+ StartBurning(100);
+ }
+}
+
+
+
+