Moved daylight burning directly into cMonster.
This commit is contained in:
parent
a80be25c92
commit
e8d1ed36c5
@ -15,6 +15,7 @@
|
|||||||
#include "../Vector3i.h"
|
#include "../Vector3i.h"
|
||||||
#include "../Vector3d.h"
|
#include "../Vector3d.h"
|
||||||
#include "../Tracer.h"
|
#include "../Tracer.h"
|
||||||
|
#include "../Chunk.h"
|
||||||
|
|
||||||
// #include "../../iniFile/iniFile.h"
|
// #include "../../iniFile/iniFile.h"
|
||||||
|
|
||||||
@ -100,6 +101,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Burning in daylight
|
||||||
|
HandleDaylightBurning(a_Chunk);
|
||||||
|
|
||||||
HandlePhysics(a_Dt,a_Chunk);
|
HandlePhysics(a_Dt,a_Chunk);
|
||||||
BroadcastMovementUpdate();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,6 +107,9 @@ public:
|
|||||||
void SetAttackDamage(float ad);
|
void SetAttackDamage(float ad);
|
||||||
void SetSightDistance(float sd);
|
void SetSightDistance(float sd);
|
||||||
|
|
||||||
|
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
|
||||||
|
void SetBurnsInDaylight(bool a_BurnsInDaylight) { a_BurnsInDaylight = a_BurnsInDaylight; }
|
||||||
|
|
||||||
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
|
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
|
||||||
enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;
|
enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;
|
||||||
|
|
||||||
@ -134,8 +137,12 @@ protected:
|
|||||||
float m_AttackDamage;
|
float m_AttackDamage;
|
||||||
float m_AttackRange;
|
float m_AttackRange;
|
||||||
float m_AttackInterval;
|
float m_AttackInterval;
|
||||||
|
|
||||||
|
bool m_BurnsInDaylight;
|
||||||
|
|
||||||
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
|
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
|
||||||
|
|
||||||
|
void HandleDaylightBurning(cChunk & a_Chunk);
|
||||||
} ; // tolua_export
|
} ; // tolua_export
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,24 +11,7 @@
|
|||||||
cSkeleton::cSkeleton(void) :
|
cSkeleton::cSkeleton(void) :
|
||||||
super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8)
|
super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8)
|
||||||
{
|
{
|
||||||
}
|
SetBurnsInDaylight(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cSkeleton::Tick(float a_Dt, cChunk & a_Chunk)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt, a_Chunk);
|
|
||||||
|
|
||||||
if ((GetWorld()->GetBlockSkyLight(GetPosX(), GetPosY(), GetPosZ()) == 15) && (GetWorld()->GetBlock(GetPosX(), GetPosY(), GetPosZ()) != E_BLOCK_SOULSAND))
|
|
||||||
{
|
|
||||||
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
|
|
||||||
{
|
|
||||||
// Burn for 100 ticks, then decide again
|
|
||||||
StartBurning(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ public:
|
|||||||
|
|
||||||
CLASS_PROTODEF(cSkeleton);
|
CLASS_PROTODEF(cSkeleton);
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -8,28 +8,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// They're eating your brains!
|
|
||||||
|
|
||||||
cZombie::cZombie(void) :
|
cZombie::cZombie(void) :
|
||||||
super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8)
|
super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8)
|
||||||
{
|
{
|
||||||
}
|
SetBurnsInDaylight(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cZombie::Tick(float a_Dt, cChunk & a_Chunk)
|
|
||||||
{
|
|
||||||
super::Tick(a_Dt, a_Chunk);
|
|
||||||
if ((GetWorld()->GetBlockSkyLight(GetPosX(), GetPosY(), GetPosZ()) == 15) && (GetWorld()->GetBlock(GetPosX(), GetPosY(), GetPosZ()) != E_BLOCK_SOULSAND))
|
|
||||||
{
|
|
||||||
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
|
|
||||||
{
|
|
||||||
// Burn for 100 ticks, then decide again
|
|
||||||
StartBurning(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,11 +12,10 @@ class cZombie :
|
|||||||
typedef cAggressiveMonster super;
|
typedef cAggressiveMonster super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cZombie();
|
cZombie(void);
|
||||||
|
|
||||||
CLASS_PROTODEF(cZombie);
|
CLASS_PROTODEF(cZombie);
|
||||||
|
|
||||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user