Refactor and improve vendor items
This commit is contained in:
@@ -327,6 +327,7 @@ namespace Game.Entities
|
||||
|
||||
public class VendorItem
|
||||
{
|
||||
public VendorItem() { }
|
||||
public VendorItem(uint _item, int _maxcount, uint _incrtime, uint _ExtendedCost, ItemVendorType _Type)
|
||||
{
|
||||
item = _item;
|
||||
@@ -341,6 +342,9 @@ namespace Game.Entities
|
||||
public uint incrtime; // time for restore items amount if maxcount != 0
|
||||
public uint ExtendedCost;
|
||||
public ItemVendorType Type;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
public uint PlayerConditionId;
|
||||
public bool IgnoreFiltering;
|
||||
|
||||
//helpers
|
||||
public bool IsGoldRequired(ItemTemplate pProto) { return Convert.ToBoolean(pProto.GetFlags2() & ItemFlags2.DontIgnoreBuyPrice) || ExtendedCost == 0; }
|
||||
@@ -365,9 +369,9 @@ namespace Game.Entities
|
||||
{
|
||||
return m_items.Count;
|
||||
}
|
||||
public void AddItem(uint item, int maxcount, uint ptime, uint ExtendedCost, ItemVendorType type)
|
||||
public void AddItem(VendorItem vItem)
|
||||
{
|
||||
m_items.Add(new VendorItem(item, maxcount, ptime, ExtendedCost, type));
|
||||
m_items.Add(vItem);
|
||||
}
|
||||
public bool RemoveItem(uint item_id, ItemVendorType type)
|
||||
{
|
||||
|
||||
@@ -2790,7 +2790,7 @@ namespace Game.Entities
|
||||
return distsq < maxdist * maxdist;
|
||||
}
|
||||
|
||||
bool IsInBetween(WorldObject obj1, WorldObject obj2, float size = 0) { return obj1 && obj2 && IsInBetween(obj1.GetPosition(), obj2.GetPosition(), size); }
|
||||
public bool IsInBetween(WorldObject obj1, WorldObject obj2, float size = 0) { return obj1 && obj2 && IsInBetween(obj1.GetPosition(), obj2.GetPosition(), size); }
|
||||
bool IsInBetween(Position pos1, Position pos2, float size)
|
||||
{
|
||||
float dist = GetExactDist2d(pos1);
|
||||
|
||||
@@ -2517,7 +2517,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Item it = bStore ? StoreNewItem(vDest, item, true, ItemEnchantment.GenerateItemRandomPropertyId(item), null, 0, null, false) : EquipNewItem(uiDest, item, true);
|
||||
Item it = bStore ? StoreNewItem(vDest, item, true, ItemEnchantment.GenerateItemRandomPropertyId(item), null, 0, crItem.BonusListIDs, false) : EquipNewItem(uiDest, item, true);
|
||||
if (it != null)
|
||||
{
|
||||
uint new_count = pVendor.UpdateVendorItemCurrentCount(crItem, count);
|
||||
@@ -3630,6 +3630,16 @@ namespace Game.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(crItem.PlayerConditionId);
|
||||
if (playerCondition != null)
|
||||
{
|
||||
if (!ConditionManager.IsPlayerMeetingCondition(this, playerCondition))
|
||||
{
|
||||
SendEquipError(InventoryResult.ItemLocked);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check current item amount if it limited
|
||||
if (crItem.maxcount != 0)
|
||||
{
|
||||
|
||||
@@ -661,7 +661,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveAllGameObjects()
|
||||
public void RemoveAllGameObjects()
|
||||
{
|
||||
// remove references to unit
|
||||
while (!m_gameObj.Empty())
|
||||
|
||||
Reference in New Issue
Block a user