From 434ea542e174bc686a7c981476e23d30d18989c3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 4 Aug 2014 21:48:33 +0200 Subject: Added arrow consuming on shooting --- src/Items/ItemBow.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Items') diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index e7a77dcbc..90645dd9a 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -57,6 +57,12 @@ public: } Force = std::min(Force, 1.0); + // Has the player a arrow? + if (!a_Player->IsGameModeCreative() && !a_Player->GetInventory().HasItems(cItem(E_ITEM_ARROW))) + { + return; + } + // Create the arrow entity: cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); if (Arrow == NULL) @@ -73,6 +79,10 @@ public: a_Player->GetWorld()->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY(), a_Player->GetPosZ(), 0.5, (float)Force); if (!a_Player->IsGameModeCreative()) { + if (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchInfinity) == 0) + { + a_Player->GetInventory().RemoveItem(cItem(E_ITEM_ARROW)); + } a_Player->UseEquippedItem(); } } -- cgit v1.2.3