| 493 | |
| 494 | |
| 495 | void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) |
| 496 | { |
| 497 | if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat()) |
| 498 | { |
| 499 | // Not an entity that interacts with an arrow |
| 500 | return; |
| 501 | } |
| 502 | |
| 503 | int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5); |
| 504 | if (m_IsCritical) |
| 505 | { |
| 506 | Damage += m_World->GetTickRandomNumber(Damage / 2 + 2); |
| 507 | } |
| 508 | a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1); |
| 509 | |
| 510 | // Broadcast successful hit sound |
| 511 | m_World->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); |
| 512 | |
| 513 | Destroy(); |
| 514 | } |
| 515 | |
| 516 | |
| 517 |
nothing calls this directly
no test coverage detected