1
0
Fork 0
This commit is contained in:
Howaner 2014-04-26 16:44:15 +02:00
parent e5683ede63
commit 49f6819829
8 changed files with 26 additions and 23 deletions

View File

@ -60,7 +60,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_Mass (0.001) // Default 1g
, m_Width(a_Width)
, m_Height(a_Height)
, m_InvulnerableTicks(20)
, m_InvulnerableTicks(0)
{
cCSLock Lock(m_CSCount);
m_EntityCount++;

View File

@ -262,7 +262,9 @@ public:
// tolua_end
/** Makes this entity take damage specified in the a_TDI. The TDI is sent through plugins first, then applied. If it returns false, the entity hasn't become any damage. */
/** Makes this entity take damage specified in the a_TDI.
The TDI is sent through plugins first, then applied.
If it returns false, the entity hasn't receive any damage. */
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
// tolua_begin
@ -481,31 +483,32 @@ protected:
int m_AirTickTimer;
private:
// Measured in degrees, [-180, +180)
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;
// Measured in meter/second (m/s)
/** Measured in meter/second (m/s) */
Vector3d m_Speed;
// Measured in degrees, [-180, +180)
/** Measured in degrees, [-180, +180) */
Vector3d m_Rot;
/// Position of the entity's XZ center and Y bottom
/** Position of the entity's XZ center and Y bottom */
Vector3d m_Pos;
// Measured in meter / second
/** Measured in meter / second */
Vector3d m_WaterSpeed;
// Measured in Kilograms (Kg)
/** Measured in Kilograms (Kg) */
double m_Mass;
// Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter.
/** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */
double m_Width;
// Height of the entity (Y axis)
/** Height of the entity (Y axis) */
double m_Height;
// If a player hit a entity, the entity become a invulnerable of 10 ticks. While this ticks, a player can't hit this entity.
/** If a player hit a entity, the entity receive a invulnerable of 10 ticks.
While this ticks, a player can't hit this entity. */
int m_InvulnerableTicks;
} ; // tolua_export

View File

@ -10,7 +10,7 @@
cWither::cWither(void) :
super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
m_InvulnerableTicks(220)
m_WitherInvulnerableTicks(220)
{
SetMaxHealth(300);
}
@ -47,7 +47,7 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
return false;
}
if (m_InvulnerableTicks > 0)
if (m_WitherInvulnerableTicks > 0)
{
return false;
}
@ -68,16 +68,16 @@ void cWither::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_InvulnerableTicks > 0)
if (m_WitherInvulnerableTicks > 0)
{
unsigned int NewTicks = m_InvulnerableTicks - 1;
unsigned int NewTicks = m_WitherInvulnerableTicks - 1;
if (NewTicks == 0)
{
m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
}
m_InvulnerableTicks = NewTicks;
m_WitherInvulnerableTicks = NewTicks;
if ((NewTicks % 10) == 0)
{

View File

@ -17,9 +17,9 @@ public:
CLASS_PROTODEF(cWither);
unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; }
unsigned int GetWitherInvulnerableTicks(void) const { return m_WitherInvulnerableTicks; }
void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; }
void SetWitherInvulnerableTicks(unsigned int a_Ticks) { m_WitherInvulnerableTicks = a_Ticks; }
/** Returns whether the wither is invulnerable to arrows. */
bool IsArmored(void) const;
@ -33,7 +33,7 @@ public:
private:
/** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */
unsigned int m_InvulnerableTicks;
unsigned int m_WitherInvulnerableTicks;
} ;

View File

@ -2013,7 +2013,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtWither:
{
WriteByte(0x54); // Int at index 20
WriteInt((Int32)((const cWither &)a_Mob).GetNumInvulnerableTicks());
WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth()));
break;

View File

@ -2820,7 +2820,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtWither:
{
WriteByte(0x54); // Int at index 20
WriteInt(((const cWither &)a_Mob).GetNumInvulnerableTicks());
WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth()));
break;

View File

@ -516,7 +516,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
case cMonster::mtWither:
{
m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetNumInvulnerableTicks());
m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks());
break;
}
case cMonster::mtWolf:

View File

@ -2272,7 +2272,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
if (CurrLine > 0)
{
Monster->SetNumInvulnerableTicks(a_NBT.GetInt(CurrLine));
Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine));
}
a_Entities.push_back(Monster.release());