1
0

Added m_TicksAlive to entities, allows projectiles to hit their creators

This commit is contained in:
archshift 2014-07-20 01:43:07 -07:00
parent 9e155c6add
commit 726312602d
3 changed files with 14 additions and 3 deletions

View File

@ -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--;

View File

@ -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;

View File

@ -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());