Example #1
0
        public static int CountPatrons(Mobile m)
        {
            int count = 0;

            foreach (Item i in m.GetItemsInRange(1))
            {
                if (i.Map == m.Map && !(i.Movable) && i is TavernTable && (m == ((TavernTable)i).DrinkerNorth || m == ((TavernTable)i).DrinkerSouth || m == ((TavernTable)i).DrinkerEast || m == ((TavernTable)i).DrinkerWest))
                {
                    if (((TavernTable)i).PatronNorth > 0)
                    {
                        count++;
                    }

                    if (((TavernTable)i).PatronSouth > 0)
                    {
                        count++;
                    }

                    if (((TavernTable)i).PatronEast > 0)
                    {
                        count++;
                    }

                    if (((TavernTable)i).PatronWest > 0)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
Example #2
0
        public bool VerifyPlacement(Mobile from, Rectangle2D area)
        {
            if (!from.CheckAlive())
            {
                return(false);
            }

            foreach (Item i in from.GetItemsInRange(12))
            {
                if ((i is TravelTent || i is TentAddon) && area.Contains(i))
                {
                    return(false);
                }
            }

            Region region = Region.Find(from.Location, from.Map);

            if (from.AccessLevel >= AccessLevel.GameMaster || region.AllowHousing(from, from.Location))
            {
                return(true);
            }
            else if (!from.Map.CanFit(from.Location, 16))
            {
                return(false);
            }
            else if (region is TreasureRegion)
            {
                return(false);
            }

            return(from.AccessLevel >= AccessLevel.GameMaster || region.AllowHousing(from, from.Location));
        }
Example #3
0
 public override void OnDoubleClick(Mobile from)
 {
     if (IsChildOf(from.Backpack))
     {
         if (Amount >= 4)
         {
             foreach (Item m in from.GetItemsInRange(2))
             {
                 if (m is FlourMillEastAddon || m is FlourMillSouthAddon)
                 {
                     from.SendMessage("You turned the wheat sheaves into a sack of flour.");
                     from.AddToBackpack(new SackFlour());
                     Consume(4);
                     return;
                 }
             }
         }
         else
         {
             from.SendMessage("You need more wheat sheaves.");
         }
     }
     else
     {
         from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
     }
 }
Example #4
0
        public static bool CheckProximity(Mobile from, int range)
        {
            Map map = from.Map;

            if (map == null)
            {
                return(false);
            }

            bool found = from.GetItemsInRange(range).Where(i => CheckTile(i.ItemID)).Any();

            for (int x = -range; !found && x <= range; ++x)
            {
                for (int y = -range; !found && y <= range; ++y)
                {
                    Tile[] tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true);

                    for (int i = 0; !found && i < tiles.Length; ++i)
                    {
                        if (CheckTile(tiles[i].ID & TileData.MaxItemValue))
                        {
                            found = true;
                        }
                    }
                }
            }

            return(found);
        }
Example #5
0
        public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (m.PlaceInBackpack(item))
            {
                return(true);
            }

            if (!placeAtFeet)
            {
                return(false);
            }

            Map map = m.Map;

            if (map == null)
            {
                return(false);
            }

            var list   = m.GetItemsInRange(0);
            var atFeet = list.OfType <Item>().ToList();

            list.Free();

            if (atFeet.Any(check => check.StackWith(m, item, false)))
            {
                return(true);
            }

            item.MoveToWorld(m.Location, map);
            return(true);
        }
        public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (m.PlaceInBackpack(item))
                return true;

            if (!placeAtFeet)
                return false;

            Map map = m.Map;

            if (map == null || map == Map.Internal)
                return false;

            List<Item> atFeet = new List<Item>();

            IPooledEnumerable eable = m.GetItemsInRange(0);

            foreach (Item obj in eable)
                atFeet.Add(obj);

            eable.Free();

            for (int i = 0; i < atFeet.Count; ++i)
            {
                Item check = atFeet[i];

                if (check.StackWith(m, item, false))
                    return true;
            }

            ColUtility.Free(atFeet);

            item.MoveToWorld(m.Location, map);
            return true;
        }
Example #7
0
        public static bool IsNearType(Mobile mob, Type type, int range)
        {
            bool mobs  = type.IsSubclassOf(typeof(Mobile));
            bool items = type.IsSubclassOf(typeof(Item));

            IPooledEnumerable eable;

            if (mobs)
            {
                eable = mob.GetMobilesInRange(range);
            }
            else if (items)
            {
                eable = mob.GetItemsInRange(range);
            }
            else
            {
                return(false);
            }

            foreach (object obj in eable)
            {
                if (type.IsAssignableFrom(obj.GetType()))
                {
                    eable.Free();
                    return(true);
                }
            }

            eable.Free();
            return(false);
        }
Example #8
0
		public override void OnDoubleClick( Mobile from )
		{
			ArrayList list = new ArrayList();

			foreach ( Item m in from.GetItemsInRange( 2 ) )
			{
				if ( m is FlourMillEastAddon )
					list.Add( m );

				else if ( m is FlourMillSouthAddon )
					list.Add( m );
			}

			if( IsChildOf( from.Backpack ) && Amount >= 4 && list.Count <= 0 )
			{
				from.SendLocalizedMessage( 1044491 ); // You must be near a flour mill to do that.
			}

			else if( IsChildOf( from.Backpack ) && Amount >= 4 )
			{
				from.SendMessage( "You got a sack of flour." );
				from.AddToBackpack( new SackFlour() );
				this.Consume( 4 );
			}

			else if( IsChildOf( from.Backpack ) && Amount < 4 )
			{
				from.SendMessage( "You need more wheat sheaves." );
			}

			else
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
		}
