protected override void OnTarget(Mobile from, object target) { if (target == from) { from.SendLocalizedMessage(1005576); // You can't throw this at yourself. } else if (target is Mobile targ) { Container pack = targ.Backpack; if (from.Region.IsPartOf <SafeZone>() || targ.Region.IsPartOf <SafeZone>()) { from.SendMessage("You may not throw snow here."); } else if (pack?.FindItemByType(new[] { typeof(SnowPile), typeof(PileOfGlacialSnow) }) != null) { if (from.BeginAction <SnowPile>()) { new InternalTimer(from).Start(); from.PlaySound(0x145); from.Animate(9, 1, 1, true, false, 0); targ.SendLocalizedMessage(1010572); // You have just been hit by a snowball! from.SendLocalizedMessage(1010573); // You throw the snowball and hit the target! Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x480); } else { from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying. } } else { from.SendLocalizedMessage( 1005577); // You can only throw a snowball at something that can throw one back. } } else { from.SendLocalizedMessage( 1005577); // You can only throw a snowball at something that can throw one back. } }
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(GetWorldLocation(), 2)) { if (m_Held > 0) { Container pack = from.Backpack; if (pack == null || !PourBottle(from, pack.FindItemByType(typeof(Bottle)))) { from.SendLocalizedMessage(502241); // Where is a container for your potion? from.Target = new InternalTarget(this); } } else { from.SendLocalizedMessage(502246); // The keg is empty. } } else { from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that. } }
/// <summary> /// StandingDelay: denotes the minimum time (in seconds) an archer must stand still /// before being able to fire. /// </summary> //private double StandingDelay = 0.5; public override TimeSpan OnSwing(Mobile attacker, Mobile defender) { Container pack = attacker.Backpack; // Make sure we've been standing still for the standing delay (originally was: one second) if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(CoreAI.StandingDelay)) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot)) { if (attacker.HarmfulCheck(defender)) { // Check if weapon is poisoned if (PoisonCharges == 0) { // Not poisoned // Check to make sure players backpack exists if (pack != null) { // check for arrows/bolts Item Ammo; Ammo = (Item)pack.FindItemByType(AmmoType, true); if (Ammo != null) { if (Core.UOSP || Core.UOMO) { } else { // check for poisoned cloth in backpack PoisonCloth PCloth = (PoisonCloth)pack.FindItemByType(typeof(PoisonCloth), false); if (PCloth != null) { // cloth found // check for charges if (PCloth.PoisonCharges > 0) { //Pix: 5/13/06 - make sure they don't have a spell ready Spell s = attacker.Spell as Spell; if (s != null && s.State == SpellState.Sequencing) { s.Disturb(DisturbType.EquipRequest, true, false); attacker.SendMessage("You break your concentration to poison an arrow."); attacker.FixedEffect(0x3735, 6, 30); } Poison poisonToApply = this.GetPoisonBasedOnSkillAndPoison(attacker, PCloth.Poison); Poison = poisonToApply; PoisonCharges = 1; PCloth.PoisonCharges--; if (PCloth.Poison != null) { if (attacker.AccessLevel > AccessLevel.GameMaster) { attacker.SendMessage("Applying poison level {0} to ammo", Poison.Name); } if (AmmoType == typeof(Arrow)) { attacker.SendMessage("You wipe an arrow with your poison soaked rag and prepare to fire it."); } else { attacker.SendMessage("You wipe a bolt with your poison soaked rag and prepare to fire it."); } } } // If no charges are left in the cloth, remove it if (PCloth.PoisonCharges == 0) { attacker.SendMessage("The rag falls apart from use."); PCloth.Delete(); } // Delay for time spent poisoning arrow if (PCloth.Delay > 0.0) { return(TimeSpan.FromSeconds(PCloth.Delay)); } } } } } } attacker.DisruptiveAction(); attacker.Send(new Swing(0, attacker, defender)); if (OnFired(attacker, defender)) { if (CheckHit(attacker, defender)) { OnHit(attacker, defender); } else { OnMiss(attacker, defender); } } if (Core.UOAI || Core.UOAR) { // set weapon to be unpoisoned Poison = null; PoisonCharges = 0; } } return(GetDelay(attacker)); } else { return(TimeSpan.FromSeconds(0.25)); } }
public static bool GibberTokenExistsOn(Mobile mob) { Container pack = mob.Backpack; return(pack != null && pack.FindItemByType(typeof(GibberToken)) != null); }
private static void IncreaseTypeAmount( Container c, Type type, double iMultiplyValue ) { Item item = c.FindItemByType(type); if( item != null && item.Stackable ) item.Amount = (int)(item.Amount * iMultiplyValue); }
public virtual bool OnFired(Mobile attacker, Mobile defender) { if (attacker.Player) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; Container pack = attacker.Backpack; if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost) { // consume ammo if (quiver != null && quiver.ConsumeTotal(this.AmmoType, 1)) { quiver.InvalidateWeight(); } else if (pack == null || !pack.ConsumeTotal(this.AmmoType, 1)) { return(false); } } else if (quiver.FindItemByType(this.AmmoType) == null && (pack == null || pack.FindItemByType(this.AmmoType) == null)) { // lower ammo cost should not work when we have no ammo at all return(false); } } attacker.MovingEffect(defender, this.EffectID, 18, 1, false, false); return(true); }
public void ConstructDragon(Mobile from) { Type[] types = new Type[6]; int[] amounts = new int[6]; if (from.Skills[SkillName.Tinkering].Value < 85.0) { from.SendMessage("You are not skilled enough to construct a dragon"); return; } Container ourPack = from.Backpack; if (ourPack == null) { return; } Item powercore = ourPack.FindItemByType(typeof(DragonPowerCore)); Item ironingot = ourPack.FindItemByType(typeof(IronIngot)); Item valoriteingot = ourPack.FindItemByType(typeof(ValoriteIngot)); Item gears = ourPack.FindItemByType(typeof(Gears)); Item dragonsblood = ourPack.FindItemByType(typeof(DragonsBlood)); if (ironingot == null) { from.SendMessage("You need 50 iron ingots to construct a dragon"); return; } else { if (ironingot.Amount < 50) { from.SendMessage("You need 50 iron ingots to construct a dragon"); return; } else { types[0] = typeof(IronIngot); amounts[0] = 50; } } if (valoriteingot == null) { from.SendMessage("You need 100 valorite ingots to construct a dragon"); return; } else { if (valoriteingot.Amount < 100) { from.SendMessage("You need 100 valorite ingots to construct a dragon"); return; } else { types[1] = typeof(ValoriteIngot); amounts[1] = 100; } } if (gears == null) { from.SendMessage("You need 10 gears to construct a dragon"); return; } else { if (gears.Amount < 10) { from.SendMessage("You need 10 gears to construct a dragon"); return; } else { types[2] = typeof(Gears); amounts[2] = 10; } } if (dragonsblood == null) { from.SendMessage("You need 50 vials of dragon's blood to construct a daemon"); return; } else { if (dragonsblood.Amount < 50) { from.SendMessage("You need 50 vials of dragon's blood to construct a daemon"); return; } else { types[3] = typeof(DragonsBlood); amounts[3] = 50; } } if (powercore == null) { from.SendMessage("You need a dragon power core to construct a dragon"); return; } else { types[4] = typeof(DragonPowerCore); amounts[4] = 1; } types[5] = typeof(RunicClockworkAssembly); amounts[5] = 1; if ((from.Followers + 3) > from.FollowersMax) { from.SendMessage("You have too many followers to construct a dragon"); return; } if (!from.CheckSkill(SkillName.Tinkering, 85.0, 120.0)) { types = new Type[2]; amounts = new int[2]; types[0] = typeof(IronIngot); amounts[0] = Utility.Random(1, 10); types[1] = typeof(ValoriteIngot); amounts[1] = Utility.Random(1, 10); ourPack.ConsumeTotal(types, amounts, true); from.SendMessage("You fail to create the dragon an lose some ingots"); return; } else { ourPack.ConsumeTotal(types, amounts, true); } double percentage = (from.Skills[SkillName.Tinkering].Base - 85) / 35; if (percentage < 0.5) { percentage = 0.5; } else if (percentage > 1.0) { percentage = 1.0; } object o = Activator.CreateInstance(typeof(IronDragon)); IronDragon assembly = (IronDragon)o; assembly.Str = (int)(assembly.Str * percentage); assembly.Dex = (int)(assembly.Dex * percentage); assembly.Int = (int)(assembly.Int * percentage); assembly.Skills[SkillName.Anatomy].Base = Math.Round(assembly.Skills[SkillName.Anatomy].Base * percentage, 1); assembly.Skills[SkillName.Macing].Base = Math.Round(assembly.Skills[SkillName.Macing].Base * percentage, 1); assembly.Skills[SkillName.Tactics].Base = Math.Round(assembly.Skills[SkillName.Tactics].Base * percentage, 1); assembly.Skills[SkillName.MagicResist].Base = Math.Round(assembly.Skills[SkillName.MagicResist].Base * percentage, 1); assembly.Hits = assembly.HitsMax; assembly.ActiveSpeed = 0.1; assembly.Crafted = true; assembly.Controlled = true; assembly.ControlMaster = from; assembly.ControlOrder = OrderType.None; assembly.Tamable = false; assembly.ControlSlots = 4; assembly.Loyalty = 100; assembly.Creator = from; assembly.UpgradeLevel = 0; assembly.Map = from.Map; assembly.Location = from.Location; from.Followers += 4; }
public static void AddSortedItem( Item item, Container cont ) { Item item2 = cont.FindItemByType( item.GetType() ); if ( item2 != null && item2.Amount < 60000 ) { item2.Amount++; item.Delete(); } else cont.DropItem( item ); }
//note: this only works for stackable items. public static Item FindItemByType( Container pack, Type type, int amount ) { //can't search a null pack! if( pack == null ) { return null; } //first check the backpack if it exists Item bagitem = pack.FindItemByType( type ); //if not, then look to pull from keys if( ( bagitem == null || bagitem.Amount < amount ) && CraftWithdraw( pack, new Type[]{ type }, amount - ( bagitem != null ? bagitem.Amount : 0 ) ) ) { //the keys will have added this item to pack, so go looking for it again return pack.FindItemByType( type ); } //return either the item found from the bag, or null if they weren't found in keys either return bagitem; }
protected override void OnTick() { Type[] types = new Type[1]; int[] amounts = new int[1]; m_Tinker.EndAction(typeof(AssemblyRepairKit)); Container ourPack = m_Tinker.Backpack; if (ourPack == null) { return; } Item ironingot = ourPack.FindItemByType(typeof(IronIngot)); if (m_Kit.Deleted || !m_Tinker.CanSee(m_Kit) || !m_Tinker.CanSee(m_Assembly) || ironingot == null) { return; } int amounttouse = (int)(m_Tinker.Skills[SkillName.Tinkering].Base / 20); if (amounttouse > ironingot.Amount) { amounttouse = ironingot.Amount; } if (amounttouse < 1) { amounttouse = 1; } types[0] = typeof(IronIngot); amounts[0] = amounttouse; ourPack.ConsumeTotal(types, amounts, true); int tinkerNumber = -1; bool checkSkills = false; if (!m_Tinker.Alive) { tinkerNumber = 500962; //You were unable to finish your work before you died. } else if (!m_Tinker.InRange(m_Assembly, 1)) { tinkerNumber = 500963; // You did not stay close enough to heal your target. } else if (m_Assembly.Hits == m_Assembly.HitsMax) { tinkerNumber = 500423; // That item is already in full repair } else { checkSkills = true; double tinkering = m_Tinker.Skills[SkillName.Tinkering].Value; if (tinkering < Utility.Random(85)) { tinkerNumber = 1044280; } else { tinkerNumber = 500425; double toHeal = amounttouse * 20 * Utility.RandomDouble(); m_Assembly.Heal((int)toHeal); BaseCreature creature = (BaseCreature)m_Assembly; creature.Loyalty = 100; } } if (tinkerNumber != -1) { m_Tinker.SendLocalizedMessage(tinkerNumber); } if (checkSkills) { m_Tinker.CheckSkill(SkillName.Tinkering, 0, 120); } }
/// <summary> /// Overrides the Double-Click option on the item. Supplies the /// player that double-clicks on the stone with appropriate gear /// based upon their skill levels. /// </summary> /// <param name="m">PlayerMobile to be supplied</param> public override void OnDoubleClick(Mobile m) { if (m.Backpack != null) { if (((m.X) == this.X || (m.X - 1) == this.X || (m.X + 1) == this.X) && ((m.Y) == this.Y || (m.Y - 1) == this.Y || (m.Y + 1) == this.Y)) { if (!Tourney) { Supply(new BagOfPots(8, 8, 4, 4, 5), m, typeof(BagOfPots)); for (int i = 1; i <= 5; i++) { TrapableContainer con = new Pouch(); con.TrapType = TrapType.MagicTrap; con.TrapLevel = 1; con.TrapPower = 1; if (!m.AddToBackpack(con)) { con.Delete(); } } } else { for (int i = 1; i <= 10; i++) { Item item = new TotalRefreshPotion(); if (!m.AddToBackpack(item)) { item.Delete(); } } } if (m.Skills[SkillName.Magery].Value >= 50.0 || m.Str <= 50) { EquipArmor(new LeatherLegs(), true, m, typeof(LeatherLegs), m_EquipHue); EquipArmor(new LeatherGorget(), true, m, typeof(LeatherGorget), m_EquipHue); EquipArmor(new LeatherGloves(), true, m, typeof(LeatherGloves), m_EquipHue); EquipArmor(new LeatherChest(), true, m, typeof(LeatherChest), m_EquipHue); EquipArmor(new LeatherArms(), true, m, typeof(LeatherArms), m_EquipHue); EquipArmor(new LeatherCap(), true, m, typeof(LeatherCap), m_EquipHue); } else { EquipArmor(new ChainLegs(), true, m, typeof(ChainLegs), m_EquipHue); EquipArmor(new LeatherGorget(), true, m, typeof(LeatherGorget), m_EquipHue); EquipArmor(new RingmailGloves(), true, m, typeof(RingmailGloves), m_EquipHue); EquipArmor(new ChainChest(), true, m, typeof(ChainChest), m_EquipHue); EquipArmor(new RingmailArms(), true, m, typeof(RingmailArms), m_EquipHue); EquipArmor(new CloseHelm(), true, m, typeof(CloseHelm), m_EquipHue); } if (m.Skills[SkillName.Magery].Value >= 50.0) { Container pack = m.Backpack; if (pack.FindItemByType(typeof(Spellbook)) == null) { Spellbook book = new Spellbook(); book.Content = ulong.MaxValue; book.LootType = LootType.Regular; if (!m.AddToBackpack(book)) { book.Delete(); } } Supply(new BagOfReagents(50), m, typeof(BagOfReagents)); } if (m.Skills[SkillName.Healing].Value >= 50.0 || m.Skills[SkillName.Veterinary].Value >= 50) { Supply(new Bandage(50), m, typeof(Bandage)); } if (m.Skills[SkillName.Swords].Value >= 50.0) { EquipItem(new Katana(), true, m, typeof(Katana)); EquipItem(new Halberd(), false, m, typeof(Halberd)); EquipItem(new BattleAxe(), false, m, typeof(BattleAxe)); } if (m.Skills[SkillName.Fencing].Value >= 50.0) { EquipItem(new Kryss(), true, m, typeof(Kryss)); EquipItem(new ShortSpear(), false, m, typeof(ShortSpear)); EquipItem(new Spear(), false, m, typeof(Spear)); } if (m.Skills[SkillName.Macing].Value >= 50.0) { EquipItem(new Mace(), true, m, typeof(Mace)); EquipItem(new QuarterStaff(), false, m, typeof(QuarterStaff)); EquipItem(new WarHammer(), false, m, typeof(WarHammer)); } if (m.Skills[SkillName.Archery].Value >= 50.0) { EquipItem(new Bow(), false, m, typeof(Bow)); EquipItem(new Crossbow(), false, m, typeof(Crossbow)); EquipItem(new HeavyCrossbow(), false, m, typeof(HeavyCrossbow)); Supply(new Arrow(50), m, typeof(Arrow)); Supply(new Bolt(50), m, typeof(Bolt)); } } else { m.SendMessage("You reach out but cannot seem to touch the stone..."); } } else { m.SendMessage("For some reason you don't seem to have a backpack..."); } }
public static bool ExistsOn(Mobile mob) { Container pack = mob.Backpack; return(pack != null && pack.FindItemByType(typeof(EventFlag)) != null); }
public void makeready(Mobile who) { PlayerMobile c = (PlayerMobile)who; if (!who.Alive) { who.Resurrect(); } Container bp = c.Backpack; Container bankbag = new Bag(); bankbag.Hue = 63; BankBox bank = c.BankBox; Item oncurs = c.Holding; if (oncurs != null) { bp.DropItem(oncurs); } c.SendMessage("You have 10 seconds until the duel begins"); c.SendMessage(63, "After one of you dies, both of you will be teleported out"); c.Criminal = true; c.CurePoison(c); c.Blessed = true; c.Frozen = true; c.Hits = c.HitsMax; c.Mana = c.ManaMax; c.Stam = c.StamMax; c.StatMods.Clear(); if (bp != null) { Item toDisarm = c.FindItemOnLayer(Layer.OneHanded); if (toDisarm == null || !toDisarm.Movable) { toDisarm = c.FindItemOnLayer(Layer.TwoHanded); } if (toDisarm != null) { bp.DropItem(toDisarm); } if (c.Mount != null) { IMount mount = c.Mount; mount.Rider = null; if (mount is BaseMount) { BaseMount oldMount = (BaseMount)mount; oldMount.Map = Map.Internal; c.TempMount = oldMount; } } //while((BasePotion)bp.FindItemByType(typeof(BasePotion)) != null) //{ // BasePotion potion = (BasePotion)bp.FindItemByType(typeof(BasePotion)); // bankbag.DropItem(potion); //} while ((EtherealMount)bp.FindItemByType(typeof(EtherealMount)) != null) { EtherealMount mount = (EtherealMount)bp.FindItemByType(typeof(EtherealMount)); bankbag.DropItem(mount); } /*Item[] weps = bp.FindItemsByType( typeof( BaseWeapon ) ); * for ( int i = 0; i < weps.Length; ++i ) * { * Item item = (Item)weps[i]; * BaseWeapon weapon = item as BaseWeapon; * if( weapon.DamageLevel > WeaponDamageLevel.Regular ) * bankbag.DropItem( item ); * }*/ if (bankbag.Items.Count > 0) { bank.DropItem(bankbag); } else { bankbag.Delete(); } } }
public override bool CanTeleport(Mobile m) { if (!base.CanTeleport(m)) { return(false); } if (GetFlag(ConditionFlag.StaffOnly) && m.IsPlayer()) { return(false); } if (GetFlag(ConditionFlag.DenyMounted) && m.Mounted) { m.SendLocalizedMessage(1077252); // You must dismount before proceeding. return(false); } if (GetFlag(ConditionFlag.DenyFollowers) && (m.Followers != 0 || (m is PlayerMobile && ((PlayerMobile)m).AutoStabled.Count != 0))) { m.SendLocalizedMessage(1077250); // No pets permitted beyond this point. return(false); } Container pack = m.Backpack; if (pack != null) { if (GetFlag(ConditionFlag.DenyPackContents) && pack.TotalItems != 0) { if (!DisableMessage) { m.SendMessage("You must empty your backpack before proceeding."); } return(false); } if (GetFlag(ConditionFlag.DenyPackEthereals) && (pack.FindItemByType(typeof(EtherealMount)) != null || pack.FindItemByType(typeof(BaseImprisonedMobile)) != null)) { if (!DisableMessage) { m.SendMessage("You must empty your backpack of ethereal mounts before proceeding."); } return(false); } } if (GetFlag(ConditionFlag.DenyHolding) && m.Holding != null) { if (!DisableMessage) { m.SendMessage("You must let go of what you are holding before proceeding."); } return(false); } if (GetFlag(ConditionFlag.DenyEquipment)) { foreach (Item item in m.Items) { switch (item.Layer) { case Layer.Hair: case Layer.FacialHair: case Layer.Backpack: case Layer.Mount: case Layer.Bank: { continue; // ignore } default: { if (!DisableMessage) { m.SendMessage("You must remove all of your equipment before proceeding."); } return(false); } } } } if (GetFlag(ConditionFlag.DenyTransformed) && m.IsBodyMod) { if (!DisableMessage) { m.SendMessage("You cannot go there in this form."); } return(false); } if (GetFlag(ConditionFlag.DeadOnly) && m.Alive) { if (!DisableMessage) { m.SendLocalizedMessage(1060014); // Only the dead may pass. } return(false); } if (!DisableMessage && ClilocNumber != 0) { m.SendLocalizedMessage(ClilocNumber); } return(true); }
public virtual bool OnFired(Mobile attacker, Mobile defender) { if (this is ThrowingGloves && attacker.Player) { string ammoType = "Throwing Stones"; ThrowingGloves glove = (ThrowingGloves)this; if (glove.GloveType == "Stones") { ammoType = "Throwing Stones"; } else if (glove.GloveType == "Axes") { ammoType = "Throwing Axes"; } else if (glove.GloveType == "Daggers") { ammoType = "Throwing Daggers"; } else if (glove.GloveType == "Darts") { ammoType = "Throwing Darts"; } else if (glove.GloveType == "Cards" && Server.Misc.GetPlayerInfo.isJester(attacker)) { ammoType = "Throwing Cards"; } else if (glove.GloveType == "Tomatoes" && Server.Misc.GetPlayerInfo.isJester(attacker)) { ammoType = "Throwing Tomatoes"; } else { ammoType = "Throwing Stars"; glove.GloveType = "Stones"; } foreach (Item i in attacker.Backpack.FindItemsByType(typeof(ThrowingWeapon), true)) { if (ammoType == "Throwing Stones") { ((ThrowingWeapon)i).ammo = "Throwing Stones"; i.ItemID = 0x10B6; i.Name = "throwing stone"; } else if (ammoType == "Throwing Axes") { ((ThrowingWeapon)i).ammo = "Throwing Axes"; i.ItemID = 0x10B3; i.Name = "throwing axe"; } else if (ammoType == "Throwing Daggers") { ((ThrowingWeapon)i).ammo = "Throwing Daggers"; i.ItemID = 0x10B7; i.Name = "throwing dagger"; } else if (ammoType == "Throwing Darts") { ((ThrowingWeapon)i).ammo = "Throwing Darts"; i.ItemID = 0x10B5; i.Name = "throwing dart"; } else if (ammoType == "Throwing Cards") { ((ThrowingWeapon)i).ammo = "Throwing Cards"; i.ItemID = 0x4C29; i.Name = "throwing card"; } else if (ammoType == "Throwing Tomatoes") { ((ThrowingWeapon)i).ammo = "Throwing Tomatoes"; i.ItemID = 0x4C28; i.Name = "throwing tomato"; } else { ((ThrowingWeapon)i).ammo = "Throwing Stars"; i.ItemID = 0x10B2; i.Name = "throwing star"; } i.InvalidateProperties(); } } if (attacker.Player) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; Container pack = attacker.Backpack; if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost) { // 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(defender, EffectID, 18, 1, false, false); Server.Gumps.QuickBar.RefreshQuickBar(attacker); return(true); }
public void ConstructRunicGolem(Mobile from) { Type[] types = new Type[5]; int[] amounts = new int[5]; if (from.Skills[SkillName.Tinkering].Value < 105.0) { from.SendMessage("You are not skilled enough to construct a runic golem"); return; } Container ourPack = from.Backpack; if (ourPack == null) { return; } Item powercore = ourPack.FindItemByType(typeof(RunicGolemPowerCore)); Item ironingot = ourPack.FindItemByType(typeof(IronIngot)); Item bronzeingot = ourPack.FindItemByType(typeof(BronzeIngot)); Item gears = ourPack.FindItemByType(typeof(Gears)); if (ironingot == null) { from.SendMessage("You need 150 iron ingots to construct a runic golem"); return; } else { if (ironingot.Amount < 150) { from.SendMessage("You need 150 iron ingots to construct a runic golem"); return; } else { types[0] = typeof(IronIngot); amounts[0] = 150; } } if (bronzeingot == null) { from.SendMessage("You need 75 bronze ingots to construct a runic golem"); return; } else { if (bronzeingot.Amount < 75) { from.SendMessage("You need 75 bronze ingots to construct a runic golem"); return; } else { types[1] = typeof(BronzeIngot); amounts[1] = 75; } } if (gears == null) { from.SendMessage("You need 25 gears to construct a runic golem"); return; } else { if (gears.Amount < 25) { from.SendMessage("You need 5 gears to construct a runic golem"); return; } else { types[2] = typeof(Gears); amounts[2] = 25; } } if (powercore == null) { from.SendMessage("You need a runic golem power core to construct a runic golem"); return; } else { types[3] = typeof(RunicGolemPowerCore); amounts[3] = 1; } types[4] = typeof(RunicClockworkAssembly); amounts[4] = 1; if ((from.Followers + 4) > from.FollowersMax) { from.SendMessage("You have too many followers to construct a runic golem"); return; } if (!from.CheckSkill(SkillName.Tinkering, 105.0, 120.0)) { types = new Type[2]; amounts = new int[2]; types[0] = typeof(IronIngot); amounts[0] = Utility.Random(1, 10); types[1] = typeof(BronzeIngot); amounts[1] = Utility.Random(1, 10); ourPack.ConsumeTotal(types, amounts, true); from.SendMessage("You fail to create the runic golem and lose some ingots"); return; } else { ourPack.ConsumeTotal(types, amounts, true); } double percentage = (from.Skills[SkillName.Tinkering].Base - 105) / 35; if (percentage < 0.5) { percentage = 0.5; } else if (percentage > 1.0) { percentage = 1.0; } object o = Activator.CreateInstance(typeof(RunicGolem)); RunicGolem assembly = (RunicGolem)o; assembly.Str = (int)(assembly.Str * percentage); assembly.Dex = (int)(assembly.Dex * percentage); assembly.Int = (int)(assembly.Int * percentage); assembly.Skills[SkillName.Anatomy].Base = Math.Round(assembly.Skills[SkillName.Anatomy].Base * percentage, 1); assembly.Skills[SkillName.Macing].Base = Math.Round(assembly.Skills[SkillName.Macing].Base * percentage, 1); assembly.Skills[SkillName.Tactics].Base = Math.Round(assembly.Skills[SkillName.Tactics].Base * percentage, 1); assembly.Skills[SkillName.MagicResist].Base = Math.Round(assembly.Skills[SkillName.MagicResist].Base * percentage, 1); assembly.Hits = assembly.HitsMax; assembly.ActiveSpeed = 0.1; assembly.Crafted = true; assembly.Controlled = true; assembly.ControlMaster = from; assembly.ControlOrder = OrderType.None; assembly.Tamable = false; assembly.ControlSlots = 4; assembly.Loyalty = 100; assembly.Creator = from; assembly.UpgradeLevel = 0; assembly.Map = from.Map; assembly.Location = from.Location; from.Followers += 4; }
public virtual bool OnFired(Mobile attacker, IDamageable damageable) { WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker); //Type type = (Color)Enum.Parse(typeof(Enumeration.ArrowType), m_ArrowType); // 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) { if (quiver != null && quiver.ConsumeTotal(SpecialAmmoType, 1)) { //attacker.SendMessage("1"); quiver.InvalidateWeight(); } //else if (pack == null || !pack.ConsumeTotal(m_ArrowType, 1)) /* UNIVERSAL STORAGE KEY BEGIN */ else if (pack == null || !pack.ConsumeTotal(SpecialAmmoType, 1) && !BaseStoreKey.Consume(pack, SpecialAmmoType, 1)) { //attacker.SendMessage("2"); return(false); } } // if( ArrowSelection > 0 & (pack == null || pack.FindItemByType(SpecialAmmoType) == null) ) // { // return false; // } else if (quiver.FindItemByType(SpecialAmmoType) == null && (pack == null || pack.FindItemByType(SpecialAmmoType) == null)) { // lower ammo cost should not work when we have no ammo at all //attacker.SendMessage("4"); return(false); } // else if( SpecialAmmoType != null && quiver.FindItemByType(SpecialAmmoType) == null && (pack == null || pack.FindItemByType(SpecialAmmoType) == null) ) // { // return false; // } } attacker.MovingEffect(damageable, EffectID, 18, 1, false, false); return(true); }