1
0

Added more enchantments and some fixes

- Removed Debug messages
- Added Punch enchantment effect
- Added Silk Touch enchantment
- Added Unbreaking enchantment effect
This commit is contained in:
Jaume Aloy
2014-08-19 16:08:17 +02:00
parent d3fd63c9eb
commit 1897f678f9
6 changed files with 101 additions and 23 deletions

View File

@@ -17,6 +17,7 @@
#include "../Chunk.h"
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
#include "../FastRandom.h"
#include "../WorldStorage/StatSerializer.h"
#include "../CompositeChat.h"
@@ -1962,7 +1963,26 @@ void cPlayer::UseEquippedItem(int a_Amount)
{
return;
}
cItem Item = GetEquippedItem();
int UnbreakingLevel = Item.m_Enchantments.GetLevel(cEnchantments::enchUnbreaking);
if (UnbreakingLevel > 0)
{
int chance;
if (ItemCategory::IsArmor(Item.m_ItemType))
{
chance = 60 + (40 / (UnbreakingLevel + 1));
}
else
{
chance = 100 / (UnbreakingLevel + 1);
}
cFastRandom Random;
if (Random.NextInt(100) <= chance)
{
return;
}
}
if (GetInventory().DamageEquippedItem(a_Amount))
{
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));