Example #9
0
        public override void OnDoubleClick(Mobile from)
        {
            if (RootParent == from || (from.InRange(GetWorldLocation(), 3) && from.InLOS(GetWorldLocation())))
            {
                if (!Unrolled)
                {
                    Unroll();
                    MoveToWorld(from.Location, from.Map);
                }
                else if (ItemID == 0x0A55)
                {
                    if (Parent == null)
                    {
                        IPooledEnumerable eable = from.GetItemsInRange(7);
                        Campfire          fire  = null;
                        foreach (Item item in eable)
                        {
                            if (item is Campfire)
                            {
                                fire = (Campfire)item;
                                break;
                            }
                        }
                        eable.Free();

                        if (fire != null)
                        {
                            if (fire.CanLogout(from))
                            {
                                new BedRollLogoutMenu().SendTo(from.NetState);
                            }
                            else
                            {
                                from.SendAsciiMessage("Your camp is not yet secure.");
                            }
                        }
                        else
                        {
                            Roll();
                            from.AddToBackpack(this);
                        }
                    }
                    else
                    {
                        // is in a container (not on ground)
                        Roll();
                        from.AddToBackpack(this);
                    }
                }
            }
            else
            {
                from.SendAsciiMessage("You must be closer to use that.");
            }
        }
Example #10
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (info.ButtonID > 0)
                {
                    Point3D loc = m_From.Location;
                    Map     map = m_From.Map;

                    bool nearCoil = false;
                    foreach (Item coil in m_From.GetItemsInRange(10))
                    {
                        if (coil is PowerCoil)
                        {
                            nearCoil = true;
                            loc      = new Point3D(coil.X, coil.Y, (coil.Z + 20));
                        }
                    }

                    if (nearCoil)
                    {
                        int Fighter = info.ButtonID - 1;

                        FrankenPorterItem flesh = new FrankenPorterItem();

                        string QuestLog = "has reanimated a flesh golem";

                        flesh.PorterOwner = m_From.Serial;
                        flesh.PorterLevel = m_Journal.HasBrain;
                        flesh.PorterType  = Fighter;

                        m_From.AddToBackpack(flesh);

                        Server.Misc.LoggingFunctions.LogGenericQuest(m_From, QuestLog);

                        m_From.PrivateOverheadMessage(MessageType.Regular, 1153, false, "My experiment is a success.", m_From.NetState);

                        int sound = Utility.RandomList(0x028, 0x029);
                        Effects.SendLocationEffect(loc, map, 0x2A4E, 30, 10, 0, 0);
                        m_From.PlaySound(sound);

                        m_Journal.Delete();
                    }
                    else
                    {
                        m_From.SendMessage("You need to be near a power coil to do that.");
                        m_From.SendSound(0x55);
                    }
                }
                else
                {
                    m_From.SendSound(0x55);
                    m_From.CloseGump(typeof(StatsGump));
                }
            }
Example #11
0
        public static void MakeHoard(Mobile from)
        {
            bool Lucky = false;

            Mobile killer = from.LastKiller;

            if (killer != null)
            {
                if (killer is BaseCreature)
                {
                    killer = ((BaseCreature)killer).GetMaster();
                }

                if (killer is PlayerMobile)
                {
                    Lucky = true;
                }
            }

            if (from.Title != null && from.Title != "" && from.Fame >= 15000 && (Utility.RandomMinMax(1, 4) == 1 || Lucky))
            {
                ArrayList targets = new ArrayList();

                foreach (Item spawner in from.GetItemsInRange(30))
                {
                    if (spawner is HoardTile)
                    {
                        targets.Add(spawner);
                    }
                }

                HoardPiles MyHoard = null;
                Point3D    loc     = from.Location;
                Map        map     = from.Map;
                Item       spawn   = null;

                for (int i = 0; i < targets.Count; ++i)
                {
                    MyHoard = new HoardPiles();
                    if (Worlds.IsOnSpaceship(from.Location, from.Map))
                    {
                        MyHoard.ItemID = Utility.RandomList(0x096D, 0x096E);
                    }
                    spawn             = ( Item )targets[i];
                    loc               = spawn.Location;
                    map               = spawn.Map;
                    MyHoard.HoardName = from.Name + " " + from.Title;
                    MyHoard.MoveToWorld(loc, map);
                    Effects.SendLocationParticles(EffectItem.Create(MyHoard.Location, MyHoard.Map, EffectItem.DefaultDuration), 0x3709, 10, 30, 5052);
                    Effects.PlaySound(MyHoard, MyHoard.Map, 0x208);
                }
            }
        }
Example #12
0
        public static double GetTotemBonus(Mobile m, TotemType totemtype)
        {
            if (m == null)
            {
                return(0);
            }

            ArrayList targets = new ArrayList();

            Map map = m.Map;

            if (map != null)
            {
                foreach (Item item in m.GetItemsInRange(15))
                {
                    if (item != null && m.CanSee(item) && item is Totem)
                    {
                        targets.Add(item);
                    }
                }
            }

            Totem chosen = null;

            for (int i = 0; i < targets.Count; ++i)
            {
                Totem totem = (Totem)targets[i];

                if (totem != null && totem.TotemType == totemtype)
                {
                    if (m.InRange(totem, totem.MaxRange))
                    {
                        if (chosen == null || chosen.Bonus < totem.Bonus)
                        {
                            chosen = totem;
                        }
                    }
                }
            }

            if (chosen != null && m != null && chosen.TotemType != TotemType.Amulette && chosen.TotemType != TotemType.Miracle && chosen.TotemType != TotemType.Refecteur)
            {
                Effects.SendTargetParticles(m, chosen.EffectID, chosen.EffectSpeed, chosen.EffectDuration, 5005, chosen.Hue, 0, chosen.EffectLayer);
            }

            if (chosen == null)
            {
                return(0);
            }

            return(chosen.Bonus);
        }
