From 675b4aa878f16291ce33fced48a2bc7425f635ae Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 24 Nov 2013 14:19:41 +0000 Subject: Moved source to src --- source/Items/ItemBow.h | 87 -------------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 source/Items/ItemBow.h (limited to 'source/Items/ItemBow.h') diff --git a/source/Items/ItemBow.h b/source/Items/ItemBow.h deleted file mode 100644 index d533c21fd..000000000 --- a/source/Items/ItemBow.h +++ /dev/null @@ -1,87 +0,0 @@ - -// ItemBow.h - -// Declares the cItemBowHandler class representing the itemhandler for bows - - - - - -#pragma once - -#include "../Entities/ProjectileEntity.h" - - - - - -class cItemBowHandler : - public cItemHandler -{ - typedef cItemHandler super; - -public: - cItemBowHandler(void) : - super(E_ITEM_BOW) - { - } - - - virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override - { - ASSERT(a_Player != NULL); - - // Check if the player has an arrow in the inventory, or is in Creative: - if (!(a_Player->IsGameModeCreative() || a_Player->GetInventory().HasItems(cItem(E_ITEM_ARROW)))) - { - return false; - } - - a_Player->StartChargingBow(); - return true; - } - - - virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override - { - // 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 - if (Force < 0.1) - { - // Too little force, ignore the shot - return; - } - if (Force > 1) - { - Force = 1; - } - - // Create the arrow entity: - cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2); - if (Arrow == NULL) - { - return; - } - if (!Arrow->Initialize(a_Player->GetWorld())) - { - delete Arrow; - return; - } - 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); - - if (!a_Player->IsGameModeCreative()) - { - a_Player->UseEquippedItem(); - } - } -} ; - - - - - -- cgit v1.2.3