From 010bc94a342770e96a005353d23d7ebf6cc5aa39 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Sep 2013 22:51:07 +0100 Subject: Entities now maintain speed outside of world --- source/Entities/Entity.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/Entities/Entity.cpp') diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp index 4066e81ab..0aaa2e899 100644 --- a/source/Entities/Entity.cpp +++ b/source/Entities/Entity.cpp @@ -491,8 +491,15 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) if ((BlockY >= cChunkDef::Height) || (BlockY < 0)) { // Outside of the world - // TODO: Current speed should still be added to the entity position - // Otherwise TNT explosions in the void will still effect the bottommost layers of the world + + cChunk * NextChunk = a_Chunk.GetNeighborChunk(BlockX,BlockZ); + // See if we can commit our changes. If not, we will discard them. + if (NextChunk != NULL) + { + SetSpeed(NextSpeed); + NextPos += (NextSpeed * a_Dt); + SetPosition(NextPos); + } return; } -- cgit v1.2.3 From c8f8597774c47e755597eae4a120bea9479d0479 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 10 Sep 2013 23:01:02 +0100 Subject: Added void damage --- source/Entities/Entity.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/Entities/Entity.cpp') diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp index 0aaa2e899..846d756dd 100644 --- a/source/Entities/Entity.cpp +++ b/source/Entities/Entity.cpp @@ -55,6 +55,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_TicksSinceLastBurnDamage(0) , m_TicksSinceLastLavaDamage(0) , m_TicksSinceLastFireDamage(0) + , m_TicksSinceLastVoidDamage(0) , m_TicksLeftBurning(0) , m_WaterSpeed(0, 0, 0) , m_Width(a_Width) @@ -472,6 +473,11 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) { TickBurning(a_Chunk); } + if ((a_Chunk.IsValid()) && (GetPosY() < -46)) + { + TickInVoid(a_Chunk); + } + else { m_TicksSinceLastVoidDamage = 0; } } @@ -803,6 +809,23 @@ void cEntity::TickBurning(cChunk & a_Chunk) +void cEntity::TickInVoid(cChunk & a_Chunk) +{ + if (m_TicksSinceLastVoidDamage == 20) + { + TakeDamage(dtInVoid, NULL, 2, 0); + m_TicksSinceLastVoidDamage = 0; + } + else + { + m_TicksSinceLastVoidDamage++; + } +} + + + + + /// Called when the entity starts burning void cEntity::OnStartedBurning(void) { -- cgit v1.2.3 From 3a1def2c905a8e6d8807d14c5953cceb04f6b8a6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 11 Sep 2013 20:07:51 +0100 Subject: More changes [SEE DESC] * Improved (again) pumpkin direction handling * Fixed spacing in Entity.cpp --- source/Entities/Entity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Entities/Entity.cpp') diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp index 846d756dd..3d6c2887a 100644 --- a/source/Entities/Entity.cpp +++ b/source/Entities/Entity.cpp @@ -498,7 +498,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) { // Outside of the world - cChunk * NextChunk = a_Chunk.GetNeighborChunk(BlockX,BlockZ); + cChunk * NextChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ); // See if we can commit our changes. If not, we will discard them. if (NextChunk != NULL) { -- cgit v1.2.3