Example #13
0
        public override bool Begin(Mobile from, BaseTool tool)
        {
            bool forge = false, anvil = false;
            IPooledEnumerable eable = from.GetItemsInRange(3);

            foreach (Item item in eable)
            {
                if (IsForge(item))
                {
                    forge = true;
                }
                else if (item.GetType().IsDefined(typeof(AnvilAttribute), true) || item.ItemID == 0xFB0)
                {
                    anvil = true;
                }
            }
            eable.Free();

            if (anvil && forge)
            {
                if (base.Begin(from, tool))
                {
                    if (ShowMenu(m_MainMenu))
                    {
                        return(true);
                    }
                    else
                    {
                        End();
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else if (anvil && !forge)
            {
                from.SendAsciiMessage("You are not near a forge.");
            }
            else if (forge && !anvil)
            {
                from.SendAsciiMessage("You are not near an anvil.");
            }
            else             // !forge && !anvil
            {
                from.SendAsciiMessage("You are not near a forge or an anvil.");
            }

            return(false);
        }
Example #14
0
        private static void HandleOnLogout(LogoutEventArgs args)
        {
            Mobile m = args.Mobile;

            try
            {
                StaticTile[] tiles  = m.Map.Tiles.GetStaticTiles(m.X, m.Y, true);
                NetState     state  = (NetState)m.NetState;
                int          tileID = 0;
                bool         safe   = false;

                int[] bedID = new int[]
                {
                    2651, 2653, 2654, 2656,
                    2659, 2660, 2662, 2663,
                    2665, 2666, 2682, 2684,
                    2688, 2690, 2692, 2696,
                    2702, 2704
                };

                foreach (Item item in m.GetItemsInRange(6))
                {
                    for (int i = 0; !safe && i < bedID.Length; i++)
                    {
                        for (int j = 0; !safe && j < tiles.Length; j++)
                        {
                            tileID = tiles[j].ID;

                            if (tiles[j].Z == m.Z)
                            {
                                safe = (tileID == bedID[i]) || (item.ItemID == bedID[i]);
                            }
                        }
                    }
                }

                if (safe)
                {
                    ((PlayerMobile)m).BedrollLogout = true;

                    if (state != null)
                    {
                        state.Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionManager.LogException("StartupSettings.cs", e);
            }
        }
Example #15
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if ( from.Guild != null )
            {
                from.SendLocalizedMessage( 501137 ); // You must resign from your current guild before founding another!
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt( from );

                if ( house == null || house is Tent )
                {
                    from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
                }
                else if ( house.FindGuildstone() != null )
                {
                    from.SendLocalizedMessage( 501142 );//Only one guildstone may reside in a given house.
                }
                else if ( !house.IsOwner( from ) )
                {
                    from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
                }
                else
                {
                    IPooledEnumerable eable = from.GetItemsInRange( 1 );
                    foreach ( Item item in eable )
                    {
                        if ( item is BaseDoor && ( item.X == from.X || item.Y == from.Y ) && item.Z - 5 < from.Z && item.Z + 5 > from.Z )
                        {
                            from.SendAsciiMessage( "You cannot place this in front of a door." );
                            eable.Free();
                            return;
                        }
                    }
                    eable.Free();

                    from.SendLocalizedMessage( 1013060 ); // Enter new guild name (40 characters max):
                    from.Prompt = new InternalPrompt( this );
                }
            }
        }
Example #16
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else if (from.Guild != null)
            {
                from.SendLocalizedMessage(501137);                   // You must resign from your current guild before founding another!
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt(from);

                if (house == null || house is Tent)
                {
                    from.SendLocalizedMessage(501138);                       // You can only place a guildstone in a house.
                }
                else if (house.FindGuildstone() != null)
                {
                    from.SendLocalizedMessage(501142);                      //Only one guildstone may reside in a given house.
                }
                else if (!house.IsOwner(from))
                {
                    from.SendLocalizedMessage(501141);                       // You can only place a guildstone in a house you own!
                }
                else
                {
                    IPooledEnumerable eable = from.GetItemsInRange(1);
                    foreach (Item item in eable)
                    {
                        if (item is BaseDoor && (item.X == from.X || item.Y == from.Y) && item.Z - 5 < from.Z && item.Z + 5 > from.Z)
                        {
                            from.SendAsciiMessage("You cannot place this in front of a door.");
                            eable.Free();
                            return;
                        }
                    }
                    eable.Free();

                    from.SendLocalizedMessage(1013060);                       // Enter new guild name (40 characters max):
                    from.Prompt = new InternalPrompt(this);
                }
            }
        }
Example #17
0
        public override bool OnMoveOver(Mobile m)
        {
            ArrayList list = new ArrayList();

            foreach (Item item in m.GetItemsInRange(2))
            {
                if (item is BaseDoor)
                {
                    list.Add(item);
                }
            }
            foreach (Item item in list)
            {
                BaseDoor iDoor = (BaseDoor)item;
                iDoor.Open = true;
            }
            return(true);
        }
Example #18
0
        public override void OnDoubleClick(Mobile from)
        {
            ArrayList list = new ArrayList();

            foreach (Item m in from.GetItemsInRange(2))
            {
                if (m is FlourMillEastAddon)
                {
                    list.Add(m);
                }

                else if (m is FlourMillSouthAddon)
                {
                    list.Add(m);
                }

                else if (m.ItemID == 6434)
                {
                    list.Add(m);
                }
            }

            if (IsChildOf(from.Backpack) && Amount >= 4 && list.Count <= 0)
            {
                from.SendLocalizedMessage(1044491);                   // You must be near a flour mill to do that.
            }

            else if (IsChildOf(from.Backpack) && Amount >= 4)
            {
                from.SendMessage("You made a sack of flour.");
                from.AddToBackpack(new SackFlour());
                this.Consume(4);
            }

            else if (IsChildOf(from.Backpack) && Amount < 4)
            {
                from.SendMessage("You need more wheat sheaves.");
            }

            else
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
        }
        public override async Task <TimeSpan> OnUse(Mobile from)
        {
            if (!from.ShilCheckSkill(Skill))
            {
                from.SendFailureMessage(500817); // You can see nothing hidden there.
                return(Delay);
            }

            var range = (int)(from.Skills.DetectHidden.Value / 15.0 * from.GetClassModifier(Skill));

            var eable         = from.GetMobilesInRange(range);
            var hiddenMobiles = eable.Where(mobile => TryDetect(from, mobile)).ToList();

            eable.Free();

            hiddenMobiles.ForEach(mobile =>
            {
                mobile.Hidden = false;
                mobile.SendFailureLocalOverHeadMessage(500814); // You have been revealed!
                from.SendSuccessPrivateOverHeadMessage(mobile, "You found someone!");
            });

            var itemEable = from.GetItemsInRange(range);

            foreach (var item in itemEable)
            {
                if (item is BaseTrap || item is TrapableContainer container && container.TrapType != TrapType.None)
                {
                    item.OnSingleClick(from);
                    item.LabelTo(from, 500851); // [trapped]
                }
            }

            var found = hiddenMobiles.Count + itemEable.Count();

            if (found == 0)
            {
                from.SendFailureMessage(500817); // You can see nothing hidden there.
            }
            itemEable.Free();

            return(Delay);
        }
Example #20
0
        public override void OnDoubleClick(Mobile from)
        {
            Guildstone stone = m_Stone as Guildstone;

            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else if (stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this)
            {
                from.SendLocalizedMessage(501197);                   // This teleporting object can not determine what guildstone to teleport
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt(from);

                if (house == null || house is Tent)
                {
                    from.SendLocalizedMessage(501138);                       // You can only place a guildstone in a house.
                }
                else if (!house.IsOwner(from))
                {
                    from.SendLocalizedMessage(501141);                       // You can only place a guildstone in a house you own!
                }
                else
                {
                    IPooledEnumerable eable = from.GetItemsInRange(1);
                    foreach (Item item in eable)
                    {
                        if (item is BaseDoor && (item.X == from.X || item.Y == from.Y) && item.Z - 5 < from.Z && item.Z + 5 > from.Z)
                        {
                            from.SendAsciiMessage("You cannot place this in front of a door.");
                            eable.Free();
                            return;
                        }
                    }
                    eable.Free();
                    m_Stone.MoveToWorld(from.Location, from.Map);
                    Delete();
                    stone.Guild.Teleporter = null;
                }
            }
        }
Example #21
0
        public static Totem GetTotem(Mobile m, TotemType totemtype)
        {
            if (m == null)
            {
                return(null);
            }

            ArrayList targets = new ArrayList();

            Map map = m.Map;

            if (map != null)
            {
                foreach (Item item in m.GetItemsInRange(15))
                {
                    if (item != null && m.CanSee(item) && item is Totem)
                    {
                        targets.Add(item);
                    }
                }
            }

            Totem chosen = null;

            for (int i = 0; i < targets.Count; ++i)
            {
                Totem totem = (Totem)targets[i];

                if (totem != null && totem.TotemType == totemtype)
                {
                    if (m.InRange(totem, totem.MaxRange))
                    {
                        if (chosen == null || chosen.Bonus < totem.Bonus)
                        {
                            chosen = totem;
                        }
                    }
                }
            }

            return(chosen);
        }
Example #22
0
        private static bool DoScan(Mobile m, GroundskeeperStatus al, ArrayList list)
        {
            al.LastScan = DateTime.Now;
            TimeSpan threshold = new TimeSpan(0, 3, 0);                         // age of item on the ground before we care
            int      trash     = 0;

            foreach (Item item in m.GetItemsInRange(12)) // 12 tiles?
            {                                            // is this trash? No LOS checks here because the manager won't be trying to pick it up
                if (Groundskeeper.IgnoreFilter(item, threshold))
                {
                    continue;
                }

                list.Add(item);                                                                 // add it
            }

            // post process list to allow things like a couple marked runes
            Groundskeeper.AllowFilter(list);
            trash = list.Count;                 // total trash after removing allowed items

            // Keep only representative items from different Zs by deleting all items except those with unique Zs
            ArrayList temp = new ArrayList();

            foreach (Item ix in list)
            {
                temp.Add(ix);
            }

            // only spawn 1 groundskeeper per Z plane and only when those Z planes are not within LOS.
            //	Example: a stack of scales will be on different Z panes, but within LOS (reachable by the same groundskeeper.)
            foreach (Item ix in temp)
            {
                if (!DifferentZ(list, ix as Item))
                {
                    list.Remove(ix);
                }
            }

            // did the scan find enough trash to pick up?
            //	if someone drops a handful of stuff (< 5 items), ignore it
            return(trash > 5);
        }
Example #23
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendMessage("This mine needs to be in your pack to setup.");
                return;
            }
            else
            {
                int mines = 0;

                foreach (Item m in from.GetItemsInRange(10))
                {
                    if (m is Landmine)
                    {
                        ++mines;
                    }
                }

                if (mines > 2)
                {
                    from.SendMessage("There are already too many landmines in the area!");
                }
                else if (!from.Region.AllowHarmful(from, from))
                {
                    from.SendMessage("That doesn't feel like a good idea.");
                    return;
                }
                else
                {
                    int Power = (int)(from.Skills[SkillName.RemoveTrap].Value / 2) + 24;

                    from.PlaySound(0x42);

                    Landmine mine = new Landmine(from, Power);
                    mine.Map      = from.Map;
                    mine.Location = from.Location;
                    this.Delete();
                    from.SendMessage("You place the landmine at your feet.");
                }
            }
        }
Example #24
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.Map == Map.Trammel && from.X < 1452 && from.X > 1439 && from.Y < 1631 && from.Y > 1621)
            {
                int runes = 0;

                ArrayList runic = new ArrayList();
                foreach (Item boulders in from.GetItemsInRange(20))
                {
                    if (boulders is RuneStoneGate)
                    {
                        ++runes;
                        runic.Add(boulders);
                    }
                }

                if (runes > 0)
                {
                    for (int i = 0; i < runic.Count; ++i)
                    {
                        Item item = ( Item )runic[i];

                        Item doorway = new UnderworldTeleporter();
                        doorway.MoveToWorld(item.Location, item.Map);

                        Effects.SendLocationEffect(doorway.Location, doorway.Map, 0x36B0, 30, 10, 0x837, 0);
                        Effects.PlaySound(doorway.Location, doorway.Map, 0x664);

                        item.Delete();
                    }
                    from.Say("In the name of Almric, open the gate to the Underworld!");
                }
                else
                {
                    from.SendMessage("The gate to the Underworld is already open.");
                }
            }
            else
            {
                from.SendMessage("This is the skull of the long dead Baron Almric.");
            }
        }
