public virtual bool OnFired(Mobile attacker, Mobile defender) { //--<<Advanced Archery Edit>>---------------------[Start 3/4] PlayerMobile a_pm = attacker as PlayerMobile; Container pack = attacker.Backpack; BaseQuiver quiver = attacker.FindItemOnLayer(Layer.MiddleTorso) as BaseQuiver; BaseRangedModule module = this.BaseRangedModule; if (!module.HasBowString) { if (DateTime.Now >= m_NextStringWarning) { m_NextStringWarning = DateTime.Now + StringWarningDelay; attacker.SendMessage("You need a string to use this bow. See a local fletcher to apply the string."); return(false); } else { return(false); } } if (Ammo == null) { if (DateTime.Now >= m_NextAmmoWarning) { m_NextAmmoWarning = DateTime.Now + AmmoWarningDelay; attacker.SendMessage("You are out of ammo."); return(false); } else { return(false); } } if (attacker.Player && quiver != null && quiver.LowerAmmoCost > Utility.Random(100)) { attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); } if (attacker.Player && (quiver == null || !quiver.ConsumeTotal(AmmoType, 1)) && (pack == null || !pack.ConsumeTotal(AmmoType, 1))) { return(false); } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); //--<<Advanced Archery Edit>>---------------------[End 3/4] }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; if (attacker.Player && (pack == null || !pack.ConsumeTotal(AmmoType, 1))) { return(false); } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 2)) { if (m_Held > 0) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Bottle), 1)) { from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle... BasePotion pot = FillBottle(); if (pack.TryDropItem(from, pot, false)) { from.SendLocalizedMessage(502243); // ...and place it into your backpack. from.PlaySound(0x240); if (--Held == 0) { from.SendLocalizedMessage(502245); // The keg is now empty. } else { Unknown = false; } } else { from.SendLocalizedMessage(502244); // ...but there is no room for the bottle in your backpack. pot.Delete(); } } else { from.Target = new BottleTarget(this); from.SendLocalizedMessage(502241); // Where is a container for your potion? } } else { from.SendLocalizedMessage(502246); // The keg is empty. } } else { from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; Container pack = attacker.Backpack; if (!EventItem || (EventItem && EventItemConsume)) { if (attacker.Player) { if (quiver == null || quiver.LowerAmmoCost == 0 || quiver.LowerAmmoCost > Utility.Random(100)) { if (quiver != null && quiver.ConsumeTotal(AmmoType, 1)) { quiver.InvalidateWeight(); } else if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { return(false); } } } } if (attacker.Mounted) { if (DefAnimation == WeaponAnimation.ShootBow) { attacker.Animate(27, 5, 1, true, false, 0); } else if (DefAnimation == WeaponAnimation.ShootXBow) { attacker.Animate(28, 5, 1, true, false, 0); } } else { if (DefAnimation == WeaponAnimation.ShootBow) { attacker.Animate(18, 5, 1, true, false, 0); } else if (DefAnimation == WeaponAnimation.ShootXBow) { attacker.Animate(19, 5, 1, true, false, 0); } } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 2)) { if (m_Held > 0) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Bottle), 1)) { from.SendAsciiMessage("You pour some of the keg's contents into an empty bottle..."); BasePotion pot = FillBottle(); if ((m_Tasters != null && m_Tasters.Contains(from)) || from == m_Owner) { pot.AddTasters(from); } if (pack.TryDropItem(from, pot, false)) { from.SendAsciiMessage("...and place it into your backpack."); from.PlaySound(0x240); if (--Held == 0) { from.SendAsciiMessage("The keg is now empty."); } } else { from.SendAsciiMessage("...but there is no room for the bottle in your backpack."); pot.Delete(); } } else { // TODO: Target a bottle } } else { from.SendAsciiMessage("The keg is empty."); } } else { from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(PhillieBlunt), 1)) { from.SendMessage("You break open the blunt and are left with the exterior."); from.AddToBackpack(new PhillieBluntWrapper()); } else { from.SendMessage("Your out of blunts bro!"); return; } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Marijuana), 3)) { from.SendMessage("You roll up some pot into a fatty."); from.AddToBackpack(new Joint()); } else { from.SendMessage("Your need more pot bro!"); return; } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 101: { // spin Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Gold), 500)) { from.SendGump(new SlotMachineGump(from, m_From, 1)); } else { from.SendGump(new SlotMachineGump(from, m_From, 2)); } break; } case 102: { // help from.CloseGump(typeof(HelpStatsGump)); from.SendGump(new HelpStatsGump(m_From)); from.SendGump(new SlotMachineGump(from, m_From, 0)); break; } case 103: { // stats from.CloseGump(typeof(SlotsStatsGump)); from.SendGump(new SlotsStatsGump(m_From)); from.SendGump(new SlotMachineGump(from, m_From, 0)); break; } case 666: { // quit break; } } } // OnResponse
public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 2)) { if (m_Held > 0) { Container pack = from.Backpack; if (pack != null && ((IsJarPotion(m_Type) && pack.ConsumeTotal(typeof(Jar), 1)) || (!IsJarPotion(m_Type) && pack.ConsumeTotal(typeof(Bottle), 1)))) { from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle... BasePotion pot = FillBottle(); if (pack.TryDropItem(from, pot, false)) { BaseContainer.DropItemFix(pot, from, from.Backpack.ItemID, from.Backpack.GumpID); from.SendLocalizedMessage(502243); // ...and place it into your backpack. from.PlaySound(0x240); if (--Held == 0) { from.SendLocalizedMessage(502245); // The keg is now empty. } } else { from.SendLocalizedMessage(502244); // ...but there is no room for the bottle in your backpack. pot.Delete(); } } else { // TODO: Target a bottle } } else { from.SendLocalizedMessage(502246); // The keg is empty. } SetColorKeg(this, this); } else { from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } }
public void LevelThree(AddonComponent c, Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(ShameCrystal), 45)) { Mobile WindElementalGuardian = new WindElementalGuardian(this); WindElementalGuardian.MoveToWorld(new Point3D(5620, 231, 0), Map); from.SendMessage("You have summoned the Wind Elemental Guardian. You have one hour to find and defeat the Guardian."); Active = false; HueShift(); } else { from.SendMessage("You need 45 crystal fragments to summon the Guardian."); //you are not yet worthy } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; if (Attributes.LowerAmmoCost < Utility.RandomMinMax(1, 100) && attacker.IsPlayer) { m_IsFalseArrow = false; bool success = false; Item cloak = attacker.FindItemOnLayer(Layer.Cloak); if (cloak is BaseQuiver) { BaseQuiver quiver = cloak as BaseQuiver; if (quiver.ConsumeTotal(AmmoType, 1)) { success = true; quiver.InvalidateProperties(); } } if (!success) { if (pack != null && pack.ConsumeTotal(AmmoType, 1)) { success = true; } } if (!success) { return(false); } } else { m_IsFalseArrow = true; } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(BoxOfPhillies), 1)) { from.SendMessage("You take the blunts out of the box."); for (int i = 0; i < 5; ++i) { from.AddToBackpack(new PhillieBlunt()); } } else { from.SendMessage("You need more blunts!"); return; } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Gold), 3200)) { BagOfNecroReagents necBag = new BagOfNecroReagents(40); if (!from.AddToBackpack(necBag)) { necBag.Delete(); } } else { from.SendMessage(0XAD, "You need at least 3200gp in your backpack to use this."); } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Gold), 5000)) { Shrinkbag sbag = new Shrinkbag(1); if (!from.AddToBackpack(sbag)) { sbag.Delete(); } } else { from.SendMessage(0XAD, "You need at least 5000gp in your backpack to use this."); } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; Container bank = from.BankBox; if (bank != null || pack != null) { if (ChargeForBolts) { if (pack.ConsumeTotal(typeof(Gold), PriceForBolts)) { PackBag(from, AmountOfBolts); from.SendMessage("{0} gold has been removed from your backpack.", PriceForBolts); } else if (bank.ConsumeTotal(typeof(Gold), PriceForBolts)) { PackBag(from, AmountOfBolts); from.SendMessage("{0} gold has been removed from your bankbox.", PriceForBolts); } else { from.SendMessage("You do not have enough funds for that."); } } else { PackBag(from, AmountOfBolts); from.SendMessage("500 Bolts have been placed into your backpack."); } } else { if (bank == null) { from.SendMessage("You do not have a bankbox. Please contact a staff member immediately and report this issue."); } if (pack == null) { from.SendMessage("You do not have a backpack. Please contact a staff member aimmediately and report this issue."); } } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(CrystalMeth), 1)) { if (from.Body.IsHuman && !from.Mounted) { from.Animate(34, 5, 1, true, false, 0); } from.SendMessage("You snort the drug."); from.SendMessage("You feel extremely confident and strong."); //if ( m_Poison != null ) { from.SendMessage("*GaG* *GaG*"); from.Say("*GaG*"); } } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Gold), 250)) { m_GamblePot += 150; InvalidateProperties(); int roll = Utility.Random(1200); if (roll == 0) // Jackpot { from.SendMessage(0x35, "You win the {0}gp jackpot!", m_GamblePot); from.AddToBackpack(new BankCheck(m_GamblePot)); m_GamblePot = 2500; } else if (roll <= 20) // Chance for a regbag { from.SendMessage(0x35, "You win a bag of reagents!"); from.AddToBackpack(new BagOfReagents(50)); } else if (roll <= 40) // Chance for gold { from.SendMessage(0x35, "You win 1500gp!"); from.AddToBackpack(new BankCheck(1500)); } else if (roll <= 100) // Another chance for gold { from.SendMessage(0x35, "You win 1000gp!"); from.AddToBackpack(new BankCheck(1000)); } else // Loser! { from.SendMessage(0x22, "You lose!"); } } else { from.SendMessage(0x22, "You need at least 250gp in your backpack to use this."); } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Shroom), 1)) { if (from.Body.IsHuman && !from.Mounted) { from.Animate(34, 5, 1, true, false, 0); from.PlaySound(Utility.Random(0x3A, 3)); // random eating noise from.SendMessage("You break off the stem and eat the funky colored cap."); from.SendMessage("You feel yourself beginning to trip mildly!"); } else { from.SendMessage("Your out of shrooms bro!"); return; } } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; #region Mondain's Legacy BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; if (attacker.Player && (quiver == null || !quiver.ConsumeAmmo(AmmoType))) { if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { return(false); } } #endregion attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Crack), 1)) { if (from.Body.IsHuman && !from.Mounted) { from.Animate(34, 5, 1, true, false, 0); } from.SendMessage("You snort the drug."); from.SendMessage("You feel extremely paronoid. You start to shake."); from.SendMessage("*Sniff* *Sniff*"); from.Animate(34, 5, 1, true, false, 0); from.Animate(34, 5, 1, true, false, 0); from.Animate(34, 5, 1, true, false, 0); from.Say("*Sniff* *Sniff*"); from.Say("IT BURNS!!!"); } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; Quiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as Quiver; if (quiver != null && quiver.ConsumeTotal(AmmoType, 1)) { quiver.UpdateTotals(); quiver.InvalidateProperties(); attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); } else if (pack != null && pack.ConsumeTotal(AmmoType, 1)) { attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); } return(false); }
public virtual bool OnFired(Mobile attacker, IDamageable damageable) { WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker); // Respect special moves that use no ammo if (ability != null && ability.ConsumeAmmo == false) { return(true); } if (attacker.Player) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; Container pack = attacker.Backpack; int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost); if (quiver == null || Utility.Random(100) >= lowerAmmo) { // consume ammo if (quiver != null && quiver.ConsumeTotal(AmmoType, 1)) { quiver.InvalidateWeight(); } else if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { return(false); } } else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null)) { // lower ammo cost should not work when we have no ammo at all return(false); } } attacker.MovingEffect(damageable, EffectID, 18, 1, false, false); return(true); }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; if (attacker.Player) { if (!ArenaFight.AllowFreeConsume(attacker, typeof(Arrow))) { if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { attacker.StealthAttackActive = false; attacker.StealthAttackReady = false; return(false); } } } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(MKScroll), 1)) { Map map = from.Map; BaseCreature minotaur = new MinotaurKing(); Point3D loc = from.Location; bool validLocation = false; for (int j = 0; !validLocation && j < 10; ++j) { int x = from.X + Utility.Random(3) - 1; int y = from.Y + Utility.Random(3) - 1; int z = map.GetAverageZ(x, y); if (validLocation = map.CanFit(x, y, this.Z, 16, false, false)) { loc = new Point3D(x, y, Z); } else if (validLocation = map.CanFit(x, y, z, 16, false, false)) { loc = new Point3D(x, y, z); } } minotaur.MoveToWorld(loc, map); minotaur.Combatant = from; } else { from.SendMessage(0x22, "You need a Minotaur King scroll to use that."); /////////////////////////// } }
public override void OnDoubleClick(Mobile from) { if (m_Held > 0) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Bottle), 1)) { from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle... BasePotion pot = FillBottle(); if (pack.TryDropItem(from, pot, false)) { from.SendLocalizedMessage(502243); // ...and place it into your backpack. from.PlaySound(0x240); if (--Held == 0) { from.SendLocalizedMessage(502245); // The keg is now empty. } } else { from.SendLocalizedMessage(502244); // ...but there is no room for the bottle in your backpack. pot.Delete(); } } else { // TODO: Target a bottle } } else { from.SendLocalizedMessage(502246); // The keg is empty. } }
public override void OnDoubleClick(Mobile from) { Container pack = from.Backpack; if (pack != null && pack.ConsumeTotal(typeof(Cigarette), 1)) { if (from.Body.IsHuman && !from.Mounted) { from.Animate(34, 5, 1, true, false, 0); } from.SendMessage("You light your cigarette and begin smoking."); from.Meditating = true; from.SendMessage("You feel more relaxed and calm."); from.PlaySound(0x226); Puffing = 60; //One point = one second new PuffingTimer(from, Puffing).Start(); } else { from.SendMessage("Your must have the cigarette in your pack to smoke it!"); return; } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; if (attacker.InRange(defender.Location, 2)) { return(false); } if (attacker.Player && this.GetType() == AmmoType) { this.MoveToWorld(defender.Location, defender.Map); attacker.MovingEffect(defender, EffectID, 18, 2, false, false); attacker.EquipItem(pack.FindItemByType(AmmoType, true)); return(true); } if (attacker.Player && (pack == null || !pack.ConsumeTotal(AmmoType, 1))) { if (attacker is TeiravonMobile && ((((TeiravonMobile)attacker).IsArcher()) && (((TeiravonMobile)attacker).IsUndead()) && (((TeiravonMobile)attacker).Shapeshifted))) { attacker.Damage(2); attacker.MovingEffect(defender, 0xF7E, 18, 1, false, false); return(true); } else { return(false); } } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
//this checks for money, and withdraws it if necessary public bool CheckCost(Mobile from, bool withdraw) { if (CostToPlay == 0) { return(true); } Gold gold = (Gold)from.Backpack.FindItemByType(typeof(Gold)); if (gold == null || gold.Amount < CostToPlay) { Container bankbox = from.FindBankNoCreate(); if (bankbox != null) { gold = (Gold)bankbox.FindItemByType(typeof(Gold)); if (gold != null && gold.Amount >= CostToPlay) { if (withdraw) { bankbox.ConsumeTotal(typeof(Gold), CostToPlay); } return(true); } } return(false); } if (withdraw) { from.Backpack.ConsumeTotal(typeof(Gold), CostToPlay); } return(true); }
public override void OnDoubleClick(Mobile from) { if (from.InRange(this.GetWorldLocation(), 2)) { Container pack = from.Backpack; if (pack != null) { if (pack.ConsumeTotal(typeof(Gold), m_Cost)) { from.AddToBackpack(new BagOfReagents(m_RegAmount)); from.SendMessage("You have bought a bag of reagents."); } else { from.SendMessage("You do not have enough money in your backpack to use this!"); } } } else { from.SendMessage("You are too far away to use this."); } }
public virtual bool OnFired(Mobile attacker, Mobile defender) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; Container pack = attacker.Backpack; if (attacker.Player) { if (quiver == null || quiver.LowerAmmoCost == 0 || quiver.LowerAmmoCost > Utility.Random(100)) { if (quiver != null && quiver.ConsumeTotal(AmmoType, 1)) { quiver.InvalidateWeight(); } else if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { return(false); } } } attacker.MovingEffect(defender, EffectID, 18, 1, false, false); return(true); }
/// <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 static void Cook(TreeResourceItem resource, Mobile from, HarvestSuccessRating rating, TreeProduct product, Container pack) { switch (rating) { case HarvestSuccessRating.PartialSuccess: case HarvestSuccessRating.Success: { TreeProductItem item = new TreeProductItem(product); if (item.ItemID == 0x183B && !pack.ConsumeTotal(typeof (LargeEmptyFlask), 1)) { from.SendMessage( "You need an empty flask in your pack to store the {0}. The resource was lost.", item.Name); resource.Consume(1); item.Delete(); } else if (item.ItemID == 0x1604 && !pack.ConsumeTotal(typeof (EmptyWoodenBowl), 1)) { from.SendMessage( "You need an empty bowl in your pack to store the {0}. The resource was lost.", item.Name); resource.Consume(1); item.Delete(); } else if (from.AddToBackpack(item) || item.DropToWorld(from, from.Location)) { from.SendMessage("You cook the resource and turn it in to {0}.", item.Name); resource.Consume(1); } else { from.SendMessage("Unable to create the {0}.", item.Name); item.Delete(); } break; } case HarvestSuccessRating.Failure: { from.SendMessage("You fail to cook the resource."); break; } } }
public void EndDryDock( Mobile from, Mobile master, Container bank ) { if ( Deleted || CheckDecay() ) return; DryDockResult result = CheckDryDock( from ); /*if (result == DryDockResult.Dead) master.Say(true, "You appear to be dead."); //from.SendAsciiMessage("You appear to be dead."); // You appear to be dead. else if (result == DryDockResult.NoKey) master.Say(true, "You must have the key to the ship you wish to dock."); //from.SendAsciiMessage("You must have a key to the ship to dock the boat."); // You must have a key to the ship to dock the boat. else if (result == DryDockResult.NotAnchored) from.SendAsciiMessage("You must lower the anchor to dock the boat."); // You must lower the anchor to dock the boat. else if (result == DryDockResult.Mobiles) master.Say(true, "Make sure the deck is clear and the hold is empty."); //from.SendAsciiMessage("You cannot dock the ship with beings on board!"); // You cannot dock the ship with beings on board! else if (result == DryDockResult.Items) master.Say(true, "Make sure the deck is clear and the hold is empty."); //from.SendAsciiMessage("You cannot dock the ship with a cluttered deck."); // You cannot dock the ship with a cluttered deck. else if (result == DryDockResult.Hold) master.Say(true, "Make sure the deck is clear and the hold is empty."); //from.SendAsciiMessage("Make sure your hold is empty, and try again!"); // Make sure your hold is empty, and try again!*/ if (result == DryDockResult.Dead) from.SendAsciiMessage("You appear to be dead."); // You appear to be dead. else if (result == DryDockResult.NoKey) from.SendAsciiMessage("You must have a key to the ship to dock the boat."); // You must have a key to the ship to dock the boat. else if (result == DryDockResult.NotAnchored) from.SendAsciiMessage("You must lower the anchor to dock the boat."); // You must lower the anchor to dock the boat. else if (result == DryDockResult.Mobiles) from.SendAsciiMessage("You cannot dock the ship with beings on board!"); // You cannot dock the ship with beings on board! else if (result == DryDockResult.Items) from.SendAsciiMessage("You cannot dock the ship with a cluttered deck."); // You cannot dock the ship with a cluttered deck. else if (result == DryDockResult.Hold) from.SendAsciiMessage("Make sure your hold is empty, and try again!"); // Make sure your hold is empty, and try again! if ( result != DryDockResult.Valid ) return; BaseDockedBoat boat = DockedBoat; if ( boat == null ) return; RemoveKeys( from ); from.AddToBackpack( boat ); Delete(); bank.ConsumeTotal(typeof(Gold), 25); master.Say(true, "Here is your claim ticket. I suggest you store it in your safety deposit box for safety."); }
//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