Added m_TicksAlive to entities, allows projectiles to hit their creators
This commit is contained in:
parent
9e155c6add
commit
726312602d
@ -49,6 +49,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
|
|||||||
, m_IsSubmerged(false)
|
, m_IsSubmerged(false)
|
||||||
, m_AirLevel(0)
|
, m_AirLevel(0)
|
||||||
, m_AirTickTimer(0)
|
, m_AirTickTimer(0)
|
||||||
|
, m_TicksAlive(0)
|
||||||
, m_HeadYaw(0.0)
|
, m_HeadYaw(0.0)
|
||||||
, m_Rot(0.0, 0.0, 0.0)
|
, m_Rot(0.0, 0.0, 0.0)
|
||||||
, m_Pos(a_X, a_Y, a_Z)
|
, 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)
|
void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
|
m_TicksAlive++;
|
||||||
|
|
||||||
if (m_InvulnerableTicks > 0)
|
if (m_InvulnerableTicks > 0)
|
||||||
{
|
{
|
||||||
m_InvulnerableTicks--;
|
m_InvulnerableTicks--;
|
||||||
|
@ -416,6 +416,9 @@ public:
|
|||||||
/** Gets remaining air of a monster */
|
/** Gets remaining air of a monster */
|
||||||
int GetAirLevel(void) const { return m_AirLevel; }
|
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 */
|
/** Gets the invulnerable ticks from the entity */
|
||||||
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
|
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
|
||||||
|
|
||||||
@ -521,6 +524,9 @@ protected:
|
|||||||
int m_AirLevel;
|
int m_AirLevel;
|
||||||
int m_AirTickTimer;
|
int m_AirTickTimer;
|
||||||
|
|
||||||
|
/** The number of ticks this entity has been alive for */
|
||||||
|
long int m_TicksAlive;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Measured in degrees, [-180, +180) */
|
/** Measured in degrees, [-180, +180) */
|
||||||
double m_HeadYaw;
|
double m_HeadYaw;
|
||||||
|
@ -146,9 +146,11 @@ public:
|
|||||||
(a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile
|
(a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// TODO: Don't check creator only for the first 5 ticks
|
// Don't check creator only for the first 5 ticks so that projectiles can collide with the creator
|
||||||
// so that arrows stuck in ground and dug up can hurt the player
|
if (m_Projectile->GetTicksAlive() <= 5)
|
||||||
return false;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
|
cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
|
||||||
|
Loading…
Reference in New Issue
Block a user