Example #25
0
        public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (m.PlaceInBackpack(item))
            {
                return(true);
            }

            if (!placeAtFeet)
            {
                return(false);
            }

            Map map = m.Map;

            if (map == null)
            {
                return(false);
            }

            ArrayList atFeet = new ArrayList();

            IPooledEnumerable eable = m.GetItemsInRange(0);

            foreach (Item obj in eable)
            {
                atFeet.Add(obj);
            }
            eable.Free();

            for (int i = 0; i < atFeet.Count; ++i)
            {
                Item check = (Item)atFeet[i];

                if (check.StackWith(m, item, false))
                {
                    return(true);
                }
            }

            item.MoveToWorld(m.Location, map);
            return(true);
        }
Example #26
0
        public static void TownSquareModifier(Mobile from, Skill skill, ref double gc)
        {
            // TODO: This should be replaced by a region check. bleh
            switch (skill.SkillName)
            {
            case SkillName.Alchemy:
            case SkillName.Blacksmith:
            case SkillName.Cartography:
            case SkillName.Carpentry:
            case SkillName.Cooking:
            case SkillName.Inscribe:
            case SkillName.Tailoring:
            case SkillName.Tinkering:
                break;

            default:
                return;                         // NOT BOOSTED
            }

            IPooledEnumerable eable = from.GetItemsInRange(MaximumRange);

            foreach (Item item in eable)
            {
                if (item is TownSquare && from.InRange(item.Location, ((TownSquare)item).ActiveRange))
                {
                    if (from is PlayerMobile)
                    {
                        var pm = from as PlayerMobile;
                        if (pm.LastTownSquareNotification + m_TimeBetweenNotifications < DateTime.Now)
                        {
                            from.SendMessage("You feel inspired by the presence of many great craftsmen.");
                            pm.LastTownSquareNotification = DateTime.Now;
                        }
                    }
                    gc *= 1.3;
                    eable.Free();
                    return;
                }
            }
            eable.Free();
        }
            protected override void OnTick()
            {
                ArrayList list = new ArrayList();

                foreach (Item m in m_Mobile.GetItemsInRange(15))
                {
                    if (m is AcidPool)
                    {
                        list.Add(m);
                    }
                }
                if (list.Count > 0 && m_Mobile.Alive)
                {
                    m_Mobile.Damage(Utility.Random(5));
                    m_Mobile.PlaySound(0x1dE);
                }
                else
                {
                    Stop();
                }
            }
