summaryrefslogtreecommitdiffstats
path: root/source/cMonster.cpp
diff options
context:
space:
mode:
authorlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-28 03:10:05 +0100
committerlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-28 03:10:05 +0100
commit1e9af56a67ae3765291361d9bf01e9009cfb4dcc (patch)
tree65878a8c373ec163eed3439b7db0fc440810d95b /source/cMonster.cpp
parentFixed some things in Core to work for multiple worlds (diff)
downloadcuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.tar
cuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.tar.gz
cuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.tar.bz2
cuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.tar.lz
cuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.tar.xz
cuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.tar.zst
cuberite-1e9af56a67ae3765291361d9bf01e9009cfb4dcc.zip
Diffstat (limited to 'source/cMonster.cpp')
-rw-r--r--source/cMonster.cpp75
1 files changed, 7 insertions, 68 deletions
diff --git a/source/cMonster.cpp b/source/cMonster.cpp
index 2f7567b15..cee068b08 100644
--- a/source/cMonster.cpp
+++ b/source/cMonster.cpp
@@ -56,25 +56,12 @@ cMonster::cMonster()
, m_AttackInterval(0)
, m_AttackRate(3)
, idle_interval(0)
- , m_bBurnable(true)
- , m_EMMetaState(NORMAL)
- , m_FireDamageInterval(0)
- , m_BurnPeriod(0)
{
LOG("cMonster::cMonster()");
- LOG("In state: %s",GetState());
- m_Health = 10;
+ LOG("In state: %s", GetState());
- MTRand r1;
- int RandVal = r1.randInt() % 4;
- if( RandVal == 0 )
- m_MobType = 90; // Pig
- else if( RandVal == 1 )
- m_MobType = 91; // Sheep
- else if( RandVal == 2 )
- m_MobType = 92; // Cow
- else
- m_MobType = 93; // Hen
+ m_bBurnable = true;
+ m_MetaData = NORMAL;
}
cMonster::~cMonster()
@@ -131,6 +118,8 @@ bool cMonster::ReachedDestination()
void cMonster::Tick(float a_Dt)
{
+ cPawn::Tick(a_Dt);
+
if( m_Health <= 0 )
{
m_DestroyTimer += a_Dt/1000;
@@ -196,12 +185,6 @@ void cMonster::Tick(float a_Dt)
SetPitch( Pitch );
}
- CheckMetaDataBurn(); //Check to see if Enemy should burn based on block they are on
-
- if(m_EMMetaState == BURNING) {
- InStateBurning(a_Dt);
- }
-
if(m_EMState == IDLE) { //If enemy passive we ignore checks for player visibility
InStateIdle(a_Dt);
}
@@ -448,37 +431,6 @@ void cMonster::InStateIdle(float a_Dt) {
}
}
-//What to do if On fire
-void cMonster::InStateBurning(float a_Dt) {
- m_FireDamageInterval += a_Dt;
- char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y +1, (int)m_Pos->z );
- if(m_FireDamageInterval > 1) {
-
- m_FireDamageInterval -= 1;
- TakeDamage(1, this);
-
- m_BurnPeriod++;
- if(block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
- || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE) {
- m_BurnPeriod = 0;
- TakeDamage(6, this);
- }else{
- TakeDamage(1, this);
- }
-
- if(m_BurnPeriod > 8) {
- cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
- m_EMMetaState = NORMAL;
- cPacket_Metadata md(NORMAL, GetUniqueID());
- InChunk->Broadcast(md);
- m_BurnPeriod = 0;
-
- }
- }
-
-}
-
//What to do if in Chasing State
//This state should always be defined in each child class
void cMonster::InStateChasing(float a_Dt) {
@@ -508,20 +460,7 @@ void cMonster::Attack(float a_Dt) {
((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage,this);
}
}
-//----Change Entity MetaData
-void cMonster::CheckMetaDataBurn() {
- char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
- if(m_bBurnable && m_EMMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
- || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)) {
- cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
- if(!InChunk)
- return;
- m_EMMetaState = BURNING;
- cPacket_Metadata md(BURNING,GetUniqueID());
- InChunk->Broadcast(md);
- }
-}
+
//----Debug
@@ -601,5 +540,5 @@ void cMonster::DropItem(ENUM_ITEM_ID a_Item, unsigned int a_Count)
void cMonster::RandomDropItem(ENUM_ITEM_ID a_Item, unsigned int a_Min, unsigned int a_Max)
{
MTRand r1;
- return cMonster::DropItem(a_Item, r1.randInt() % (a_Max + 1) + a_Min);
+ return cMonster::DropItem(a_Item, r1.randInt() % (a_Max + 1 - a_Min) + a_Min);
} \ No newline at end of file