From 885a50d77a26eea6619de681bf6ee746e79308cd Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 22:57:13 +0200 Subject: Fix bow sound and creative arrow pickup. --- src/Items/ItemBow.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/Items/ItemBow.h') 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()) { -- cgit v1.2.3 From b45e85a6784861e225c7a4ecfd7838a6d32c7875 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 22:57:27 +0200 Subject: This isn't needed --- src/Items/ItemBow.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Items/ItemBow.h') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index a8fac13cc..a2f740ba7 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -70,7 +70,6 @@ public: } cFastRandom Random; - a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow); 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()) -- cgit v1.2.3 From a1fd0b0335a5b19af29a4862f4d0ac39bec6887f Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 23:41:23 +0200 Subject: Split Broadcast Sound Effect function call in multiple lines. --- src/Items/ItemBow.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Items/ItemBow.h') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index a2f740ba7..d79fecd30 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -70,7 +70,14 @@ public: } cFastRandom Random; - 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); + 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()) { -- cgit v1.2.3 From e8143de01bff31f9e153949d7ab5b0df82629541 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 19 Jun 2014 01:49:56 -0700 Subject: Nullify deleted pointers. --- src/Items/ItemBow.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Items/ItemBow.h') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index e0ab339d3..821e2ab26 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -69,6 +69,7 @@ public: if (!Arrow->Initialize(*a_Player->GetWorld())) { delete Arrow; + Arrow = NULL; return; } a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow); -- cgit v1.2.3 From da1d946b2b6cbb5d3e66c78adc09a4c472e04078 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Jul 2014 22:04:26 +0100 Subject: Fixed bow charge --- src/Items/ItemBow.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/Items/ItemBow.h') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 940338d0f..185f17fee 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -55,7 +55,7 @@ public: // Too little force, ignore the shot return; } - Force = std::max(Force, 1.0); + Force = std::min(Force, 1.0); // Create the arrow entity: cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); @@ -70,16 +70,7 @@ public: return; } - cFastRandom Random; - 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 - ); - + 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); if (!a_Player->IsGameModeCreative()) { a_Player->UseEquippedItem(); -- cgit v1.2.3