Example #28
0
        public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (m.PlaceInBackpack(item))
            {
                return(true);
            }

            if (!placeAtFeet)
            {
                return(false);
            }

            Map map = m.Map;

            if (map == null)
            {
                return(false);
            }

            List <Item> atFeet = new List <Item>();

            foreach (Item obj in m.GetItemsInRange(0))
            {
                atFeet.Add(obj);
            }

            for (int i = 0; i < atFeet.Count; ++i)
            {
                Item check = atFeet[i];

                if (check.StackWith(m, item, false))
                {
                    return(true);
                }
            }

            item.MoveToWorld(m.Location, map);
            return(true);
        }
Example #29
0
            protected override void OnTick()
            {
                int count = 0;

                foreach (Item item in m_Mobile.GetItemsInRange(10))
                {
                    if (item is AcidPool)
                    {
                        count++;
                    }
                }

                if (count > 0 && m_Mobile.Alive)
                {
                    m_Mobile.Damage(Utility.Random(5));
                    m_Mobile.PlaySound(0x1DE);
                }
                else
                {
                    Stop();
                }
            }
        public static bool TooMuchSplatter(Mobile from)
        {
            int splatter = 0;

            foreach (Item i in from.GetItemsInRange(10))
            {
                if (i is MonsterSplatter)
                {
                    MonsterSplatter splat = (MonsterSplatter)i;
                    if (splat.owner != from)
                    {
                        splatter++;
                    }
                }
            }

            if (splatter > 16)
            {
                return(true);
            }

            return(false);
        }
