diff options
Diffstat (limited to 'source/Mobs/Monster.cpp')
-rw-r--r-- | source/Mobs/Monster.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 9ae91f1e0..a42ae30ee 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" @@ -25,6 +26,8 @@ cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : super(etMob, a_Width, a_Height) , m_Target(NULL) + , m_AttackRate(3) + , idle_interval(0) , m_bMovingToDestination(false) , m_DestinationTime( 0 ) , m_DestroyTimer( 0 ) @@ -39,8 +42,7 @@ cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const A , m_AttackDamage(1.0f) , m_AttackRange(5.0f) , m_AttackInterval(0) - , m_AttackRate(3) - , idle_interval(0) + , m_BurnsInDaylight(false) { if (!a_ConfigName.empty()) { @@ -100,6 +102,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 +478,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); + } +} + + + + |