Protection Enchantments, some fixes
- Protection echantments (fire, blast, feather falling, protection and projectile). It isn't finished, add secondary effects and optimize the code. - Removed some brackets. - Silk touch fixed.
This commit is contained in:
parent
5008eb8c83
commit
19d1c976e7
@ -428,8 +428,14 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
|
||||
{
|
||||
if (!a_DropVerbatim)
|
||||
{
|
||||
ConvertToPickups(Pickups, Meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Add a proper overridable function for this
|
||||
// Pickups.Add(m_BlockType, 1, Meta);
|
||||
cEnchantments Enchantments = a_Digger->GetEquippedWeapon().m_Enchantments;
|
||||
if ((Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0) && (a_Digger->IsPlayer()))
|
||||
if ((Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0) && a_Digger->IsPlayer())
|
||||
{
|
||||
switch (m_BlockType)
|
||||
{
|
||||
@ -459,15 +465,10 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
|
||||
}
|
||||
else
|
||||
{
|
||||
ConvertToPickups(Pickups, Meta);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Add a proper overridable function for this
|
||||
Pickups.Add(m_BlockType, 1, Meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allow plugins to modify the pickups:
|
||||
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
|
||||
|
@ -91,7 +91,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
|
||||
// Broadcast arrow hit sound
|
||||
m_World->BroadcastSoundEffect("random.bowhit", (double)X, (double)Y, (double)Z, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
|
||||
|
||||
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && (IsOnFire()))
|
||||
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && IsOnFire())
|
||||
{
|
||||
m_World->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
|
||||
m_World->SpawnPrimedTNT(X, Y, Z);
|
||||
@ -122,12 +122,12 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
||||
int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
|
||||
if (PunchLevel > 0)
|
||||
{
|
||||
Vector3f LookVector = Vector3d(0, 0, 0);
|
||||
Vector3d LookVector = GetLookVector();
|
||||
Vector3f FinalSpeed = Vector3f(0, 0, 0);
|
||||
switch (PunchLevel)
|
||||
{
|
||||
case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5);
|
||||
case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8);
|
||||
case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5); break;
|
||||
case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8); break;
|
||||
default: break;
|
||||
}
|
||||
a_EntityHit.SetSpeed(FinalSpeed);
|
||||
@ -135,7 +135,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
|
||||
|
||||
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);
|
||||
|
||||
if ((IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming()))
|
||||
if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming())
|
||||
{
|
||||
a_EntityHit.StartBurning(100);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "../Tracer.h"
|
||||
#include "Player.h"
|
||||
#include "Items/ItemHandler.h"
|
||||
#include "../FastRandom.h"
|
||||
|
||||
|
||||
|
||||
@ -324,7 +325,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
|
||||
if (SharpnessLevel > 0)
|
||||
{
|
||||
a_TDI.RawDamage += 1.25 * SharpnessLevel;
|
||||
a_TDI.FinalDamage += 1.25 * SharpnessLevel;
|
||||
}
|
||||
else if (SmiteLevel > 0)
|
||||
{
|
||||
@ -338,7 +339,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
case cMonster::mtWither:
|
||||
case cMonster::mtZombiePigman:
|
||||
{
|
||||
a_TDI.RawDamage += 2.5 * SmiteLevel;
|
||||
a_TDI.FinalDamage += 2.5 * SmiteLevel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -404,6 +405,110 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
|
||||
Player->GetStatManager().AddValue(statDamageDealt, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
|
||||
}
|
||||
if (IsPlayer()){
|
||||
double TotalEPF = 0.0;
|
||||
double EPFProtection = 0.00;
|
||||
double EPFFireProtection = 0.00;
|
||||
double EPFBlastProtection = 0.00;
|
||||
double EPFProjectileProtection = 0.00;
|
||||
double EPFFeatherFalling = 0.00;
|
||||
|
||||
cEnchantments ChestplateEnchantments = GetEquippedChestplate().m_Enchantments;
|
||||
cEnchantments LeggingsEnchantments = GetEquippedLeggings().m_Enchantments;
|
||||
cEnchantments BootsEnchantments = GetEquippedBoots().m_Enchantments;
|
||||
cEnchantments HelmetEnchantments = GetEquippedHelmet().m_Enchantments;
|
||||
|
||||
if ((ChestplateEnchantments.GetLevel(cEnchantments::enchProtection) > 0) || (LeggingsEnchantments.GetLevel(cEnchantments::enchProtection) > 0)
|
||||
|| (BootsEnchantments.GetLevel(cEnchantments::enchProtection) > 0) || (HelmetEnchantments.GetLevel(cEnchantments::enchProtection) > 0))
|
||||
{
|
||||
EPFProtection += (6 + pow(ChestplateEnchantments.GetLevel(cEnchantments::enchProtection), 2)) * 0.75 / 3;
|
||||
EPFProtection += (6 + pow(LeggingsEnchantments.GetLevel(cEnchantments::enchProtection), 2)) * 0.75 / 3;
|
||||
EPFProtection += (6 + pow(BootsEnchantments.GetLevel(cEnchantments::enchProtection), 2)) * 0.75 / 3;
|
||||
EPFProtection += (6 + pow(HelmetEnchantments.GetLevel(cEnchantments::enchProtection), 2)) * 0.75 / 3;
|
||||
|
||||
TotalEPF += EPFProtection;
|
||||
}
|
||||
|
||||
if ((ChestplateEnchantments.GetLevel(cEnchantments::enchFireProtection) > 0) || (LeggingsEnchantments.GetLevel(cEnchantments::enchFireProtection) > 0)
|
||||
|| (BootsEnchantments.GetLevel(cEnchantments::enchFireProtection) > 0) || (HelmetEnchantments.GetLevel(cEnchantments::enchFireProtection) > 0))
|
||||
{
|
||||
EPFFireProtection += (6 + pow(ChestplateEnchantments.GetLevel(cEnchantments::enchFireProtection), 2)) * 1.25 / 3;
|
||||
EPFFireProtection += (6 + pow(LeggingsEnchantments.GetLevel(cEnchantments::enchFireProtection), 2)) * 1.25 / 3;
|
||||
EPFFireProtection += (6 + pow(BootsEnchantments.GetLevel(cEnchantments::enchFireProtection), 2)) * 1.25 / 3;
|
||||
EPFFireProtection += (6 + pow(HelmetEnchantments.GetLevel(cEnchantments::enchFireProtection), 2)) * 1.25 / 3;
|
||||
|
||||
TotalEPF += EPFFireProtection;
|
||||
}
|
||||
|
||||
if ((ChestplateEnchantments.GetLevel(cEnchantments::enchFeatherFalling) > 0) || (LeggingsEnchantments.GetLevel(cEnchantments::enchFeatherFalling) > 0)
|
||||
|| (BootsEnchantments.GetLevel(cEnchantments::enchFeatherFalling) > 0) || (HelmetEnchantments.GetLevel(cEnchantments::enchFeatherFalling) > 0))
|
||||
{
|
||||
EPFFeatherFalling += (6 + pow(ChestplateEnchantments.GetLevel(cEnchantments::enchFeatherFalling), 2)) * 2.5 / 3;
|
||||
EPFFeatherFalling += (6 + pow(LeggingsEnchantments.GetLevel(cEnchantments::enchFeatherFalling), 2)) * 2.5 / 3;
|
||||
EPFFeatherFalling += (6 + pow(BootsEnchantments.GetLevel(cEnchantments::enchFeatherFalling), 2)) * 2.5 / 3;
|
||||
EPFFeatherFalling += (6 + pow(HelmetEnchantments.GetLevel(cEnchantments::enchFeatherFalling), 2)) * 2.5 / 3;
|
||||
|
||||
TotalEPF += EPFFeatherFalling;
|
||||
}
|
||||
|
||||
if ((ChestplateEnchantments.GetLevel(cEnchantments::enchBlastProtection) > 0) || (LeggingsEnchantments.GetLevel(cEnchantments::enchBlastProtection) > 0)
|
||||
|| (BootsEnchantments.GetLevel(cEnchantments::enchBlastProtection) > 0) || (HelmetEnchantments.GetLevel(cEnchantments::enchBlastProtection) > 0))
|
||||
{
|
||||
EPFBlastProtection += (6 + pow(ChestplateEnchantments.GetLevel(cEnchantments::enchBlastProtection), 2)) * 1.5 / 3;
|
||||
EPFBlastProtection += (6 + pow(LeggingsEnchantments.GetLevel(cEnchantments::enchBlastProtection), 2)) * 1.5 / 3;
|
||||
EPFBlastProtection += (6 + pow(BootsEnchantments.GetLevel(cEnchantments::enchBlastProtection), 2)) * 1.5 / 3;
|
||||
EPFBlastProtection += (6 + pow(HelmetEnchantments.GetLevel(cEnchantments::enchBlastProtection), 2)) * 1.5 / 3;
|
||||
|
||||
TotalEPF += EPFBlastProtection;
|
||||
}
|
||||
|
||||
if ((ChestplateEnchantments.GetLevel(cEnchantments::enchProjectileProtection) > 0) || (LeggingsEnchantments.GetLevel(cEnchantments::enchProjectileProtection) > 0)
|
||||
|| (BootsEnchantments.GetLevel(cEnchantments::enchProjectileProtection) > 0) || (HelmetEnchantments.GetLevel(cEnchantments::enchProjectileProtection) > 0))
|
||||
{
|
||||
EPFProjectileProtection += (6 + pow(ChestplateEnchantments.GetLevel(cEnchantments::enchProjectileProtection), 2)) * 1.5 / 3;
|
||||
EPFProjectileProtection += (6 + pow(LeggingsEnchantments.GetLevel(cEnchantments::enchProjectileProtection), 2)) * 1.5 / 3;
|
||||
EPFProjectileProtection += (6 + pow(BootsEnchantments.GetLevel(cEnchantments::enchProjectileProtection), 2)) * 1.5 / 3;
|
||||
EPFProjectileProtection += (6 + pow(HelmetEnchantments.GetLevel(cEnchantments::enchProjectileProtection), 2)) * 1.5 / 3;
|
||||
|
||||
TotalEPF += EPFProjectileProtection;
|
||||
}
|
||||
|
||||
EPFProtection = EPFProtection / TotalEPF;
|
||||
EPFFireProtection = EPFFireProtection / TotalEPF;
|
||||
EPFFeatherFalling = EPFFeatherFalling / TotalEPF;
|
||||
EPFBlastProtection = EPFBlastProtection / TotalEPF;
|
||||
EPFProjectileProtection = EPFProjectileProtection / TotalEPF;
|
||||
|
||||
if (TotalEPF > 25) TotalEPF = 25;
|
||||
|
||||
cFastRandom Random;
|
||||
float randomvalue;
|
||||
randomvalue = Random.GenerateRandomInteger(50, 100) * 0.01;
|
||||
|
||||
TotalEPF = ceil(TotalEPF * randomvalue);
|
||||
|
||||
if (TotalEPF > 20) TotalEPF = 20;
|
||||
|
||||
EPFProtection = TotalEPF * EPFProtection;
|
||||
EPFFireProtection = TotalEPF * EPFFireProtection;
|
||||
EPFFeatherFalling = TotalEPF * EPFFeatherFalling;
|
||||
EPFBlastProtection = TotalEPF * EPFBlastProtection;
|
||||
EPFProjectileProtection = TotalEPF * EPFProjectileProtection;
|
||||
|
||||
int RemovedDamage = 0;
|
||||
|
||||
if (a_TDI.DamageType != dtInVoid) RemovedDamage += ceil(EPFProtection * 0.04 * a_TDI.FinalDamage);
|
||||
|
||||
if ((a_TDI.DamageType == dtFalling) || (a_TDI.DamageType == dtFall) || (a_TDI.DamageType == dtEnderPearl)) RemovedDamage += ceil(EPFFeatherFalling * 0.04 * a_TDI.FinalDamage);
|
||||
|
||||
if (a_TDI.DamageType == dtBurning) RemovedDamage += ceil(EPFFireProtection * 0.04 * a_TDI.FinalDamage);
|
||||
|
||||
if (a_TDI.DamageType == dtExplosion) RemovedDamage += ceil(EPFBlastProtection * 0.04 * a_TDI.FinalDamage);
|
||||
|
||||
if (a_TDI.DamageType == dtProjectile) RemovedDamage += ceil(EPFBlastProtection * 0.04 * a_TDI.FinalDamage);
|
||||
|
||||
a_TDI.FinalDamage -= RemovedDamage;
|
||||
}
|
||||
|
||||
m_Health -= (short)a_TDI.FinalDamage;
|
||||
|
||||
@ -411,6 +516,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
|
||||
m_Health = std::max(m_Health, 0);
|
||||
|
||||
|
||||
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
|
||||
{
|
||||
int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
|
||||
|
@ -1978,7 +1978,7 @@ void cPlayer::UseEquippedItem(int a_Amount)
|
||||
}
|
||||
|
||||
cFastRandom Random;
|
||||
if (Random.NextInt(100) <= chance)
|
||||
if (Random.NextInt(101) <= chance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user