Example #31
0
        public void Target(Mobile m)
        {
            if (!Caster.CanSee(m))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (CheckHSequence(m))
            {
                int damage = 1 + (int)((Caster.Skills[SkillName.Begging].Value / 5) + (Caster.Skills[SkillName.EvalInt].Value / 3));
                Caster.MovingParticles(m, 0x3818, 7, 0, false, false, 0xB44, 0, 0);
                Caster.PlaySound(0x025);
                Effects.SendLocationEffect(m.Location, m.Map, 0x23B2, 20, 0xB50, 0);

                if (Caster.Skills[SkillName.Begging].Value >= Utility.RandomMinMax(50, 300) && m != null)
                {
                    int goo = 0;

                    foreach (Item splash in m.GetItemsInRange(10))
                    {
                        if (splash is MonsterSplatter)
                        {
                            goo++;
                        }
                    }

                    if (goo == 0)
                    {
                        Point3D p = m.Location;
                        MonsterSplatter.AddSplatter(p.X, p.Y, p.Z, m.Map, p, Caster, "poisonous slime", 1167, 0);
                    }
                }

                AOS.Damage(m, Caster, damage, 50, 0, 0, 50, 0);
            }

            FinishSequence();
        }
Example #32
0
        public static void BritainTownSquareModifier(Mobile from, Skill skill, ref double gc)
        {
            IPooledEnumerable eable = from.GetItemsInRange(MaximumRange);

            foreach (Item item in eable)
            {
                if (item is BritainTownSquare && from.InRange(item.Location, ((BritainTownSquare)item).ActiveRange))
                {
                    if (from is PlayerMobile)
                    {
                        var pm = from as PlayerMobile;
                        if (pm.LastTownSquareNotification + m_TimeBetweenNotifications < DateTime.Now)
                        {
                            from.SendMessage("You feel your skills are quickly improving!");
                            pm.LastTownSquareNotification = DateTime.Now;
                        }
                    }
                    gc *= 1.5;
                    eable.Free();
                    return;
                }
            }
            eable.Free();
        }
Example #33
0
        public virtual bool CheckFeed( Mobile from, Item dropped )
        {
            if ( !IsDeadPet && Controlled && ( ControlMaster == from || IsPetFriend( from ) ) && ( dropped is Food || dropped is Gold || dropped is CookableFood || dropped is Head || dropped is LeftArm || dropped is LeftLeg || dropped is Torso || dropped is RightArm || dropped is RightLeg || dropped is IPetBooster ) )
            {
                Item f = dropped;

                if ( dropped is IPetBooster )
                {
                    IPetBooster pb = dropped as IPetBooster;

                    return pb.OnUsed( from, this );
                }
                else if ( CheckFoodPreference( f ) )
                {
                    int amount = f.Amount;

                    if ( amount > 0 )
                    {
                        bool happier = false;

                        int stamGain;

                        if ( f is Gold )
                            stamGain = amount - 50;
                        else
                            stamGain = ( amount * 15 ) - 50;

                        if ( stamGain > 0 )
                            Stam += stamGain;

                        if ( m_Loyalty != PetLoyalty.WonderfullyHappy )
                        {
                            m_Loyalty = PetLoyalty.WonderfullyHappy;
                            happier = true;
                        }

                        #region PetBondingGate
                        if ( TestCenter.Enabled )
                        {
                            if ( !IsBonded )
                            {
                                var overPetBondingGate = from.GetItemsInRange( 5 ).OfType<PetBondingGate>()
                                    .Any( pbg => pbg.Location == from.Location && pbg.Location == Location );

                                if ( overPetBondingGate )
                                {
                                    IsBonded = true;
                                    BondingBegin = DateTime.MinValue;
                                    from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
                                }
                            }
                        }
                        #endregion

                        if ( happier )
                            SayTo( from, 502060 ); // Your pet looks happier.

                        if ( Body.IsAnimal )
                            Animate( 3, 5, 1, true, false, 0 );
                        else if ( Body.IsMonster )
                            Animate( 17, 5, 1, true, false, 0 );

                        if ( IsBondable && !IsBonded )
                        {
                            Mobile master = m_ControlMaster;

                            if ( master != null && master == from )	//So friends can't start the bonding process
                            {
                                if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Base >= m_dMinTameSkill || this is SwampDragon || this is Ridgeback || this is SavageRidgeback || this is FireBeetle || this is LesserHiryu || this is IronBeetle )
                                {
                                    if ( BondingBegin == DateTime.MinValue )
                                    {
                                        BondingBegin = DateTime.Now;
                                    }
                                    else if ( ( BondingBegin + BondingDelay ) <= DateTime.Now )
                                    {
                                        IsBonded = true;
                                        BondingBegin = DateTime.MinValue;
                                        from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
                                    }
                                }
                                else
                                {
                                    from.SendLocalizedMessage( 1075268 ); // Your pet cannot form a bond with you until your animal taming ability has risen.
                                }
                            }
                        }

                        dropped.Delete();
                        return true;
                    }
                }
                else if ( !( dropped is Gold ) )
                {
                    SayTo( from, 1043257 ); // The animal shies away.
                }
            }

            return false;
        }
        public override void OnDoubleClick( Mobile from )
        {
            if( from == null || !from.InRange( this.Location, 2 ) || !from.InLOS( this.Location ) || !from.Alive || from.Paralyzed )
            {
                from.SendMessage( "You are too far away." );
                return;
            }

            if( m_Owner == null )
            {
                bool haschest = false;

                foreach( Item item in from.GetItemsInRange( 10 ) )
                {
                    if( item is BaseStorageContainer )
                    {
                        BaseStorageContainer cont = item as BaseStorageContainer;

                        if( cont.Owner == from )
                            haschest = true;
                    }
                }

                if( haschest )
                {
                    from.SendMessage( "You already have a storage box in this area." );
                    return;
                }

                Container pack = from.Backpack;

                if ( !pack.ConsumeTotal( typeof( Copper ), m_Price ) )
                {
                    from.SendMessage( "You need to be carrying " + m_Price + " copper coins in order to purchase this storage box." );
                }

                else
                {
                    m_Owner = from;
                    m_OwnersName = from.Name;

                    if( m_OwnersName.EndsWith( "s" ) )
                        m_OwnersName = m_OwnersName + "'";

                    else
                        m_OwnersName = m_OwnersName + "'s";

                    this.Name = "" + m_OwnersName + " Storage Box";

                    Key key = new Key();

                    uint newlock = Key.RandomValue();
                    this.KeyValue = newlock;
                    this.Locked = true;
                    key.KeyValue = newlock;
                    pack.DropItem( key );
                    this.LastRent = DateTime.Now;
                    from.SendMessage( "A key to the storage box has been placed in your backpack and " + m_Price + " copper coins have been charged from you." );

                    Copper copper = new Copper( m_Price );

                    if( this.Nation != Nation.None && this.AssignTreasury() )
                    {
                        if( this.Treasury is BaseContainer )
                            ( (BaseContainer)this.Treasury ).DropAndStack( copper );
                    }
                }
            }

            else
                base.OnDoubleClick( from );
        }
