void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat()) { // Not an entity that interacts with an arrow return; } int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5); if (m_IsCritical) { Damage += m_World->GetTickRandomNumber(Damage / 2 + 2); } a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); // Broadcast successful hit sound m_World->BroadcastSoundEffect( "random.successful_hit", (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8.0), (int)std::floor(GetPosZ() * 8.0), 0.5f, 0.75f + ((float)((GetUniqueID() * 23) % 32)) / 64.0f ); Destroy(); }
void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { int TotalDamage = 0; if (a_EntityHit.IsMob()) { eMonsterType MobType = static_cast<cMonster &>(a_EntityHit).GetMobType(); if (MobType == mtBlaze) { TotalDamage = 3; } } // TODO: If entity is Ender Crystal, destroy it a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); m_DestroyTimer = 5; }
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer()) { // Not an entity that interacts with an arrow return; } int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5); if (m_IsCritical) { Damage += m_World->GetTickRandomNumber(Damage / 2 + 2); } a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); Destroy(); }
void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { int TotalDamage = 0; // If entity is an Ender Dragon or Ender Crystal, it is damaged. if ( (a_EntityHit.IsMob() && (static_cast<cMonster &>(a_EntityHit).GetMobType() == mtEnderDragon)) || a_EntityHit.IsEnderCrystal() ) { TotalDamage = 1; } TrySpawnChicken(a_HitPos); a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); m_DestroyTimer = 5; }
void cProtocol125::SendEntityMetadata(const cEntity & a_Entity) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_METADATA); WriteInt (a_Entity.GetUniqueID()); WriteCommonMetadata(a_Entity); if (a_Entity.IsMob()) { WriteMobMetadata(((const cMonster &)a_Entity)); } else { WriteEntityMetadata(a_Entity); } WriteByte(0x7f); Flush(); }
void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { int TotalDamage = 0; if (a_EntityHit.IsMob()) { cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType(); if (MobType == cMonster::mtBlaze) { TotalDamage = 3; } else if (MobType == cMonster::mtEnderDragon) { TotalDamage = 1; } } a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1); Destroy(true); }