public static bool ContainsKey( Container cont, uint keyValue ) { if ( cont == null ) return false; Item[] items = cont.FindItemsByType( new Type[] { typeof( Key ), typeof( KeyRing ) } ); foreach ( Item item in items ) { if ( item is Key ) { Key key = (Key) item; if ( key.KeyValue == keyValue ) return true; } else { KeyRing keyRing = (KeyRing) item; if ( keyRing.ContainsKey( keyValue ) ) return true; } } return false; }
private bool ContainsDeed( Container cont ) { List<HouseRaffleDeed> deeds = cont.FindItemsByType<HouseRaffleDeed>(); for ( int i = 0; i < deeds.Count; ++i ) { if ( deeds[i] == m_Stone.Deed ) return true; } return false; }
public static void RemoveKeys( Container cont, uint keyValue ) { if ( cont == null || keyValue == 0 ) return; Item[] items = cont.FindItemsByType( new Type[] { typeof( Key ), typeof( KeyRing ) } ); foreach ( Item item in items ) { if ( item is Key ) { Key key = (Key) item; if ( key.KeyValue == keyValue ) key.Delete(); } else { KeyRing keyRing = (KeyRing) item; keyRing.RemoveKeys( keyValue ); } } }
public static int GETAMOUNTINCONTAINER(TriggerObject trigObject, Container container, object typeObjectOrString) { if (container == null || container.Deleted) { return 0; } Type type = TYPE(trigObject, typeObjectOrString); if (type == null) { throw new UberScriptException( "GETAMOUNTINCONTAINER typeString " + typeObjectOrString + " did not match any available types!"); } return container.FindItemsByType(type).Sum(t => t.Amount); }
private Item SelectBestPick(Mobile from, Container pack) { RunescapePickaxe item = null; Item[] picks = pack.FindItemsByType(typeof(RunescapePickaxe)); foreach (Item pickitem in picks) { if (pickitem is RunescapePickaxe) { RunescapePickaxe pick = (RunescapePickaxe) pickitem; if ((item != null && pick.WeaponType > item.WeaponType) || (item == null)) { if (Utilities.CanUse(from, pick)) item = pick; } } } return item; }
public int GetQuantity( Container cont, Type[] types ) { Item[] items = cont.FindItemsByType( types, true ); int amount = 0; for ( int i = 0; i < items.Length; ++i ) { IHasQuantity hq = items[i] as IHasQuantity; if ( hq == null ) { amount += items[i].Amount; } else { if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water ) continue; amount += hq.Quantity; } } return amount; }
public static List<SoftenedReeds> GetReeds( Container cont, PlantHue hue ) { return GetReeds( cont.FindItemsByType<SoftenedReeds>(), hue ); }
/// <summary> /// Tries to consume the given amount out of the total amount of currency in the provided container. /// Automatically redistributes coins. /// </summary> /// <param name="cont">the container to consume from</param> /// <param name="currencyType">the target currency to consume from</param> /// <param name="amount">the amount of the target currency to consume</param> /// <returns>true if the container has the exact amount of the currencyType, or if the container has enough total monies</returns> public static bool Consume( Container cont, Type currencyType, int amount ) { if( cont == null ) return false; if( cont.ConsumeTotal(currencyType, amount) ) return true; int availableCopper = 0; Item[] coins = cont.FindItemsByType(AllCurrencies); //calculate monies as copper total for( int i = 0; i < coins.Length; i++ ) availableCopper += ConvertTo(FindType(coins[i].GetType()), CurrencyType.Copper, coins[i].Amount); //if we have enough to pay... if( availableCopper >= amount ) { //delete all the coins for( int i = 0; i < coins.Length; i++ ) coins[i].Consume(coins[i].Amount); availableCopper -= amount; //if we should still have money, redistribute if( availableCopper > 0 ) DistributeCoins(cont, Compress(availableCopper, 0, 0)); return true; } return false; }
public override bool OnDeath( Mobile mob, Container corpse ) { Mobile killer = mob.FindMostRecentDamager( false ); bool hadFlag = false; Item[] flags = corpse.FindItemsByType( typeof( CTFFlag ), false ); for ( int i = 0; i < flags.Length; ++i ) ( flags[i] as CTFFlag ).DropTo( mob, killer ); hadFlag = ( hadFlag || flags.Length > 0 ); if ( mob.Backpack != null ) { flags = mob.Backpack.FindItemsByType( typeof( CTFFlag ), false ); for ( int i = 0; i < flags.Length; ++i ) ( flags[i] as CTFFlag ).DropTo( mob, killer ); hadFlag = ( hadFlag || flags.Length > 0 ); } if ( killer != null && killer.Player ) { CTFTeamInfo teamInfo = GetTeamInfo( killer ); CTFTeamInfo victInfo = GetTeamInfo( mob ); if ( teamInfo != null && teamInfo != victInfo ) { CTFPlayerInfo playerInfo = teamInfo[killer]; if ( playerInfo != null ) { playerInfo.Kills += 1; playerInfo.Score += 1; // base frag if ( hadFlag ) playerInfo.Score += 4; // fragged flag carrier if ( mob.InRange( teamInfo.Origin, 24 ) && mob.Map == this.Facet ) playerInfo.Score += 1; // fragged in base -- guarding for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i ) { if ( m_Controller.TeamInfo[i] == teamInfo ) continue; Mobile ourFlagCarrier = null; if ( m_Controller.TeamInfo[i].Flag != null ) ourFlagCarrier = m_Controller.TeamInfo[i].Flag.RootParent as Mobile; if ( ourFlagCarrier != null && GetTeamInfo( ourFlagCarrier ) == teamInfo ) { for ( int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j ) { AggressorInfo aggr = ourFlagCarrier.Aggressors[j]; if ( aggr == null || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob ) continue; playerInfo.Score += 2; // helped defend guy capturing enemy flag break; } if ( mob.Map == ourFlagCarrier.Map && ourFlagCarrier.InRange( mob, 12 ) ) playerInfo.Score += 1; // helped defend guy capturing enemy flag } } } } } mob.CloseGump( typeof( CTFBoardGump ) ); mob.SendGump( new CTFBoardGump( mob, this ) ); m_Context.Requip( mob, corpse ); DelayBounce( TimeSpan.FromSeconds( 30.0 ), mob, corpse ); return false; }
public int GetCommodityType(Container c, Type type) { if (c == null) return 0; Item[] items = c.FindItemsByType(typeof(CommodityDeed)); int amt = 0; foreach (Item item in items) { if (item is CommodityDeed && ((CommodityDeed)item).Commodity != null && ((CommodityDeed)item).Commodity.GetType() == type) amt += ((CommodityDeed)item).Commodity.Amount; } return amt; }
private void TakeItems(Container c, Type type, ref int amount) { if (c == null) return; Item[] items = c.FindItemsByType(type); List<Item> toSell = new List<Item>(); foreach(Item item in items) { if(amount <= 0) break; if(item.Amount <= amount) { toSell.Add(item); amount -= item.Amount; } else { Item newItem = Loot.Construct(type); newItem.Amount = amount; item.Amount -= amount; toSell.Add(newItem); amount = 0; } } foreach(Item item in toSell) { AddInventory(null, item); } }
private void TakeCommodities(Container c, Type type, ref int amount) { if (c == null) return; Item[] items = c.FindItemsByType(typeof(CommodityDeed)); List<Item> toSell = new List<Item>(); foreach(Item item in items) { CommodityDeed commodityDeed = item as CommodityDeed; if (commodityDeed != null && commodityDeed.Commodity != null && commodityDeed.Commodity.GetType() == type) { Item commodity = commodityDeed.Commodity; if (commodity.Amount <= amount) { toSell.Add(item); amount -= commodity.Amount; } else { CommodityDeed newDeed = new CommodityDeed(); Item newItem = Loot.Construct(type); newItem.Amount = amount; newDeed.SetCommodity(newItem); commodity.Amount -= amount; commodityDeed.InvalidateProperties(); toSell.Add(newDeed); amount = 0; } } } foreach(Item item in toSell) { AddInventory(null, item); } }
public static void TransferGold(Mobile m, Container c, GoldLedger ledger, string nametitle) { Item[] items = c.FindItemsByType(typeof(Gold)); foreach (Gold ngold in items) { Gold gold = ngold as Gold; if (gold != null) { if (ledger.Gold < 999999999) { double maxWeight = (WeightOverloading.GetMaxWeight(m)); if ((Mobile.BodyWeight + m.TotalWeight) < (maxWeight)) { int golda = gold.Amount; if ((gold.Amount + ledger.Gold) > 999999999) golda = (999999999 - ledger.Gold); double maxgold = golda; if (ledger.d_WeightScale > 0) maxgold = ((maxWeight - ((double)Mobile.BodyWeight + (double)m.TotalWeight)) / ledger.d_WeightScale); if (golda > maxgold) golda = (int)maxgold; int GoldID = 0; if (golda == 1) GoldID = gold.ItemID; else if (golda > 1 && golda < 6) GoldID = gold.ItemID + 1; else if (golda >= 6) GoldID = gold.ItemID + 2; if (golda < gold.Amount) gold.Amount -= golda; else gold.Delete(); ledger.Gold += golda; if (ledger.b_open && golda > 0) { m.CloseGump(typeof(GoldLedgerGump)); m.SendGump(new GoldLedgerGump(ledger)); } if (golda > 0) { m.SendMessage(2125, "You loot {0} gold from {1} and deposit it into your gold ledger.", golda.ToString("#,0"), nametitle); Effects.SendMovingEffect(c, m, GoldID, 5, 50, true, false); m.PlaySound(0x2E6); } } } } } }
private static int GetGoldInContainer(Container c) { int iGold = 0; Item[] golds = c.FindItemsByType(typeof(Gold), true); foreach(Item g in golds) { iGold += g.Amount; } Item[] checks = c.FindItemsByType(typeof(BankCheck), true); foreach(Item i in checks) { BankCheck bc = (BankCheck)i; iGold += bc.Worth; } return iGold; }
private static int GetHouseDeedsInContainer(Container c, ref int count) { int iGold = 0; Item[] deeds = c.FindItemsByType(typeof(Server.Multis.Deeds.HouseDeed), true); foreach (Item i in deeds) { Server.Multis.Deeds.HouseDeed housedeed = i as Server.Multis.Deeds.HouseDeed; // don't count tents as they cannot be redeemed for cash if (housedeed != null && housedeed is SiegeTentBag == false && housedeed is TentBag == false) { count++; iGold += RealEstateBroker.ComputePriceFor(housedeed); } } Item[] BUCdeeds = c.FindItemsByType(typeof(BaseUpgradeContract), true); foreach (Item i in BUCdeeds) { BaseUpgradeContract budeed = i as BaseUpgradeContract; if (budeed != null) { count++; iGold += (int)budeed.Price; } } return iGold; }
public static void DELETEFROMCONTAINER( TriggerObject trigObject, Container container, object typeObjectOrString, int amount) { Type type = TYPE(trigObject, typeObjectOrString); if (type == null) { throw new UberScriptException( "DELETEFROMCONTAINER typeObjectOrString " + typeObjectOrString + " did not match any available types!"); } var list = container.FindItemsByType(type); for (int i = 0; amount > 0 && i < list.Length; i++) { int consume = Math.Min(list[i].Amount, amount); list[i].Consume(consume); amount -= consume; } }
private void BuildGump() { /*FIND GOLD*/ balance = 0; Item[] gold; bank = ((Mobile)m_Victum).FindBankNoCreate(); if (bank != null) { gold = bank.FindItemsByType(typeof(Gold)); for (int i = 0; i < gold.Length; ++i) balance += gold[i].Amount; } this.Closable = false; this.Disposable = false; this.Dragable = false; this.Resizable = false; AddPage(0); AddImage(200, 150, 1140); AddButton(408, 340, 1144, 1145, 2, GumpButtonType.Reply, 0); AddButton(317, 341, 1147, 1148, 1, GumpButtonType.Reply, 0); AddHtml(267, 196, 254, 37, String.Format("Would you like to report {0} as a murderer?", ((Mobile)m_Killers[m_Idx]).Name), (bool)false, (bool)false); /*if (m_Killers[m_Idx].Kills >= 5) {*/ AddImage(260, 282, 1143); AddHtml(266, 258, 256, 21, String.Format("Optional bounty ({0}gp max)", balance), (bool)false, (bool)false); AddTextEntry(274, 285, 242, 16, 0, 0, "0", 25); //} }
//this performs a consume operation on a list of source items. Since resources can be distributed among different items, //this handles a distributed search and take operation public static bool Consume( Container pack, Type[] types, int[] amounts ) { //check if there are any BaseStoreKey or MasterItemStoreKey objects in the caster's backpack Item[] keysources = pack.FindItemsByType( new Type[]{ typeof( BaseStoreKey ), typeof( MasterItemStoreKey ) } ); if( keysources == null || types == null || amounts == null ) { return false; } //a list of any items that are found in the backpack after they were not found in the keys List<Type> backpacksources = new List<Type>(); //the corresponding amounts to be withdrawn from the items found in the backpack List<int> backpackwithdrawamounts = new List<int>(); //boolean array flag used to indicate which types have been found while in the middle of scanning all sources bool[] foundentries = new bool[ types.Length ]; List<StoreEntry> consumeentries = new List<StoreEntry>(); //go thru the list of found objects foreach( Item key in keysources ) { //utilizes IItemStoreObject interface function, defined by keys if( key is IItemStoreObject ) { //scan this object for any usable candidates to withdraw from consumeentries.AddRange( ((IItemStoreObject)key).FindConsumableEntries( types, amounts, ref foundentries ) ); //check if we're done if( consumeentries.Count == types.Length ) { break; } } } //check if the operation was complete. If not, look for any more in the backpack if( consumeentries.Count < types.Length ) { for( int i = 0; i < types.Length; i++ ) { //if this isn't found yet if( !foundentries[i] ) { //find any item, and check if there's enough to consume Item[] items = pack.FindItemsByType( types[i] ); int total = 0; for ( int j = 0; j < items.Length; j++ ) { total += items[j].Amount; } //make sure the total found is sufficient if ( total >= amounts[i] ) { //add this source to the list to be extracted from the backpack backpacksources.Add( types[i] ); backpackwithdrawamounts.Add( amounts[i] ); foundentries[i] = true; } } } //second pass, check if scanning the backpack has given us enough now if( consumeentries.Count + backpacksources.Count < types.Length ) { return false; } } //if we found everything we need, then consume them //perform the consumption from backpack foreach( StoreEntry entry in consumeentries ) { entry.Consume(); entry.RefreshParentGump(); } //perform the consumption from backpack (if it was necessary) for( int i = 0; i < backpacksources.Count; i++ ) { pack.ConsumeTotal( backpacksources[i], backpackwithdrawamounts[i] ); } return true; }//static consume
public static bool ConsumeTotal(Container pack, Type itemType, BeverageType content, int quantity) { Item[] items = pack.FindItemsByType(itemType); // First pass, compute total int total = items.OfType<BaseBeverage>() .Where(bev => bev.Content == content && !bev.IsEmpty) .Sum(bev => bev.Quantity); if (total >= quantity) { // We've enough, so consume it int need = quantity; foreach (BaseBeverage bev in items.OfType<BaseBeverage>()) { if (bev.Content != content || bev.IsEmpty) { continue; } int theirQuantity = bev.Quantity; if (theirQuantity < need) { bev.Quantity = 0; need -= theirQuantity; } else { bev.Quantity -= need; return true; } } } return false; }
public static bool CraftWithdraw( Container pack, Type[] types, int amount, bool getamountonly ) { //check if there are any BaseStoreKey or MasterItemStoreKey objects in the caster's backpack Item[] keysources = pack.FindItemsByType( new Type[]{ typeof( BaseStoreKey ), typeof( MasterItemStoreKey ) } ); if( keysources == null || types == null || amount == 0 ) { return false; } //go thru the list of found objects foreach( Item key in keysources ) { //utilizes IItemStoreObject interface function, defined by keys if( key is IItemStoreObject ) { //scan this object for any usable candidates to withdraw from StoreEntry entry = ((IItemStoreObject)key).FindConsumableEntry( types, amount ); if( entry != null ) { if( getamountonly ) { _LastAmountCount = entry.Amount; } else if( entry.Amount < amount ) { //don't do anything if there's not enough to work from return false; } else { //if a valid entry was found, withdraw it to the container Console.WriteLine( "trying to withdraw " + amount.ToString() ); //doesn't work properly with unstackable items //store the amount that needs to be withdrawn, and reset the amount that has been withdrawn int amounttowithdraw = amount; int amountwithdrawn = 0; //keep withdrawing until the desired amount has been taken out while( amountwithdrawn < amounttowithdraw ) { amount = amounttowithdraw - amountwithdrawn; _LastWithdrawn = entry.Withdraw( ref amount ); amountwithdrawn += amount; //if for some reason none was taken out, then exit if( amount == 0 ) { return false; } pack.AddItem( _LastWithdrawn ); } entry.RefreshParentGump(); } return true; } } } //if nothing was found, return false return false; }//static CraftWithdraw
private void PackItemsMovable(Container pack, bool canmove) { if (pack == null) return; Item[] itemlist = pack.FindItemsByType(typeof(Item), true); if (itemlist != null) { for (int i = 0; i < itemlist.Length; i++) { itemlist[i].Movable = canmove; } } }
//this is used to withdraw based on a particular store entry, and specified parameters public static Item WithdrawByEntryType( Container pack, Type entrytype, int amount, object[] parameters ) { //check if there are any BaseStoreKey or MasterItemStoreKey objects in the caster's backpack Item[] keysources = pack.FindItemsByType( new Type[]{ typeof( BaseStoreKey ), typeof( MasterItemStoreKey ) } ); if( keysources == null || amount == 0 ) { return null; } //go thru the list of found objects foreach( Item key in keysources ) { //utilizes IItemStoreObject interface function, defined by keys if( key is IItemStoreObject ) { //scan this object for any usable candidates to withdraw from StoreEntry entry = ((IItemStoreObject)key).FindEntryByEntryType( entrytype, amount, parameters ); if( entry != null ) { Item item = entry.Withdraw( ref amount, true ); entry.RefreshParentGump(); pack.AddItem( _LastWithdrawn ); return item; } } } return null; }
public static bool ConsumeTotal( Container pack, Type itemType, BeverageType content, int quantity ) { Item[] items = pack.FindItemsByType( itemType ); // First pass, compute total int total = 0; for ( int i = 0; i < items.Length; ++i ) { BaseBeverage bev = items[i] as BaseBeverage; if ( bev != null && bev.Content == content && !bev.IsEmpty ) total += bev.Quantity; } if ( total >= quantity ) { // We've enough, so consume it int need = quantity; for ( int i = 0; i < items.Length; ++i ) { BaseBeverage bev = items[i] as BaseBeverage; if ( bev == null || bev.Content != content || bev.IsEmpty ) continue; int theirQuantity = bev.Quantity; if ( theirQuantity < need ) { bev.Quantity = 0; need -= theirQuantity; } else { bev.Quantity -= need; return true; } } } return false; }
public int ConsumeQuantityByPlantHue(Mobile from, CraftSystem craftSystem, Container cont, Type[][] types, int[] amounts) { if (types.Length != amounts.Length) throw new ArgumentException(); CraftContext context = craftSystem.GetContext(from); if (context == null) return 0; Item[][] items = new Item[types.Length][]; int[] totals = new int[types.Length]; for (int i = 0; i < types.Length; ++i) { items[i] = cont.FindItemsByType(types[i], true); for (int j = 0; j < items[i].Length; ++j) { IPlantHue plantHue = items[i][j] as IPlantHue; IPigmentHue pigmentHue = items[i][j] as IPigmentHue; if (plantHue != null && plantHue.PlantHue != context.RequiredPlantHue) continue; else if (pigmentHue != null && pigmentHue.PigmentHue != context.RequiredPigmentHue) continue; totals[i] += items[i][j].Amount; } if (totals[i] < amounts[i]) return i; } for (int i = 0; i < types.Length; ++i) { int need = amounts[i]; for (int j = 0; j < items[i].Length; ++j) { Item item = items[i][j]; IPlantHue ph = item as IPlantHue; IPigmentHue pigh = item as IPigmentHue; int theirAmount = item.Amount; if (ph != null && ph.PlantHue != context.RequiredPlantHue) continue; else if (pigh != null && pigh.PigmentHue != context.RequiredPigmentHue) continue; if (theirAmount < need) { OnResourceConsumed(item, theirAmount); item.Delete(); need -= theirAmount; } else { OnResourceConsumed(item, need); item.Consume(need); break; } } } return -1; }
public int ConsumeQuantity( Container cont, Type[][] types, int[] amounts ) { if ( types.Length != amounts.Length ) throw new ArgumentException(); Item[][] items = new Item[types.Length][]; int[] totals = new int[types.Length]; for ( int i = 0; i < types.Length; ++i ) { items[i] = cont.FindItemsByType( types[i], true ); for ( int j = 0; j < items[i].Length; ++j ) { IHasQuantity hq = items[i][j] as IHasQuantity; if ( hq == null ) { totals[i] += items[i][j].Amount; } else { if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water ) continue; totals[i] += hq.Quantity; } } if ( totals[i] < amounts[i] ) return i; } for ( int i = 0; i < types.Length; ++i ) { int need = amounts[i]; for ( int j = 0; j < items[i].Length; ++j ) { Item item = items[i][j]; IHasQuantity hq = item as IHasQuantity; if ( hq == null ) { int theirAmount = item.Amount; if ( theirAmount < need ) { item.Delete(); need -= theirAmount; } else { item.Consume( need ); break; } } else { if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water ) continue; int theirAmount = hq.Quantity; if ( theirAmount < need ) { hq.Quantity -= theirAmount; need -= theirAmount; } else { hq.Quantity -= need; break; } } } } return -1; }
public int GetPlantHueAmount(Mobile from, CraftSystem craftSystem, Container cont, Type[] types) { Item[] items = cont.FindItemsByType(types, true); CraftContext context = craftSystem.GetContext(from); int amount = 0; for (int i = 0; i < items.Length; ++i) { IPlantHue ph = items[i] as IPlantHue; IPigmentHue pigh = items[i] as IPigmentHue; if (context == null || (ph != null && ph.PlantHue != context.RequiredPlantHue)) continue; else if (context == null || (pigh != null && pigh.PigmentHue != context.RequiredPigmentHue)) continue; amount += items[i].Amount; } return amount; }
public override bool OnDeath( Mobile mob, Container corpse ) { Mobile killer = mob.FindMostRecentDamager( false ); bool hadBomb = false; Item[] bombs = corpse.FindItemsByType( typeof( BRBomb ), false ); for ( int i = 0; i < bombs.Length; ++i ) ( bombs[i] as BRBomb ).DropTo( mob, killer ); hadBomb = ( hadBomb || bombs.Length > 0 ); if ( mob.Backpack != null ) { bombs = mob.Backpack.FindItemsByType( typeof( BRBomb ), false ); for ( int i = 0; i < bombs.Length; ++i ) ( bombs[i] as BRBomb ).DropTo( mob, killer ); hadBomb = ( hadBomb || bombs.Length > 0 ); } if ( killer != null && killer.Player ) { BRTeamInfo teamInfo = GetTeamInfo( killer ); BRTeamInfo victInfo = GetTeamInfo( mob ); if ( teamInfo != null && teamInfo != victInfo ) { BRPlayerInfo playerInfo = teamInfo[killer]; if ( playerInfo != null ) { playerInfo.Kills += 1; playerInfo.Score += 1; // base frag if ( hadBomb ) playerInfo.Score += 4; // fragged bomb carrier } } } mob.CloseGump( typeof( BRBoardGump ) ); mob.SendGump( new BRBoardGump( mob, this ) ); m_Context.Requip( mob, corpse ); DelayBounce( TimeSpan.FromSeconds( 30.0 ), mob, corpse ); return false; }
public void OnTarget(Mobile from, object targeted) { if (targeted is Item) { Item item = (Item)targeted; if (item.Parent is Mobile) { from.SendLocalizedMessage(1112350); // You cannot scour items that are being worn! } else if (item.IsLockedDown || item.IsSecure) { from.SendLocalizedMessage(1112351); // You may not scour items which are locked down. } else if (item.QuestItem) { from.SendLocalizedMessage(1151837); // You may not scour toggled quest items. } else if (item is DryReeds) { if (!(from is PlayerMobile) || !((PlayerMobile)from).BasketWeaving) { from.SendLocalizedMessage(1112253); //You haven't learned basket weaving. Perhaps studying a book would help! } else { DryReeds reed1 = (DryReeds)targeted; Container cont = from.Backpack; Engines.Plants.PlantHue hue = reed1.PlantHue; if (!reed1.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1116249); //That must be in your backpack for you to use it. } else if (cont != null) { Item[] items = cont.FindItemsByType(typeof(DryReeds)); List <Item> list = new List <Item>(); int total = 0; foreach (Item it in items) { if (it is DryReeds) { DryReeds check = (DryReeds)it; if (reed1.PlantHue == check.PlantHue) { total += it.Amount; list.Add(it); } } } int toConsume = 2; if (list.Count > 0 && total > 1) { foreach (Item it in list) { if (it.Amount >= toConsume) { it.Consume(toConsume); toConsume = 0; } else if (it.Amount < toConsume) { it.Delete(); toConsume -= it.Amount; } if (toConsume <= 0) { break; } } SoftenedReeds sReed = new SoftenedReeds(hue); if (!from.Backpack.TryDropItem(from, sReed, false)) { sReed.MoveToWorld(from.Location, from.Map); } m_UsesRemaining--; if (m_UsesRemaining <= 0) { Delete(); } else { InvalidateProperties(); } from.PlaySound(0x23E); } else { from.SendLocalizedMessage(1112250); //You don't have enough of this type of dry reeds to make that. } } } } else if (BasePigmentsOfTokuno.IsValidItem(item)) { from.PlaySound(0x23E); ((Item)targeted).Hue = 0; m_UsesRemaining--; if (m_UsesRemaining <= 0) { Delete(); } else { InvalidateProperties(); } } else { from.SendLocalizedMessage(1112349); // You cannot scour that! } } else { from.SendLocalizedMessage(1112349); // You cannot scour that! } }