Fixed Code
This commit is contained in:
parent
b239de66db
commit
a6de7bf1cd
File diff suppressed because it is too large
Load Diff
@ -103,13 +103,13 @@ public:
|
||||
// tolua_end
|
||||
|
||||
/** Add enchantment weights from item to the vector */
|
||||
static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short & a_ItemType, int a_EnchantmentLevel);
|
||||
static void AddItemEnchantmentWeights(cWeightedEnchantments & a_Enchantments, short a_ItemType, int a_EnchantmentLevel);
|
||||
|
||||
/** Add a enchantment weight to the vector */
|
||||
static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, cEnchantments a_Enchantment);
|
||||
static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, int a_EnchantmentID, int a_EnchantmentLevel);
|
||||
/** Remove a enchantment weight from the vector */
|
||||
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, int a_EnchantmentID);
|
||||
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, cEnchantments a_Enchantment);
|
||||
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, int a_EnchantmentID);
|
||||
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments & a_Enchantments, const cEnchantments & a_Enchantment);
|
||||
|
||||
/** Check enchantment conflicts from enchantments from the vector */
|
||||
static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, cEnchantments a_FirstEnchantment);
|
||||
|
122
src/Item.cpp
122
src/Item.cpp
@ -215,49 +215,66 @@ int cItem::GetEnchantability()
|
||||
{
|
||||
int Enchantability = 0;
|
||||
|
||||
if (m_ItemType == E_ITEM_WOODEN_SWORD || m_ItemType == E_ITEM_WOODEN_PICKAXE || m_ItemType == E_ITEM_WOODEN_SHOVEL || m_ItemType == E_ITEM_WOODEN_AXE || m_ItemType == E_ITEM_WOODEN_HOE)
|
||||
switch (m_ItemType)
|
||||
{
|
||||
Enchantability = 15;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_LEATHER_CAP || m_ItemType == E_ITEM_LEATHER_TUNIC || m_ItemType == E_ITEM_LEATHER_PANTS || m_ItemType == E_ITEM_LEATHER_BOOTS)
|
||||
{
|
||||
Enchantability = 15;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_STONE_SWORD || m_ItemType == E_ITEM_STONE_PICKAXE || m_ItemType == E_ITEM_STONE_SHOVEL || m_ItemType == E_ITEM_STONE_AXE || m_ItemType == E_ITEM_STONE_HOE)
|
||||
{
|
||||
Enchantability = 5;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_IRON_HELMET || m_ItemType == E_ITEM_IRON_CHESTPLATE || m_ItemType == E_ITEM_IRON_LEGGINGS || m_ItemType == E_ITEM_IRON_BOOTS)
|
||||
{
|
||||
Enchantability = 9;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_IRON_SWORD || m_ItemType == E_ITEM_IRON_PICKAXE || m_ItemType == E_ITEM_IRON_SHOVEL || m_ItemType == E_ITEM_IRON_AXE || m_ItemType == E_ITEM_IRON_HOE)
|
||||
{
|
||||
Enchantability = 14;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_CHAIN_HELMET || m_ItemType == E_ITEM_CHAIN_CHESTPLATE || m_ItemType == E_ITEM_CHAIN_LEGGINGS || m_ItemType == E_ITEM_CHAIN_BOOTS)
|
||||
{
|
||||
Enchantability = 12;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_DIAMOND_HELMET || m_ItemType == E_ITEM_DIAMOND_CHESTPLATE || m_ItemType == E_ITEM_DIAMOND_LEGGINGS || m_ItemType == E_ITEM_DIAMOND_BOOTS)
|
||||
{
|
||||
Enchantability = 10;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_DIAMOND_SWORD || m_ItemType == E_ITEM_DIAMOND_PICKAXE || m_ItemType == E_ITEM_DIAMOND_SHOVEL || m_ItemType == E_ITEM_DIAMOND_AXE || m_ItemType == E_ITEM_DIAMOND_HOE)
|
||||
{
|
||||
Enchantability = 10;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_GOLD_HELMET || m_ItemType == E_ITEM_GOLD_CHESTPLATE || m_ItemType == E_ITEM_GOLD_LEGGINGS || m_ItemType == E_ITEM_GOLD_BOOTS)
|
||||
{
|
||||
Enchantability = 25;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_GOLD_SWORD || m_ItemType == E_ITEM_GOLD_PICKAXE || m_ItemType == E_ITEM_GOLD_SHOVEL || m_ItemType == E_ITEM_GOLD_AXE || m_ItemType == E_ITEM_GOLD_HOE)
|
||||
{
|
||||
Enchantability = 22;
|
||||
}
|
||||
else if (m_ItemType == E_ITEM_FISHING_ROD || m_ItemType == E_ITEM_BOW || m_ItemType == E_ITEM_BOOK)
|
||||
{
|
||||
Enchantability = 1;
|
||||
case E_ITEM_WOODEN_SWORD: Enchantability = 15;
|
||||
case E_ITEM_WOODEN_PICKAXE: Enchantability = 15;
|
||||
case E_ITEM_WOODEN_SHOVEL: Enchantability = 15;
|
||||
case E_ITEM_WOODEN_AXE: Enchantability = 15;
|
||||
case E_ITEM_WOODEN_HOE: Enchantability = 15;
|
||||
|
||||
case E_ITEM_LEATHER_CAP: Enchantability = 15;
|
||||
case E_ITEM_LEATHER_TUNIC: Enchantability = 15;
|
||||
case E_ITEM_LEATHER_PANTS: Enchantability = 15;
|
||||
case E_ITEM_LEATHER_BOOTS: Enchantability = 15;
|
||||
|
||||
case E_ITEM_STONE_SWORD: Enchantability = 5;
|
||||
case E_ITEM_STONE_PICKAXE: Enchantability = 5;
|
||||
case E_ITEM_STONE_SHOVEL: Enchantability = 5;
|
||||
case E_ITEM_STONE_AXE: Enchantability = 5;
|
||||
case E_ITEM_STONE_HOE: Enchantability = 5;
|
||||
|
||||
case E_ITEM_IRON_HELMET: Enchantability = 9;
|
||||
case E_ITEM_IRON_CHESTPLATE: Enchantability = 9;
|
||||
case E_ITEM_IRON_LEGGINGS: Enchantability = 9;
|
||||
case E_ITEM_IRON_BOOTS: Enchantability = 9;
|
||||
|
||||
case E_ITEM_IRON_SWORD: Enchantability = 14;
|
||||
case E_ITEM_IRON_PICKAXE: Enchantability = 14;
|
||||
case E_ITEM_IRON_SHOVEL: Enchantability = 14;
|
||||
case E_ITEM_IRON_AXE: Enchantability = 14;
|
||||
case E_ITEM_IRON_HOE: Enchantability = 14;
|
||||
|
||||
case E_ITEM_CHAIN_HELMET: Enchantability = 12;
|
||||
case E_ITEM_CHAIN_CHESTPLATE: Enchantability = 12;
|
||||
case E_ITEM_CHAIN_LEGGINGS: Enchantability = 12;
|
||||
case E_ITEM_CHAIN_BOOTS: Enchantability = 12;
|
||||
|
||||
case E_ITEM_DIAMOND_HELMET: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_CHESTPLATE: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_LEGGINGS: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_BOOTS: Enchantability = 10;
|
||||
|
||||
case E_ITEM_DIAMOND_SWORD: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_PICKAXE: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_SHOVEL: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_AXE: Enchantability = 10;
|
||||
case E_ITEM_DIAMOND_HOE: Enchantability = 10;
|
||||
|
||||
case E_ITEM_GOLD_HELMET: Enchantability = 25;
|
||||
case E_ITEM_GOLD_CHESTPLATE: Enchantability = 25;
|
||||
case E_ITEM_GOLD_LEGGINGS: Enchantability = 25;
|
||||
case E_ITEM_GOLD_BOOTS: Enchantability = 25;
|
||||
|
||||
case E_ITEM_GOLD_SWORD: Enchantability = 22;
|
||||
case E_ITEM_GOLD_PICKAXE: Enchantability = 22;
|
||||
case E_ITEM_GOLD_SHOVEL: Enchantability = 22;
|
||||
case E_ITEM_GOLD_AXE: Enchantability = 22;
|
||||
case E_ITEM_GOLD_HOE: Enchantability = 22;
|
||||
|
||||
case E_ITEM_FISHING_ROD: Enchantability = 1;
|
||||
case E_ITEM_BOW: Enchantability = 1;
|
||||
case E_ITEM_BOOK: Enchantability = 1;
|
||||
}
|
||||
|
||||
return Enchantability;
|
||||
@ -269,7 +286,7 @@ int cItem::GetEnchantability()
|
||||
|
||||
bool cItem::EnchantByXPLevels(int a_NumXPLevels)
|
||||
{
|
||||
if (!cItem::IsEnchantable(m_ItemType) && m_ItemType != E_ITEM_BOOK)
|
||||
if ((!cItem::IsEnchantable(m_ItemType)) && (m_ItemType != E_ITEM_BOOK))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -284,9 +301,14 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
|
||||
cWeightedEnchantments enchantments;
|
||||
cEnchantments::AddItemEnchantmentWeights(enchantments, m_ItemType, FinalEnchantmentLevel);
|
||||
|
||||
if (m_ItemType == E_ITEM_BOOK)
|
||||
{
|
||||
m_ItemType = E_ITEM_ENCHANTED_BOOK;
|
||||
}
|
||||
|
||||
cEnchantments Enchantment1 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
|
||||
m_Enchantments.AddFromString(Enchantment1.ToString());
|
||||
cEnchantments::RemoveEnchantmentWeightFromVector(&enchantments, Enchantment1);
|
||||
cEnchantments::RemoveEnchantmentWeightFromVector(enchantments, Enchantment1);
|
||||
|
||||
// Checking for conflicting enchantments
|
||||
cEnchantments::CheckEnchantmentConflictsFromVector(enchantments, Enchantment1);
|
||||
@ -302,12 +324,10 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
|
||||
{
|
||||
cEnchantments Enchantment2 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
|
||||
m_Enchantments.AddFromString(Enchantment2.ToString());
|
||||
cEnchantments::RemoveEnchantmentWeightFromVector(&enchantments, Enchantment2);
|
||||
cEnchantments::RemoveEnchantmentWeightFromVector(enchantments, Enchantment2);
|
||||
|
||||
// Checking for conflicting enchantments
|
||||
cEnchantments::CheckEnchantmentConflictsFromVector(enchantments, Enchantment2);
|
||||
}
|
||||
}
|
||||
|
||||
// Next Enchantment (Third)
|
||||
NewEnchantmentLevel = NewEnchantmentLevel / 2;
|
||||
@ -318,12 +338,10 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
|
||||
{
|
||||
cEnchantments Enchantment3 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
|
||||
m_Enchantments.AddFromString(Enchantment3.ToString());
|
||||
cEnchantments::RemoveEnchantmentWeightFromVector(&enchantments, Enchantment3);
|
||||
cEnchantments::RemoveEnchantmentWeightFromVector(enchantments, Enchantment3);
|
||||
|
||||
// Checking for conflicting enchantments
|
||||
cEnchantments::CheckEnchantmentConflictsFromVector(enchantments, Enchantment3);
|
||||
}
|
||||
}
|
||||
|
||||
// Next Enchantment (Fourth)
|
||||
NewEnchantmentLevel = NewEnchantmentLevel / 2;
|
||||
@ -336,6 +354,10 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
|
||||
m_Enchantments.AddFromString(Enchantment4.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -783,7 +783,8 @@ void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
|
||||
{
|
||||
// Toss the item in the enchanting slot
|
||||
TossItems(a_Player, 0, 1);
|
||||
// Player not found - that is acceptable
|
||||
|
||||
super::OnPlayerRemoved(a_Player);
|
||||
}
|
||||
|
||||
|
||||
@ -838,7 +839,7 @@ int cSlotAreaEnchanting::GetBookshelvesCount(cWorld * a_World)
|
||||
static const struct
|
||||
{
|
||||
int m_BookX, m_BookY, m_BookZ; // Coords to check for bookcases
|
||||
int m_AirX, m_AirY, m_AirZ; // Coords to check for air; if not air, the bookcase won\'t be counted
|
||||
int m_AirX, m_AirY, m_AirZ; // Coords to check for air; if not air, the bookcase won't be counted
|
||||
} CheckCoords[] =
|
||||
{
|
||||
{ 0, 0, 0, 1, 0, 1 }, // Bookcase at {0, 0, 0}, air at {1, 0, 1}
|
||||
|
@ -826,11 +826,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value)
|
||||
{
|
||||
m_PropertyValue[a_Property] = a_Value;
|
||||
|
||||
cCSLock Lock(m_CS);
|
||||
for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
|
||||
{
|
||||
(*itr)->GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
|
||||
} // for itr - m_OpenedBy[]
|
||||
super::SetProperty(a_Property, a_Value);
|
||||
}
|
||||
|
||||
|
||||
@ -841,7 +837,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Pla
|
||||
{
|
||||
m_PropertyValue[a_Property] = a_Value;
|
||||
|
||||
a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
|
||||
super::SetProperty(a_Property, a_Value, a_Player);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user