From 52d4c49d5cd2c15078c84a18821761b723833584 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 22:32:23 +0200 Subject: Fixed many slime bugs. - Fixed slime hurt/death sound - Added slime spawning on death. - Fixed the max health. - Fixed the attack damage. - Little slimes should not attack players. --- src/Entities/Entity.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4a6de25b7..3433258fd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1146,10 +1146,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth) m_MaxHealth = a_MaxHealth; // Reset health, if too high: - if (m_Health > a_MaxHealth) - { - m_Health = a_MaxHealth; - } + m_Health = std::min(m_Health, a_MaxHealth); } -- cgit v1.2.3 From 041bfd5860cd8ef51db42eb6fb4b50b45549feba Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 19 Jul 2014 01:40:29 -0700 Subject: Fixed clamping issues --- src/Entities/Entity.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 61b28ec70..f9331ede8 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -327,10 +327,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) // TODO: Apply damage to armor - if (m_Health < 0) - { - m_Health = 0; - } + m_Health = std::max(m_Health, 0); if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs { -- cgit v1.2.3 From 726312602d293117fc4999897ef56869f2fef534 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 20 Jul 2014 01:43:07 -0700 Subject: Added m_TicksAlive to entities, allows projectiles to hit their creators --- src/Entities/Entity.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index f9331ede8..5a3bbcdc4 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -49,6 +49,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_IsSubmerged(false) , m_AirLevel(0) , m_AirTickTimer(0) + , m_TicksAlive(0) , m_HeadYaw(0.0) , m_Rot(0.0, 0.0, 0.0) , m_Pos(a_X, a_Y, a_Z) @@ -559,6 +560,8 @@ void cEntity::SetHealth(int a_Health) void cEntity::Tick(float a_Dt, cChunk & a_Chunk) { + m_TicksAlive++; + if (m_InvulnerableTicks > 0) { m_InvulnerableTicks--; -- cgit v1.2.3 From 93d29555e58df172bafba530afbc593c16ec66a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 21 Jul 2014 15:19:48 +0200 Subject: Style: Normalized to no spaces before closing parenthesis. --- src/Entities/Entity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 5a3bbcdc4..db0fd0fd6 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -648,7 +648,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width); int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width); - BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ ); + BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ); BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR; if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block { @@ -758,7 +758,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) m_WaterSpeed *= 0.9f; // Reduce speed each tick - switch(WaterDir) + switch (WaterDir) { case X_PLUS: m_WaterSpeed.x = 0.2f; -- cgit v1.2.3