Example #35
0
		public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
		{
			if (m.PlaceInBackpack(item))
			{
				return true;
			}

			if (!placeAtFeet)
			{
				return false;
			}

			Map map = m.Map;

			if (map == null)
			{
				return false;
			}

			var list = m.GetItemsInRange(0);
			var atFeet = list.OfType<Item>().ToList();

			list.Free();

			if (atFeet.Any(check => check.StackWith(m, item, false)))
			{
				return true;
			}

			item.MoveToWorld(m.Location, map);
			return true;
		}
Example #36
0
		public void SmeltOre( Mobile from )
		{
			object forge = null;

			IPooledEnumerable eable = from.GetItemsInRange( 2 );

			foreach ( Item item in eable )
			{
				if ( IsForge( item ) )
				{
					forge = item;
					break;
				}
			}

			eable.Free();

			eable = from.GetMobilesInRange( 2 );

			foreach ( Mobile mob in eable )
			{
				if ( IsForge( mob ) )
				{
					forge = mob;
					break;
				}
			}

			eable.Free();

			if ( forge == null )
			{
				for ( int x = from.X-2;forge == null && x < from.X+2; x++ )
				{
					for ( int y = from.Y-2;forge == null &&  y < from.Y+2; y++ )
					{
						StaticTile[] tiles = from.Map.Tiles.GetStaticTiles( x, y, true );
						for ( int j = 0;forge == null && j < tiles.Length; j++ )
						{
							StaticTarget st = new StaticTarget( tiles[j], tiles[j].ID );
							if ( IsForge( st ) )
								forge = st;
						}
					}
				}
			}

			if ( forge != null )
			{
				double difficulty;

				switch ( Resource )
				{
					default: difficulty = 50.0; break;
					case CraftResource.DullCopper: difficulty = 65.0; break;
					case CraftResource.ShadowIron: difficulty = 70.0; break;
					case CraftResource.Copper: difficulty = 75.0; break;
					case CraftResource.Bronze: difficulty = 80.0; break;
					case CraftResource.Gold: difficulty = 85.0; break;
					case CraftResource.Agapite: difficulty = 90.0; break;
					case CraftResource.Verite: difficulty = 95.0; break;
					case CraftResource.Valorite: difficulty = 99.0; break;
				}

				double minSkill = difficulty - 25.0;
				double maxSkill = difficulty + 25.0;

				if ( difficulty > 50.0 && difficulty > from.Skills[SkillName.Mining].Value )
					from.SendLocalizedMessage( 501986 ); // You have no idea how to smelt this strange ore!
				//else if ( Amount <= 1 )
				//	from.SendLocalizedMessage( 501987 ); // There is not enough metal-bearing ore in this pile to make an ingot.
				else
				{
					/*
					int successes = 0;
					int count = Amount / 2;

					for ( int i = 0;i < count; i++ )
						if ( from.CheckTargetSkill( SkillName.Mining, forge, minSkill, maxSkill ) )
							successes++;

					Consume( count * 2 );

					if ( successes > 0 )
					{
						string[] locals = new string[3];

						BaseIngot ingot = GetIngot();
						ingot.Amount = successes;

						if ( Parent != from.Backpack && Parent is Container && RootParent == from && ((Container)Parent).TryDropItem( from, ingot, false ) ) //Its in a container, on the player
						{
							if ( locals[0] == null )
								locals[0] = "back in the same container";
						}
						else if ( from.AddToBackpack( ingot ) )
						{
							if ( locals[1] == null )
								locals[1] = "in your backpack";
						}
						else	if ( locals[2] == null )
								locals[2] = "on the floor";

						string localText = String.Empty;
						//Trimmed list
						List<string> localslist = new List<string>();
						for ( int i = 0;i < locals.Length; i++ )
							if ( locals[i] != null )
								localslist.Add( locals[i] );

						//We know there is at least ONE location
						localText = localslist[0];

						for ( int i = 1;i < localslist.Count; i++ )
							localText = String.Format( "{0},{1}{2}", localText, (i+1 < localslist.Count) ? " and" : " ", localslist[i] );

						from.SendMessage( "You smelt the ore removing the impurities and put the metal {0}.", localText );
					}
					else
						from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal.

					from.PlaySound( 0x2B ); // Smelting/Bellow noise
*/
					bool atcap = from.Skills[SkillName.Mining].Value > from.Skills[SkillName.Mining].Cap || from.Skills[SkillName.Mining].Value >= maxSkill;
					//int amountIngot = atcap ? (Amount / 2) : 1;
					//int amountOre = amountIngot * 2;
					int amountIngot = atcap ? Amount : 1;
					from.PlaySound( 0x2B ); // Smelting/Bellow noise

					if ( from.CheckTargetSkill( SkillName.Mining, forge, minSkill, maxSkill ) )
					{
						string[] locals = new string[3];

						BaseIngot ingot = GetIngot();
                        double chanceOfDoublingIronSmelt = from.Skills[SkillName.Mining].Value / 200.0; // 50% chance at 100
                        if (ingot.Resource == CraftResource.Iron && chanceOfDoublingIronSmelt > Utility.RandomDouble()) // per 10 skill, 5% chance of 2 ingots
                        {
                            ingot.Amount = amountIngot * 2;
                            from.SendMessage("You skillfully extract extra metal out of the ore pile.");
                        }
                        else
                        {
                            ingot.Amount = amountIngot;
                        }

						if ( Parent != from.Backpack && Parent is Container && RootParent == from && ((Container)Parent).TryDropItem( from, ingot, false ) ) //Its in a container, on the player
						{
							if ( locals[0] == null )
								locals[0] = "back in the same container";
						}
						else if ( from.AddToBackpack( ingot ) )
						{
							if ( locals[1] == null )
								locals[1] = "in your backpack";
						}
						else	if ( locals[2] == null )
								locals[2] = "on the floor";

						string localText = String.Empty;
						//Trimmed list
						List<string> localslist = new List<string>();
						for ( int i = 0;i < locals.Length; i++ )
							if ( locals[i] != null )
								localslist.Add( locals[i] );

						//We know there is at least ONE location
						localText = localslist[0];

						for ( int i = 1;i < localslist.Count; i++ )
							localText = String.Format( "{0},{1}{2}", localText, (i+1 < localslist.Count) ? " and" : " ", localslist[i] );

						from.SendMessage( "You smelt the ore removing the impurities and put the metal {0}.", localText );
						Consume( amountIngot );
					}
					else
					{
						Consume( Math.Max(amountIngot / 2, 1) );
						from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal.
					}
				}
			}
			else
				from.SendLocalizedMessage( 500420 ); // You are not near a forge.
		}
