MCPcopy Create free account
hub / github.com/cuberite/cuberite / OnHitEntity

Method OnHitEntity

src/Entities/ProjectileEntity.cpp:495–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493
494
495void 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

Callers

nothing calls this directly

Calls 10

IsMobMethod · 0.80
IsMinecartMethod · 0.80
IsPlayerMethod · 0.80
IsBoatMethod · 0.80
LengthMethod · 0.80
GetTickRandomNumberMethod · 0.80
TakeDamageMethod · 0.80
GetMobTypeMethod · 0.80
StartBurningMethod · 0.80
BroadcastSoundEffectMethod · 0.45

Tested by

no test coverage detected