1
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_Mass (0.001) // Default 1g
, m_Width(a_Width) , m_Width(a_Width)
, m_Height(a_Height) , m_Height(a_Height)
, m_InvulnerableTicks(20) , m_InvulnerableTicks(0)
{ {
cCSLock Lock(m_CSCount); cCSLock Lock(m_CSCount);
m_EntityCount++; m_EntityCount++;

View File

@ -262,7 +262,9 @@ public:
// tolua_end // 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); virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
// tolua_begin // tolua_begin
@ -481,31 +483,32 @@ protected:
int m_AirTickTimer; int m_AirTickTimer;
private: private:
// Measured in degrees, [-180, +180) /** Measured in degrees, [-180, +180) */
double m_HeadYaw; double m_HeadYaw;
// Measured in meter/second (m/s) /** Measured in meter/second (m/s) */
Vector3d m_Speed; Vector3d m_Speed;
// Measured in degrees, [-180, +180) /** Measured in degrees, [-180, +180) */
Vector3d m_Rot; 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; Vector3d m_Pos;
// Measured in meter / second /** Measured in meter / second */
Vector3d m_WaterSpeed; Vector3d m_WaterSpeed;
// Measured in Kilograms (Kg) /** Measured in Kilograms (Kg) */
double m_Mass; 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; double m_Width;
// Height of the entity (Y axis) /** Height of the entity (Y axis) */
double m_Height; 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; int m_InvulnerableTicks;
} ; // tolua_export } ; // tolua_export

View File

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

View File

@ -17,9 +17,9 @@ public:
CLASS_PROTODEF(cWither); 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. */ /** Returns whether the wither is invulnerable to arrows. */
bool IsArmored(void) const; bool IsArmored(void) const;
@ -33,7 +33,7 @@ public:
private: private:
/** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */ /** 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: case cMonster::mtWither:
{ {
WriteByte(0x54); // Int at index 20 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 WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth())); WriteFloat((float)(a_Mob.GetHealth()));
break; break;

View File

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

View File

@ -516,7 +516,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
} }
case cMonster::mtWither: case cMonster::mtWither:
{ {
m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetNumInvulnerableTicks()); m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks());
break; break;
} }
case cMonster::mtWolf: 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"); int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
if (CurrLine > 0) if (CurrLine > 0)
{ {
Monster->SetNumInvulnerableTicks(a_NBT.GetInt(CurrLine)); Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine));
} }
a_Entities.push_back(Monster.release()); a_Entities.push_back(Monster.release());