Example #37
0
		public static bool IsNearType(Mobile mob, Type type, int range)
		{
			bool mobs = type.IsSubclassOf(typeof(Mobile));
			bool items = type.IsSubclassOf(typeof(Item));

			IPooledEnumerable eable;

			if (mobs)
			{
				eable = mob.GetMobilesInRange(range);
			}
			else if (items)
			{
				eable = mob.GetItemsInRange(range);
			}
			else
			{
				return false;
			}

			if (eable.OfType<IEntity>().Any(e => e.TypeEquals(type)))
			{
				eable.Free();
				return true;
			}

			eable.Free();
			return false;
		}
Example #38
0
        public static bool IsNearType(Mobile mob, Type type, int range)
        {
            bool mobs = type.IsSubclassOf(typeof(Mobile));
            bool items = type.IsSubclassOf(typeof(Item));

            IPooledEnumerable eable;

            if (mobs)
                eable = mob.GetMobilesInRange(range);
            else if (items)
                eable = mob.GetItemsInRange(range);
            else
                return false;

            foreach (object obj in eable)
            {
                if (type.IsAssignableFrom(obj.GetType()))
                {
                    eable.Free();
                    return true;
                }
            }

            eable.Free();
            return false;
        }
Example #39
0
        public virtual bool Give(Mobile m, Item item, bool placeAtFeet)
        {
            if (m.PlaceInBackpack(item))
                return true;

            if (!placeAtFeet)
                return false;

            Map map = m.Map;

            if (map == null)
                return false;

            List<Item> atFeet = new List<Item>();

            foreach (Item obj in m.GetItemsInRange(0))
                atFeet.Add(obj);

            for (int i = 0; i < atFeet.Count; ++i)
            {
                Item check = atFeet[i];

                if (check.StackWith(m, item, false))
                    return true;
            }

            item.MoveToWorld(m.Location, map);
            return true;
        }
Example #40
0
		public bool VerifyPlacement( Mobile from, Rectangle2D area )
		{
			if( !from.CheckAlive() )
				return false;

			foreach( Item i in from.GetItemsInRange( 12 ) )
			{
				if( (i is TravelTent || i is TentAddon) && area.Contains( i ) )
					return false;
			}

			Region region = Region.Find( from.Location, from.Map );

			if( from.AccessLevel >= AccessLevel.GameMaster || region.AllowHousing( from, from.Location ) )
				return true;
			else if( !from.Map.CanFit( from.Location, 16 ) )
				return false;
			else if( region is TreasureRegion )
				return false;

			return (from.AccessLevel >= AccessLevel.GameMaster || region.AllowHousing( from, from.Location ));
		}
        public override void OnDoubleClick( Mobile from )
        {
            Guildstone stone = m_Stone as Guildstone;

            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if ( stone == null || stone.Deleted || stone.Guild == null || stone.Guild.Teleporter != this )
            {
                from.SendLocalizedMessage( 501197 ); // This teleporting object can not determine what guildstone to teleport
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt( from );

                if ( house == null || house is Tent )
                {
                    from.SendLocalizedMessage( 501138 ); // You can only place a guildstone in a house.
                }
                else if ( !house.IsOwner( from ) )
                {
                    from.SendLocalizedMessage( 501141 ); // You can only place a guildstone in a house you own!
                }
                else
                {
                    IPooledEnumerable eable = from.GetItemsInRange( 1 );
                    foreach ( Item item in eable )
                    {
                        if ( item is BaseDoor && ( item.X == from.X || item.Y == from.Y ) && item.Z - 5 < from.Z && item.Z + 5 > from.Z )
                        {
                            from.SendAsciiMessage( "You cannot place this in front of a door." );
                            eable.Free();
                            return;
                        }
                    }
                    eable.Free();
                    m_Stone.MoveToWorld( from.Location, from.Map );
                    Delete();
                    stone.Guild.Teleporter = null;
                }
            }
        }