diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-06-16 22:57:13 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-06-16 22:57:13 +0200 |
commit | 885a50d77a26eea6619de681bf6ee746e79308cd (patch) | |
tree | 2cb971c4c070c919944dfbb412d90837957bb966 /src/Items | |
parent | Add bow charging animation (diff) | |
download | cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.tar cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.tar.gz cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.tar.bz2 cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.tar.lz cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.tar.xz cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.tar.zst cuberite-885a50d77a26eea6619de681bf6ee746e79308cd.zip |
Diffstat (limited to 'src/Items')
-rw-r--r-- | src/Items/ItemBow.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index e0ab339d3..a8fac13cc 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -46,20 +46,17 @@ public: { // Actual shot - produce the arrow with speed based on the ticks that the bow was charged ASSERT(a_Player != NULL); - + int BowCharge = a_Player->FinishChargingBow(); - double Force = (double)BowCharge / 20; - Force = (Force * Force + 2 * Force) / 3; // This formula is used by the 1.6.2 client + double Force = (double)BowCharge / 20.0; + Force = (Force * Force + 2.0 * Force) / 3.0; // This formula is used by the 1.6.2 client if (Force < 0.1) { // Too little force, ignore the shot return; } - if (Force > 1) - { - Force = 1; - } - + Force = std::max(Force, 1.0); + // Create the arrow entity: cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); if (Arrow == NULL) @@ -71,8 +68,10 @@ public: delete Arrow; return; } + + cFastRandom Random; a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow); - a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force); + a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F); if (!a_Player->IsGameModeCreative()) { |