2013-07-29 07:13:03 -04:00
|
|
|
// Enchantments.cpp
|
|
|
|
|
|
|
|
// Implements the cEnchantments class representing a storage for item enchantments and stored-enchantments
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "Enchantments.h"
|
|
|
|
#include "WorldStorage/FastNBT.h"
|
2014-04-17 07:15:35 -04:00
|
|
|
#include "FastRandom.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cEnchantments::cEnchantments(void)
|
|
|
|
{
|
|
|
|
// Nothing needed yet, but the constructor needs to be declared and impemented in order to be usable
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cEnchantments::cEnchantments(const AString & a_StringSpec)
|
|
|
|
{
|
|
|
|
AddFromString(a_StringSpec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-20 08:16:26 -04:00
|
|
|
void cEnchantments::Add(const cEnchantments & a_Other)
|
|
|
|
{
|
|
|
|
for (cEnchantments::cMap::const_iterator itr = a_Other.m_Enchantments.begin(), end = a_Other.m_Enchantments.end(); itr != end; ++itr)
|
|
|
|
{
|
|
|
|
SetLevel(itr->first, itr->second);
|
|
|
|
} // for itr - a_Other.m_Enchantments[]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
void cEnchantments::AddFromString(const AString & a_StringSpec)
|
|
|
|
{
|
|
|
|
// Add enchantments in the stringspec; if a specified enchantment already exists, overwrites it
|
|
|
|
|
|
|
|
// Split the StringSpec into separate declarations, each in the form "id=lvl":
|
|
|
|
AStringVector Decls = StringSplit(a_StringSpec, ";");
|
|
|
|
for (AStringVector::const_iterator itr = Decls.begin(), end = Decls.end(); itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Split each declaration into the id and lvl part:
|
|
|
|
if (itr->empty())
|
|
|
|
{
|
|
|
|
// The decl is empty (may happen if there's an extra semicolon at the end), ignore silently
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
AStringVector Split = StringSplitAndTrim(*itr, "=");
|
|
|
|
if (Split.size() != 2)
|
|
|
|
{
|
|
|
|
// Malformed decl
|
|
|
|
LOG("%s: Malformed enchantment decl: \"%s\", skipping.", __FUNCTION__, itr->c_str());
|
|
|
|
continue;
|
|
|
|
}
|
2014-04-10 13:09:21 -04:00
|
|
|
int id = StringToEnchantmentID(Split[0]);
|
|
|
|
if (id < 0)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-04-10 13:09:21 -04:00
|
|
|
LOG("%s: Failed to parse enchantment \"%s\", skipping.", __FUNCTION__, Split[0].c_str());
|
|
|
|
continue;
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
int lvl = atoi(Split[1].c_str());
|
2014-04-10 13:09:21 -04:00
|
|
|
if ((lvl == 0) && (Split[1] != "0"))
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-04-10 13:09:21 -04:00
|
|
|
// Level failed to parse
|
|
|
|
LOG("%s: Failed to parse enchantment level \"%s\", skipping.", __FUNCTION__, Split[1].c_str());
|
2013-07-29 07:13:03 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SetLevel(id, lvl);
|
|
|
|
} // for itr - Decls[]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-06 13:38:09 -04:00
|
|
|
size_t cEnchantments::Count(void)
|
2014-04-30 18:47:57 -04:00
|
|
|
{
|
2014-05-05 16:11:48 -04:00
|
|
|
return m_Enchantments.size();
|
2014-04-30 18:47:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
AString cEnchantments::ToString(void) const
|
|
|
|
{
|
|
|
|
// Serialize all the enchantments into a string
|
|
|
|
AString res;
|
|
|
|
for (cEnchantments::cMap::const_iterator itr = m_Enchantments.begin(), end = m_Enchantments.end(); itr != end; ++itr)
|
|
|
|
{
|
|
|
|
AppendPrintf(res, "%d=%d;", itr->first, itr->second);
|
|
|
|
} // for itr - m_Enchantments[]
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int cEnchantments::GetLevel(int a_EnchantmentID) const
|
|
|
|
{
|
|
|
|
// Return the level for the specified enchantment; 0 if not stored
|
|
|
|
cMap::const_iterator itr = m_Enchantments.find(a_EnchantmentID);
|
|
|
|
if (itr != m_Enchantments.end())
|
|
|
|
{
|
|
|
|
return itr->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not stored, return zero
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEnchantments::SetLevel(int a_EnchantmentID, int a_Level)
|
|
|
|
{
|
|
|
|
// Sets the level for the specified enchantment, adding it if not stored before or removing it if level <= 0
|
|
|
|
if (a_Level == 0)
|
|
|
|
{
|
|
|
|
// Delete enchantment, if present:
|
|
|
|
cMap::iterator itr = m_Enchantments.find(a_EnchantmentID);
|
|
|
|
if (itr != m_Enchantments.end())
|
|
|
|
{
|
|
|
|
m_Enchantments.erase(itr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Add / overwrite enchantment
|
|
|
|
m_Enchantments[a_EnchantmentID] = a_Level;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEnchantments::Clear(void)
|
|
|
|
{
|
|
|
|
m_Enchantments.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cEnchantments::IsEmpty(void) const
|
|
|
|
{
|
|
|
|
return m_Enchantments.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int cEnchantments::StringToEnchantmentID(const AString & a_EnchantmentName)
|
|
|
|
{
|
2014-04-10 13:09:21 -04:00
|
|
|
static const struct
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
int m_Value;
|
|
|
|
const char * m_Name;
|
|
|
|
} EnchantmentNames[] =
|
|
|
|
{
|
|
|
|
{ enchProtection, "Protection"},
|
|
|
|
{ enchFireProtection, "FireProtection"},
|
|
|
|
{ enchFeatherFalling, "FeatherFalling"},
|
|
|
|
{ enchBlastProtection, "BlastProtection"},
|
|
|
|
{ enchProjectileProtection, "ProjectileProtection"},
|
|
|
|
{ enchRespiration, "Respiration"},
|
|
|
|
{ enchAquaAffinity, "AquaAffinity"},
|
|
|
|
{ enchThorns, "Thorns"},
|
|
|
|
{ enchSharpness, "Sharpness"},
|
|
|
|
{ enchSmite, "Smite"},
|
|
|
|
{ enchBaneOfArthropods, "BaneOfArthropods"},
|
|
|
|
{ enchKnockback, "Knockback"},
|
|
|
|
{ enchFireAspect, "FireAspect"},
|
|
|
|
{ enchLooting, "Looting"},
|
|
|
|
{ enchEfficiency, "Efficiency"},
|
|
|
|
{ enchSilkTouch, "SilkTouch"},
|
|
|
|
{ enchUnbreaking, "Unbreaking"},
|
|
|
|
{ enchFortune, "Fortune"},
|
|
|
|
{ enchPower, "Power"},
|
|
|
|
{ enchPunch, "Punch"},
|
|
|
|
{ enchFlame, "Flame"},
|
|
|
|
{ enchInfinity, "Infinity"},
|
2013-11-13 02:17:26 -05:00
|
|
|
{ enchLuckOfTheSea, "LuckOfTheSea"},
|
|
|
|
{ enchLure, "Lure"},
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
2014-04-10 13:09:21 -04:00
|
|
|
|
|
|
|
// First try to parse as a number:
|
|
|
|
int id = atoi(a_EnchantmentName.c_str());
|
|
|
|
if ((id != 0) || (a_EnchantmentName == "0"))
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
// It wasn't a number, do a lookup:
|
2013-12-20 10:01:34 -05:00
|
|
|
for (size_t i = 0; i < ARRAYCOUNT(EnchantmentNames); i++)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
if (NoCaseCompare(EnchantmentNames[i].m_Name, a_EnchantmentName) == 0)
|
|
|
|
{
|
|
|
|
return EnchantmentNames[i].m_Value;
|
|
|
|
}
|
|
|
|
} // for i - EnchantmentNames[]
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cEnchantments::operator ==(const cEnchantments & a_Other) const
|
|
|
|
{
|
|
|
|
return m_Enchantments == a_Other.m_Enchantments;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cEnchantments::operator !=(const cEnchantments & a_Other) const
|
|
|
|
{
|
|
|
|
return m_Enchantments != a_Other.m_Enchantments;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-19 09:10:50 -04:00
|
|
|
void cEnchantments::AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short a_ItemType, int a_EnchantmentLevel)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
|
|
|
if (ItemCategory::IsSword(a_ItemType))
|
|
|
|
{
|
|
|
|
// Sharpness
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 34) && (a_EnchantmentLevel <= 54))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 23) && (a_EnchantmentLevel <= 43))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 12) && (a_EnchantmentLevel <= 32))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 21))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Smite
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 29) && (a_EnchantmentLevel <= 49))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 25))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bane of Arthropods
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 29) && (a_EnchantmentLevel <= 49))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 25))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Knockback
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 25) && (a_EnchantmentLevel <= 75))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchKnockback, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 55))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchKnockback, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fire Aspect
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 30) && (a_EnchantmentLevel <= 80))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFireAspect, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 60))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFireAspect, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Looting
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 33) && (a_EnchantmentLevel <= 83))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchLooting, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 24) && (a_EnchantmentLevel <= 74))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchLooting, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchLooting, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ItemCategory::IsTool(a_ItemType))
|
|
|
|
{
|
|
|
|
// Efficiency
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 31) && (a_EnchantmentLevel <= 81))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 71))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 11) && (a_EnchantmentLevel <= 61))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 51))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Silk Touch
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchSilkTouch, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fortune
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 33) && (a_EnchantmentLevel <= 83))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFortune, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 24) && (a_EnchantmentLevel <= 74))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFortune, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFortune, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ItemCategory::IsArmor(a_ItemType))
|
|
|
|
{
|
|
|
|
// Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 34) && (a_EnchantmentLevel <= 54))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 23) && (a_EnchantmentLevel <= 43))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 12) && (a_EnchantmentLevel <= 32))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 21))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fire Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 34) && (a_EnchantmentLevel <= 46))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 26) && (a_EnchantmentLevel <= 38))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 18) && (a_EnchantmentLevel <= 30))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 22))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Blast Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 29) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 25))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 17))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Projectile Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 36))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 30))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 9) && (a_EnchantmentLevel <= 24))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 3) && (a_EnchantmentLevel <= 18))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Thorns
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 50) && (a_EnchantmentLevel <= 100))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchThorns, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 30) && (a_EnchantmentLevel <= 80))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchThorns, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 60))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchThorns, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ItemCategory::IsHelmet(a_ItemType))
|
|
|
|
{
|
|
|
|
// Respiration
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 30) && (a_EnchantmentLevel <= 60))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchRespiration, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 20) && (a_EnchantmentLevel <= 50))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchRespiration, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 40))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchRespiration, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Aqua Affinity
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchAquaAffinity, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ItemCategory::IsBoots(a_ItemType))
|
|
|
|
{
|
|
|
|
// Feather Fall
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 23) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 17) && (a_EnchantmentLevel <= 27))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 11) && (a_EnchantmentLevel <= 21))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 15))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (a_ItemType == E_ITEM_BOW)
|
|
|
|
{
|
|
|
|
// Power
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 31) && (a_EnchantmentLevel <= 46))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 36))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 11) && (a_EnchantmentLevel <= 26))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 16))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Punch
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 32) && (a_EnchantmentLevel <= 57))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchPunch, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 12) && (a_EnchantmentLevel <= 37))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchPunch, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Flame and Infinity
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 20) && (a_EnchantmentLevel <= 50))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFlame, 1);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchInfinity, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (a_ItemType == E_ITEM_FISHING_ROD)
|
|
|
|
{
|
|
|
|
// Luck of the Sea and Lure
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 33) && (a_EnchantmentLevel <= 83))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLuckOfTheSea, 3);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLure, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 24) && (a_EnchantmentLevel <= 74))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLuckOfTheSea, 2);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLure, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLuckOfTheSea, 1);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLure, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (a_ItemType == E_ITEM_BOOK)
|
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
// All Enchantments
|
2014-04-17 07:15:35 -04:00
|
|
|
|
|
|
|
// Sharpness
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 34) && (a_EnchantmentLevel <= 54))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 23) && (a_EnchantmentLevel <= 43))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 12) && (a_EnchantmentLevel <= 32))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 21))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchSharpness, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Smite
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 29) && (a_EnchantmentLevel <= 49))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 25))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchSmite, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bane of Arthropods
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 29) && (a_EnchantmentLevel <= 49))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 25))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchBaneOfArthropods, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Knockback
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 25) && (a_EnchantmentLevel <= 75))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchKnockback, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 55))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchKnockback, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fire Aspect
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 30) && (a_EnchantmentLevel <= 80))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFireAspect, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 60))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFireAspect, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Looting
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 33) && (a_EnchantmentLevel <= 83))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchLooting, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 24) && (a_EnchantmentLevel <= 74))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchLooting, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchLooting, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Efficiency
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 31) && (a_EnchantmentLevel <= 81))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 71))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 11) && (a_EnchantmentLevel <= 61))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 51))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchEfficiency, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Silk Touch
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchSilkTouch, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fortune
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 33) && (a_EnchantmentLevel <= 83))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFortune, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 24) && (a_EnchantmentLevel <= 74))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFortune, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFortune, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 34) && (a_EnchantmentLevel <= 54))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 23) && (a_EnchantmentLevel <= 43))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 12) && (a_EnchantmentLevel <= 32))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 21))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Fire Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 34) && (a_EnchantmentLevel <= 46))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 26) && (a_EnchantmentLevel <= 38))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 18) && (a_EnchantmentLevel <= 30))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 22))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFireProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Blast Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 29) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 25))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 17))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchBlastProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Projectile Protection
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 36))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 30))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 9) && (a_EnchantmentLevel <= 24))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 3) && (a_EnchantmentLevel <= 18))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchProjectileProtection, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Thorns
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 50) && (a_EnchantmentLevel <= 100))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchThorns, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 30) && (a_EnchantmentLevel <= 80))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchThorns, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 60))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchThorns, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Respiration
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 30) && (a_EnchantmentLevel <= 60))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchRespiration, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 20) && (a_EnchantmentLevel <= 50))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchRespiration, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 10) && (a_EnchantmentLevel <= 40))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchRespiration, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Aqua Affinity
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 41))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchAquaAffinity, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Feather Fall
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 23) && (a_EnchantmentLevel <= 33))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 17) && (a_EnchantmentLevel <= 27))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 11) && (a_EnchantmentLevel <= 21))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 15))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchFeatherFalling, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Power
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 31) && (a_EnchantmentLevel <= 46))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 4);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 36))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 11) && (a_EnchantmentLevel <= 26))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 1) && (a_EnchantmentLevel <= 16))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 10, enchPower, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Punch
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 32) && (a_EnchantmentLevel <= 57))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchPunch, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 12) && (a_EnchantmentLevel <= 37))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchPunch, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Flame and Infinity
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 20) && (a_EnchantmentLevel <= 50))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 2, enchFlame, 1);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchInfinity, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Luck of the Sea and Lure
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 33) && (a_EnchantmentLevel <= 83))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLuckOfTheSea, 3);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLure, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 24) && (a_EnchantmentLevel <= 74))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLuckOfTheSea, 2);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLure, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 15) && (a_EnchantmentLevel <= 65))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLuckOfTheSea, 1);
|
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 1, enchLure, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unbreaking
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((a_EnchantmentLevel >= 21) && (a_EnchantmentLevel <= 71))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchUnbreaking, 3);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 13) && (a_EnchantmentLevel <= 63))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchUnbreaking, 2);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if ((a_EnchantmentLevel >= 5) && (a_EnchantmentLevel <= 55))
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 16:37:29 -04:00
|
|
|
AddEnchantmentWeightToVector(a_Enchantments, 5, enchUnbreaking, 1);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-19 16:37:29 -04:00
|
|
|
void cEnchantments::AddEnchantmentWeightToVector(cWeightedEnchantments & a_Enchantments, int a_Weight, int a_EnchantmentID, int a_EnchantmentLevel)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
cWeightedEnchantment weightedenchantment;
|
|
|
|
weightedenchantment.m_Weight = a_Weight;
|
|
|
|
cEnchantments enchantment;
|
|
|
|
enchantment.SetLevel(a_EnchantmentID, a_EnchantmentLevel);
|
|
|
|
weightedenchantment.m_Enchantments = enchantment;
|
2014-04-19 16:37:29 -04:00
|
|
|
a_Enchantments.push_back(weightedenchantment);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-19 09:10:50 -04:00
|
|
|
void cEnchantments::RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, int a_EnchantmentID)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
for (cWeightedEnchantments::iterator it = a_Enchantments.begin(); it != a_Enchantments.end(); ++it)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
if ((*it).m_Enchantments.GetLevel(a_EnchantmentID) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
a_Enchantments.erase(it);
|
2014-04-18 08:34:29 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-19 09:10:50 -04:00
|
|
|
void cEnchantments::RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, const cEnchantments & a_Enchantment)
|
2014-04-18 08:34:29 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
for (cWeightedEnchantments::iterator it = a_Enchantments.begin(); it != a_Enchantments.end(); ++it)
|
2014-04-18 08:34:29 -04:00
|
|
|
{
|
|
|
|
if ((*it).m_Enchantments == a_Enchantment)
|
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
a_Enchantments.erase(it);
|
2014-04-17 07:15:35 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cEnchantments::CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, cEnchantments a_FirstEnchantment)
|
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
if (a_FirstEnchantment.GetLevel(cEnchantments::enchProtection) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchFireProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchBlastProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchProjectileProtection);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchFireProtection) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchBlastProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchProjectileProtection);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchBlastProtection) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchFireProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchProjectileProtection);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchProjectileProtection) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchFireProtection);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchBlastProtection);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchSharpness) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchSmite);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchBaneOfArthropods);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchSmite) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchSharpness);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchBaneOfArthropods);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchBaneOfArthropods) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchSharpness);
|
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchSmite);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchSilkTouch) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchFortune);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
2014-04-19 09:10:50 -04:00
|
|
|
else if (a_FirstEnchantment.GetLevel(cEnchantments::enchFortune) > 0)
|
2014-04-17 07:15:35 -04:00
|
|
|
{
|
2014-04-19 09:10:50 -04:00
|
|
|
RemoveEnchantmentWeightFromVector(a_Enchantments, cEnchantments::enchSilkTouch);
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cEnchantments cEnchantments::GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments)
|
|
|
|
{
|
|
|
|
cFastRandom Random;
|
|
|
|
|
|
|
|
int AllWeights = 0;
|
|
|
|
for (cWeightedEnchantments::iterator it = a_Enchantments.begin(); it != a_Enchantments.end(); ++it)
|
|
|
|
{
|
|
|
|
AllWeights += (*it).m_Weight;
|
|
|
|
}
|
|
|
|
int RandomNumber = Random.GenerateRandomInteger(0, AllWeights - 1);
|
|
|
|
for (cWeightedEnchantments::iterator it = a_Enchantments.begin(); it != a_Enchantments.end(); ++it)
|
|
|
|
{
|
|
|
|
RandomNumber -= (*it).m_Weight;
|
|
|
|
if (RandomNumber < 0)
|
|
|
|
{
|
|
|
|
return (*it).m_Enchantments;
|
|
|
|
}
|
|
|
|
}
|
2014-04-18 08:34:29 -04:00
|
|
|
|
|
|
|
return cEnchantments();
|
2014-04-17 07:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|