diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-20 11:39:25 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-20 11:39:25 +0200 |
commit | 88c877f79c37e7485f0c4cfa1ab103ed73e4f551 (patch) | |
tree | dfaa3c6349c91fc70d8b351496a9c0b3d8d12784 | |
parent | Added destroy-timer system to splash potion entities (diff) | |
parent | Added m_TicksAlive to entities, allows projectiles to hit their creators (diff) | |
download | cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.tar cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.tar.gz cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.tar.bz2 cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.tar.lz cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.tar.xz cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.tar.zst cuberite-88c877f79c37e7485f0c4cfa1ab103ed73e4f551.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.cpp | 3 | ||||
-rw-r--r-- | src/Entities/Entity.h | 6 | ||||
-rw-r--r-- | src/Entities/ProjectileEntity.cpp | 8 |
3 files changed, 14 insertions, 3 deletions
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--; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 88f8528e9..83fe76e7e 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -416,6 +416,9 @@ public: /** Gets remaining air of a monster */ int GetAirLevel(void) const { return m_AirLevel; } + /** Gets number of ticks this entity has existed for */ + long int GetTicksAlive(void) const { return m_TicksAlive; } + /** Gets the invulnerable ticks from the entity */ int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } @@ -521,6 +524,9 @@ protected: int m_AirLevel; int m_AirTickTimer; + /** The number of ticks this entity has been alive for */ + long int m_TicksAlive; + private: /** Measured in degrees, [-180, +180) */ double m_HeadYaw; diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index a55c9b895..b5e81bc0c 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -146,9 +146,11 @@ public: (a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile ) { - // TODO: Don't check creator only for the first 5 ticks - // so that arrows stuck in ground and dug up can hurt the player - return false; + // Don't check creator only for the first 5 ticks so that projectiles can collide with the creator + if (m_Projectile->GetTicksAlive() <= 5) + { + return false; + } } cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight()); |