UOBetty
Initiate
This fixes the problem with gold and items going to your feet if you buy too much for your weight from a vendor and it goes directly to the bank.
basevendor.cs
Find:
Replace:
Find:
REPLACE:
Find:
REPLACE:
basevendor.cs
Find:
Code:
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
Replace:
Code:
private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
{
if (amount > bii.Amount)
{
amount = bii.Amount;
}
if (amount < 1)
{
return;
}
bii.Amount -= amount;
IEntity o = bii.GetEntity();
if (o is Item)
{
Item item = (Item)o;
if (item.Stackable)
{
item.Amount = amount;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem( item );
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
}
else
{
item.Amount = 1;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem(item);
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
for (int i = 1; i < amount; i++)
{
item = bii.GetEntity() as Item;
if (item != null)
{
item.Amount = 1;
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem(item);
}
// if (cont == null || !cont.TryDropItem(buyer, item, false))
// {
// item.MoveToWorld(buyer.Location, buyer.Map);
// }
}
}
}
}
else if (o is Mobile)
{
Mobile m = (Mobile)o;
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
m.PlaySound(m.GetIdleSound());
if (m is BaseCreature)
{
((BaseCreature)m).SetControlMaster(buyer);
}
for (int i = 1; i < amount; ++i)
{
m = bii.GetEntity() as Mobile;
if (m != null)
{
m.Direction = (Direction)Utility.Random(8);
m.MoveToWorld(buyer.Location, buyer.Map);
if (m is BaseCreature)
{
((BaseCreature)m).SetControlMaster(buyer);
}
}
}
}
}
Find:
Code:
public virtual bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
REPLACE:
Code:
public virtual bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
{
if (!IsActiveSeller)
{
return false;
}
if (!buyer.CheckAlive())
{
return false;
}
if (!CheckVendorAccess(buyer))
{
Say(501522); // I shall not treat with scum like thee!
return false;
}
UpdateBuyInfo();
var buyInfo = GetBuyInfo();
var info = GetSellInfo();
int totalCost = 0;
var validBuy = new List<BuyItemResponse>(list.Count);
Container cont;
bool bought = false;
bool fromBank = false;
bool fullPurchase = true;
int controlSlots = buyer.FollowersMax - buyer.Followers;
foreach (BuyItemResponse buy in list)
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if (ser.IsItem)
{
Item item = World.FindItem(ser);
if (item == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(item);
if (gbi != null)
{
ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
}
else if (item != BuyPack && item.IsChildOf(BuyPack))
{
if (amount > item.Amount)
{
amount = item.Amount;
}
if (amount <= 0)
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
totalCost += ssi.GetBuyPriceFor(item) * amount;
validBuy.Add(buy);
break;
}
}
}
}
}
else if (ser.IsMobile)
{
Mobile mob = World.FindMobile(ser);
if (mob == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(mob);
if (gbi != null)
{
ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost);
}
}
} //foreach
if (fullPurchase && validBuy.Count == 0)
{
SayTo(buyer, 500190); // Thou hast bought nothing!
}
else if (validBuy.Count == 0)
{
SayTo(buyer, 500187); // Your order cannot be fulfilled, please try again.
}
if (validBuy.Count == 0)
{
return false;
}
bought = buyer.AccessLevel >= AccessLevel.GameMaster;
cont = buyer.Backpack;
if (!bought && cont != null)
{
if (cont.ConsumeTotal(typeof(Gold), totalCost))
{
bought = true;
}
}
if (!bought &&
(totalCost >= 2000 ||
AccountGold.Enabled)
)
{
if (Banker.Withdraw(buyer, totalCost))
{
bought = true;
fromBank = true;
}
else
{
cont = buyer.FindBankNoCreate();
if (cont != null && cont.ConsumeTotal(typeof(Gold), totalCost))
{
bought = true;
fromBank = true;
}
}
}
if (!bought)
{
// ? Begging thy pardon, but thy bank account lacks these funds.
// : Begging thy pardon, but thou casnt afford that.
SayTo(buyer, totalCost >= 2000 ? 500191 : 500192);
return false;
}
buyer.PlaySound(0x32);
cont = buyer.Backpack ?? buyer.BankBox;
foreach (BuyItemResponse buy in validBuy)
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if (amount < 1)
{
continue;
}
if (ser.IsItem)
{
Item item = World.FindItem(ser);
if (item == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(item);
if (gbi != null)
{
ProcessValidPurchase(amount, gbi, buyer, cont);
}
else
{
if (amount > item.Amount)
{
amount = item.Amount;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(item))
{
if (ssi.IsResellable(item))
{
Item buyItem;
if (amount >= item.Amount)
{
buyItem = item;
}
else
{
buyItem = LiftItemDupe(item, item.Amount - amount);
if (buyItem == null)
{
buyItem = item;
}
}
if( WeightOverloading.IsOverloaded(buyer) )
{
buyer.BankBox.DropItem( buyItem );
}
// if (cont == null || !cont.TryDropItem(buyer, buyItem, false))
// {
// buyItem.MoveToWorld(buyer.Location, buyer.Map);
// }
break;
}
}
}
}
}
else if (ser.IsMobile)
{
Mobile mob = World.FindMobile(ser);
if (mob == null)
{
continue;
}
GenericBuyInfo gbi = LookupDisplayObject(mob);
if (gbi != null)
{
ProcessValidPurchase(amount, gbi, buyer, cont);
}
}
} //foreach
if (fullPurchase)
{
if (buyer.AccessLevel >= AccessLevel.GameMaster)
{
SayTo(buyer, true, "I would not presume to charge thee anything. Here are the goods you requested.");
}
else if (fromBank)
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage.",
totalCost);
}
else
{
SayTo(buyer, true, "The total of thy purchase is {0} gold. My thanks for the patronage.", totalCost);
}
}
else
{
if (buyer.AccessLevel >= AccessLevel.GameMaster)
{
SayTo(
buyer,
true,
"I would not presume to charge thee anything. Unfortunately, I could not sell you all the goods you requested.");
}
else if (fromBank)
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold, which has been withdrawn from your bank account. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.",
totalCost);
}
else
{
SayTo(
buyer,
true,
"The total of thy purchase is {0} gold. My thanks for the patronage. Unfortunately, I could not sell you all the goods you requested.",
totalCost);
}
}
return true;
}
Find:
Code:
publicvirtualbool OnSellItems(Mobile seller, List<SellItemResponse> list)
REPLACE:
Code:
public virtual bool OnSellItems(Mobile seller, List<SellItemResponse> list)
{
if (!IsActiveBuyer)
{
return false;
}
if (!seller.CheckAlive())
{
return false;
}
if (!CheckVendorAccess(seller))
{
Say(501522); // I shall not treat with scum like thee!
return false;
}
seller.PlaySound(0x32);
var info = GetSellInfo();
var buyInfo = GetBuyInfo();
int GiveGold = 0;
int Sold = 0;
Container cont;
foreach (SellItemResponse resp in list)
{
if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable ||
(resp.Item is Container && (resp.Item).Items.Count != 0))
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(resp.Item))
{
Sold++;
break;
}
}
}
if (Sold > MaxSell)
{
SayTo(seller, true, "You may only sell {0} items at a time!", MaxSell);
return false;
}
else if (Sold == 0)
{
return true;
}
foreach (SellItemResponse resp in list)
{
if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || !resp.Item.Movable ||
(resp.Item is Container && (resp.Item).Items.Count != 0))
{
continue;
}
foreach (IShopSellInfo ssi in info)
{
if (ssi.IsSellable(resp.Item))
{
int amount = resp.Amount;
if (amount > resp.Item.Amount)
{
amount = resp.Item.Amount;
}
if (ssi.IsResellable(resp.Item))
{
bool found = false;
foreach (IBuyItemInfo bii in buyInfo)
{
if (bii.Restock(resp.Item, amount))
{
resp.Item.Consume(amount);
found = true;
break;
}
}
if (!found)
{
cont = BuyPack;
if (amount < resp.Item.Amount)
{
Item item = LiftItemDupe(resp.Item, resp.Item.Amount - amount);
if (item != null)
{
item.SetLastMoved();
cont.DropItem(item);
}
else
{
resp.Item.SetLastMoved();
cont.DropItem(resp.Item);
}
}
else
{
resp.Item.SetLastMoved();
cont.DropItem(resp.Item);
}
}
}
else
{
if (amount < resp.Item.Amount)
{
resp.Item.Amount -= amount;
}
else
{
resp.Item.Delete();
}
}
GiveGold += ssi.GetSellPriceFor(resp.Item) * amount;
break;
}
}
}
if (GiveGold > 0)
{
while (GiveGold > 60000)
{
if( WeightOverloading.IsOverloaded(seller) )
{
seller.BankBox.DropItem(new Gold(60000));
}
seller.AddToBackpack(new Gold(60000));
GiveGold -= 60000;
}
//seller.AddToBackpack(new Gold(GiveGold));
if( WeightOverloading.IsOverloaded(seller) )
{
seller.BankBox.DropItem(new Gold(GiveGold));
}
else
{
seller.AddToBackpack(new Gold(GiveGold));
}
seller.PlaySound(0x0037); //Gold dropping sound
if (SupportsBulkOrders(seller))
{
Item bulkOrder = CreateBulkOrder(seller, false);
if (bulkOrder is LargeBOD)
{
seller.SendGump(new LargeBODAcceptGump(seller, (LargeBOD)bulkOrder));
}
else if (bulkOrder is SmallBOD)
{
seller.SendGump(new SmallBODAcceptGump(seller, (SmallBOD)bulkOrder));
}
}
}
//no cliloc for this?
//SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold );
return true;
}