Beispiel #1
0
		public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds )
		{
			for ( int i = 0; i < m_Facets.Length; ++i )
			{
				Rectangle2D area = new Rectangle2D();
				bool isValid = false;

				for ( int j = 0; j < 10; ++j )
				{
					area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height );

					if ( !CheckWeatherConflict( m_Facets[i], null, area ) )
						isValid = true;

					if ( isValid )
						break;
				}

				if ( !isValid )
					continue;

				Weather w = new Weather( m_Facets[i], new Rectangle2D[]{ area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) );

				w.m_Bounds = bounds;
				w.m_MoveSpeed = moveSpeed;
			}
		}
        public static void Create2DElement(String name, String texture, Vector2 TopLeft, Vector2 BottomRight)
        {
            MaterialPtr material = MaterialManager.Singleton.Create(name, "General");
                material.GetTechnique(0).GetPass(0).CreateTextureUnitState(texture);
                material.GetTechnique(0).GetPass(0).DepthCheckEnabled = false;
                material.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;
                material.GetTechnique(0).GetPass(0).LightingEnabled = false;
                // Create background rectangle covering the whole screen
                Rectangle2D rect = new Rectangle2D(true);
                rect.SetCorners(TopLeft.x * 2 - 1, 1 - TopLeft.y * 2, BottomRight.x * 2 - 1, 1 - BottomRight.y * 2);
                //rect.SetCorners(-1.0f, 1.0f, 1.0f, -1.0f);
                rect.SetMaterial(name);

                // Render the background before everything else
                rect.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

                // Use infinite AAB to always stay visible
                AxisAlignedBox aab = new AxisAlignedBox();
                aab.SetInfinite();
                rect.BoundingBox = aab;

                // Attach background to the scene
                SceneNode node = _OgreEngine.mMgr.RootSceneNode.CreateChildSceneNode("2D__" + name);
                node.AttachObject(rect);
        }
		/// <summary>
		/// Test whether label collides.
		/// </summary>
		/// <param name="newLabel"></param>
		/// <returns>true if label collided with another (more important or earlier) label</returns>
		public Boolean SimpleCollisionTest(Label2D newLabel)
		{
			if (labelList.Contains(newLabel))
			{
				return false;
			}

			Size2D newSize = TextRenderer.MeasureString(newLabel.Text, newLabel.Font);
			newSize = new Size2D(newSize.Width + 2 * newLabel.CollisionBuffer.Width, newSize.Height + 2 * newLabel.CollisionBuffer.Height);
			Rectangle2D newRect = new Rectangle2D(new Point2D(newLabel.Location.X - newLabel.CollisionBuffer.Width, newLabel.Location.Y - newLabel.CollisionBuffer.Height), newSize);

			foreach (Label2D label in labelList)
			{
				Size2D size = TextRenderer.MeasureString(label.Text, label.Font);
				size = new Size2D(size.Width + 2*label.CollisionBuffer.Width, size.Height + 2*label.CollisionBuffer.Height);
				Rectangle2D rect =
					new Rectangle2D(
						new Point2D(label.Location.X - newLabel.CollisionBuffer.Width, label.Location.Y - label.CollisionBuffer.Height),
						size);

				if (newRect.Intersects(rect))
				{
					return true;
				}
			}

			labelList.Add(newLabel);

			return false;
		}
Beispiel #4
0
		public PresetMapEntry( int name, int width, int height, int xLeft, int yTop, int xRight, int yBottom )
		{
			m_Name = name;
			m_Width = width;
			m_Height = height;
			m_Bounds = new Rectangle2D( xLeft, yTop, xRight - xLeft, yBottom - yTop );
		}
Beispiel #5
0
		public ConfirmTentPlacementGump( Mobile owner, TentAddon tent, TentFlap flap, TentBedroll roll, SecureTentChest chest, Rectangle2D bounds )
			: base( 10, 10 )
		{
			m_Owner = owner;
			m_Tent = tent;
			m_Flap = flap;
			m_Bedroll = roll;
			m_Chest = chest;
			m_RegionBounds = bounds;

			Closable = false;
			Disposable = false;
			Resizable = false;
			Dragable = true;

			AddPage( 1 );
			AddBackground( 10, 10, 325, 305, 9250 );
			AddImageTiled( 25, 25, 295, 11, 50 );
			AddLabel( 90, 35, 0, "Confirm Tent Placement" );

			AddButton( 35, 275, 4020, 4022, 0, GumpButtonType.Reply, 1 ); //Cancel
			AddButton( 280, 275, 4023, 4025, 1, GumpButtonType.Reply, 1 ); //Ok

			AddHtml( 27, 75, 290, 200, String.Format( "<center>You are about to place a travel tent.</center><br> Within, you will find a bedroll "
													 + "and a secure wooden chest.<br> To repack your tent, or to logout safely, double-click "
													 + "your bedroll. When doing so, please make sure that all items are removed from the chest."
													 + "<br> Please press okay to continue, or press cancel to stop tent placement." ), false, false );
		}
        public void Rectangle2DEqualityTests()
        {
            Rectangle2D r1 = new Rectangle2D();
            Rectangle2D r2 = Rectangle2D.Empty;
            Rectangle2D r3 = Rectangle2D.Zero;
            Rectangle2D r4 = new Rectangle2D(0, 0, 0, 0);
            Rectangle2D r5 = new Rectangle2D(9, 10, -5, -6);
            Rectangle2D r6 = new Rectangle2D(0, 0, 10, 10);
            Rectangle2D r7 = new Rectangle2D(new Point2D(0, 0), new Size2D(10, 10));

            Assert.Equal(r1, r2);
            Assert.NotEqual(r1, r3);
            Assert.Equal(r3, r4);
            Assert.NotEqual(r1, r5);
            Assert.NotEqual(r3, r5);
            Assert.Equal(r6, r7);

            IMatrixD v1 = r1;
            IMatrixD v2 = r2;
            IMatrixD v3 = r3;
            IMatrixD v4 = r4;
            IMatrixD v5 = r5;

            Assert.Equal(v1, v2);
            Assert.NotEqual(v1, v3);
            Assert.Equal(v3, v4);
            Assert.NotEqual(v1, v5);
            Assert.NotEqual(v3, v5);

            Assert.Equal(v5, r5);
        }
		public StrongholdDefinition( Rectangle2D[] area, Point3D joinStone, Point3D factionStone, Point3D[] monoliths )
		{
			m_Area = area;
			m_JoinStone = joinStone;
			m_FactionStone = factionStone;
			m_Monoliths = monoliths;
		}
        public CrateRectangle(GenericReader reader)
        {
            int version = reader.ReadInt();

            Rectangle = reader.ReadRect2D();
            FirstDirection = (Direction)reader.ReadInt();
            SecondDirection = (Direction)reader.ReadInt();
        }
Beispiel #9
0
		/*public override bool AllowReds{ get{ return true; } }*/

		public SafeZone( Rectangle2D area, Point3D goloc, Map map, bool isGuarded ) : base( null, map, SafeZonePriority, area )
		{
			GoLocation = goloc;

			this.Disabled = !isGuarded;

			Register();
		}
Beispiel #10
0
		private static Point3D RandomPointIn( Rectangle2D rect, Map map )
		{
			int x = Utility.Random( rect.X, rect.Width );
			int y = Utility.Random( rect.Y, rect.Height );
			int z = map.GetAverageZ( x, y );

			return new Point3D( x, y, z );
		}
Beispiel #11
0
		public SerpentPillar( string word, Rectangle2D destination, bool active ) : base( 0x233F )
		{
			Movable = false;

			m_Active = active;
			m_Word = word;
			m_Destination = destination;
		}
 public ViewBoundsChanedEventArgs(Rectangle2D oldViewBounds, Rectangle2D newViewBounds)
 {
     if (oldViewBounds != null)
     {
         _oldViewBounds = new Rectangle2D(oldViewBounds);
     }
     if (_newViewBounds != null)
     {
         _newViewBounds = new Rectangle2D(newViewBounds);
     }
 }
 internal PolygonElementClip(Rectangle2D clipBox)
 {
     this.boundary = clipBox;
     this.Edges = new Edge[]
     {
         new Edge { IsHorisontal = false, IsLeft = true, Value = this.boundary.Left },
         new Edge { IsHorisontal = false, IsLeft = false, Value = this.boundary.Right },
         new Edge { IsHorisontal = true, IsLeft = true, Value = this.boundary.Bottom },
         new Edge { IsHorisontal = true, IsLeft = false, Value = this.boundary.Top }
     };
 }
Beispiel #14
0
		public TentValidator( Mobile owner, TentAddon tent, TentBedroll bedroll, SecureTentChest chest, TravelTentRegion region, Rectangle2D bounds )
			: base( 0x12B3 )
		{
			Name = "travel tent validator";
			Movable = false;
			Visible = false;

			m_Owner = owner;
			m_Tent = tent;
			m_Bedroll = bedroll;
			m_Chest = chest;
			m_Region = region;
			m_Bounds = bounds;
		}
        public void IntersectsTest()
        {
            Rectangle2D r1 = Rectangle2D.Empty;
            Rectangle2D r2 = Rectangle2D.Zero;
            Rectangle2D r3 = new Rectangle2D(0, 0, 10, 10);
            Rectangle2D r4 = new Rectangle2D(new Point2D(5, 5), new Size2D(10, 10));

            Assert.False(r1.Intersects(Rectangle2D.Empty));
            Assert.False(r1.Intersects(r2));
            Assert.False(r2.Intersects(r1));
            Assert.True(r2.Intersects(r3));
            Assert.True(r3.Intersects(r4));
            Assert.True(r4.Intersects(r4));
        }
		public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			try
			{
				object[] states = (object[])state;
				BaseCommand command = (BaseCommand)states[0];
				string[] args = (string[])states[1];

				Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

				if ( !CheckObjectTypes( command, ext, out items, out mobiles ) )
					return;

				IPooledEnumerable eable;

				if ( items && mobiles )
					eable = map.GetObjectsInBounds( rect );
				else if ( items )
					eable = map.GetItemsInBounds( rect );
				else if ( mobiles )
					eable = map.GetMobilesInBounds( rect );
				else
					return;

				ArrayList objs = new ArrayList();

				foreach ( object obj in eable )
				{
					if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
						continue;

					if ( ext.IsValid( obj ) )
						objs.Add( obj );
				}

				eable.Free();

				ext.Filter( objs );

				RunCommand( from, objs, command, args );
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
Beispiel #17
0
        public Weather(Map facet, Rectangle2D[] area, int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, TimeSpan interval)
        {
            this.m_Facet = facet;
            this.m_Area = area;
            this.m_Temperature = temperature;
            this.m_ChanceOfPercipitation = chanceOfPercipitation;
            this.m_ChanceOfExtremeTemperature = chanceOfExtremeTemperature;

            List<Weather> list = GetWeatherList(facet);

            if (list != null)
                list.Add(this);

            Timer.DelayCall(TimeSpan.FromSeconds((0.2 + (Utility.RandomDouble() * 0.8)) * interval.TotalSeconds), interval, new TimerCallback(OnTick));
        }
Beispiel #18
0
		public override void OnDoubleClick( Mobile from )
		{
			Point2D start = new Point2D( from.X - 3, from.Y - 3 );
			Point2D end = new Point2D( from.X + 3, from.Y + 3 );

			m_Bounds = new Rectangle2D( start, end );

			if( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042001 ); //That must be in your pack to use it.
			}
			else if( AlreadyOwnTent( from ) )
			{
				from.SendMessage( "You already have a tent established." );
			}
			else if( from.HasGump( typeof( ConfirmTentPlacementGump ) ) )
			{
				from.CloseGump( typeof( ConfirmTentPlacementGump ) );
			}
			else if( from.Combatant != null )
			{
				from.SendMessage( "You can't place a tent while fighting!" );
			}
			else if( VerifyPlacement( from, m_Bounds ) )
			{
				TentAddon tent = new TentAddon();
				tent.MoveToWorld( new Point3D( from.X, from.Y, from.Z ), from.Map );

				TentFlap flap = new TentFlap( from, this );
				flap.MoveToWorld( new Point3D( from.X + 2, from.Y, from.Z ), from.Map );

				SecureTentChest chest = new SecureTentChest( from );
				chest.MoveToWorld( new Point3D( from.X - 1, from.Y - 2, from.Z ), from.Map );

				TentBedroll roll = new TentBedroll( from, tent, flap, chest );
				roll.MoveToWorld( new Point3D( from.X, from.Y + 1, from.Z ), from.Map );

				from.SendGump( new ConfirmTentPlacementGump( from, tent, flap, roll, chest, m_Bounds ) );

				this.Delete();
			}
			else
			{
				from.SendMessage( "You cannot place a tent in this area." );
			}
		}
		private void BoundingBox_Callback( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			Utility.FixPoints( ref start, ref end );
			Rectangle2D rect = new Rectangle2D(start, end);
			_map = map;
		
			_rects.Add(new Rect2D(rect.Start.X, rect.Start.Y, rect.Width, rect.Height));

			if(_args.MultipleRects)
			{
				_picker.Begin( this.Mobile, new BoundingBoxCallback( BoundingBox_Callback ), null );
			}
			else
			{
				ExtractItems();
			}
		}
 internal PolygonElementClip(Rectangle2D clipBox)
 {
     if (Rectangle2D.IsNullOrEmpty(clipBox))
     {
         boundary = Rectangle2D.Empty;
     }
     else
     {
         this.boundary = clipBox;
     }
     this.Edges = new Edge[] 
     {   
         new Edge { IsHorisontal = false, IsLeft = true, Value = this.boundary.Left },
         new Edge { IsHorisontal = false, IsLeft = false, Value = this.boundary.Right },
         new Edge { IsHorisontal = true, IsLeft = true, Value = this.boundary.Bottom }, 
         new Edge { IsHorisontal = true, IsLeft = false, Value = this.boundary.Top }
     };
 }
Beispiel #21
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			if( version >= 1 )
			{
				m_Owner = reader.ReadMobile();
				m_Tent = reader.ReadItem() as TentAddon;
				m_Bedroll = reader.ReadItem() as TentBedroll;
				m_Chest = reader.ReadItem() as SecureTentChest;
				m_Bounds = reader.ReadRect2D();

				if( m_Owner != null && m_Chest != null && m_Tent != null )
					m_Region = new TravelTentRegion( m_Owner, m_Chest, m_Tent.Map, m_Bounds, 16 );
			}
		}
        public void CompareTest()
        {
            Rectangle2D r1 = Rectangle2D.Empty;
            Rectangle2D r2 = Rectangle2D.Zero;
            Rectangle2D r3 = new Rectangle2D(0, 0, 10, 10);
            Rectangle2D r4 = new Rectangle2D(new Point2D(11, -11), new Size2D(10, 10));
            Rectangle2D r5 = new Rectangle2D(new Point2D(-11, -11), new Size2D(10, 10));
            Rectangle2D r6 = new Rectangle2D(new Point2D(11, 11), new Size2D(10, 10));

            Assert.Equal(0, r1.CompareTo(Rectangle2D.Empty));
            Assert.Equal(-1, r1.CompareTo(r2));
            Assert.Equal(1, r2.CompareTo(r1));
            Assert.Equal(0, r3.CompareTo(r3));
            Assert.Equal(0, r3.CompareTo(r2));
            Assert.Equal(-1, r4.CompareTo(r3));
            Assert.Equal(-1, r5.CompareTo(r3));
            Assert.Equal(1, r6.CompareTo(r3));
        }
Beispiel #23
0
		public void SetDisplay( int x1, int y1, int x2, int y2, int w, int h )
		{
			Width = w;
			Height = h;

			if ( x1 < 0 )
				x1 = 0;

			if ( y1 < 0 )
				y1 = 0;

			if ( x2 >= 5120 )
				x2 = 5119;

			if ( y2 >= 4096 )
				y2 = 4095;

			Bounds = new Rectangle2D( x1, y1, x2-x1, y2-y1 );
		}
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 2:
                    {
                        m_GameItems = reader.ReadStrongItemList();
                        m_WinnerLocation = reader.ReadPoint3D();
                        goto case 1;
                    }
                case 1:
                    {
                        m_GameArea = reader.ReadRect2D();
                        break;
                    }
            }
        }
Beispiel #25
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 ));
		}
Beispiel #26
0
        public HouseRaffleStone()
            : base(0xEDD)
        {
            this.m_Region = null;
            this.m_Bounds = new Rectangle2D();
            this.m_Facet = null;

            this.m_Winner = null;
            this.m_Deed = null;

            this.m_Active = false;
            this.m_Started = DateTime.MinValue;
            this.m_Duration = DefaultDuration;
            this.m_ExpireAction = HouseRaffleExpireAction.None;
            this.m_TicketPrice = DefaultTicketPrice;

            this.m_Entries = new List<RaffleEntry>();

            this.Movable = false;

            m_AllStones.Add(this);
        }
Beispiel #27
0
        public static void DoWipe(Mobile from, Map map, Point3D start, Point3D end, WipeType type)
        {
            CommandLogging.WriteLine(from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format(from), start, end, type, map);

            bool mobiles = ((type & WipeType.Mobiles) != 0);
            bool multis = ((type & WipeType.Multis) != 0);
            bool items = ((type & WipeType.Items) != 0);

            List<IEntity> toDelete = new List<IEntity>();

            Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

            IPooledEnumerable eable;

            if ((items || multis) && mobiles)
                eable = map.GetObjectsInBounds(rect);
            else if (items || multis)
                eable = map.GetItemsInBounds(rect);
            else if (mobiles)
                eable = map.GetMobilesInBounds(rect);
            else
                return;

            foreach (IEntity obj in eable)
            {
                if (items && (obj is Item) && !((obj is BaseMulti) || (obj is HouseSign)))
                    toDelete.Add(obj);
                else if (multis && (obj is BaseMulti))
                    toDelete.Add(obj);
                else if (mobiles && (obj is Mobile) && !((Mobile)obj).Player)
                    toDelete.Add(obj);
            }

            eable.Free();

            for (int i = 0; i < toDelete.Count; ++i)
                toDelete[i].Delete();
        }
Beispiel #28
0
        public VendorSearchMap(PlayerVendor vendor, Item item) : base(vendor.Map)
        {
            Vendor = vendor;
            SearchItem = item;

            LootType = LootType.Blessed;

            Width = 400;
            Height = 400;

            Bounds = new Rectangle2D(vendor.X - 100, vendor.Y - 100, 200, 200);
            AddWorldPin(vendor.X, vendor.Y);

            if (vendor.Map == Map.Malas)
                Hue = 1102;
            else if (vendor.Map == Map.Trammel)
                Hue = 50;
            else if (vendor.Map == Map.Tokuno)
                Hue = 1154;

            DeleteTime = DateTime.UtcNow + TimeSpan.FromMinutes(30);
            Timer.DelayCall(TimeSpan.FromMinutes(30), Delete);
        }
Beispiel #29
0
        public static Point3D FindLocation(Map map)
        {
            if (map == null || map == Map.Internal)
            {
                return(Point3D.Zero);
            }

            Rectangle2D[] regions;

            if (map == Map.Felucca || map == Map.Trammel)
            {
                regions = m_BritRegions;
            }
            else if (map == Map.Ilshenar)
            {
                regions = m_IlshRegions;
            }
            else if (map == Map.Malas)
            {
                regions = m_MalasRegions;
            }
            else
            {
                regions = new Rectangle2D[] { new Rectangle2D(0, 0, map.Width, map.Height) }
            };

            if (regions.Length == 0)
            {
                return(Point3D.Zero);
            }

            for (int i = 0; i < 50; ++i)
            {
                Rectangle2D reg = regions[Utility.Random(regions.Length)];
                int         x   = Utility.Random(reg.X, reg.Width);
                int         y   = Utility.Random(reg.Y, reg.Height);

                if (!ValidateDeepWater(map, x, y))
                {
                    continue;
                }

                bool valid = true;

                for (int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5)
                {
                    if (!ValidateDeepWater(map, x + offset, y + offset))
                    {
                        valid = false;
                    }
                    else if (!ValidateDeepWater(map, x + offset, y - offset))
                    {
                        valid = false;
                    }
                    else if (!ValidateDeepWater(map, x - offset, y + offset))
                    {
                        valid = false;
                    }
                    else if (!ValidateDeepWater(map, x - offset, y - offset))
                    {
                        valid = false;
                    }
                }

                if (valid)
                {
                    return(new Point3D(x, y, 0));
                }
            }

            return(Point3D.Zero);
        }
Beispiel #30
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            m_DamageEntries = new Dictionary <Mobile, int>();

            int version = reader.ReadInt();

            switch (version)
            {
            case 5:
            {
                int    entries = reader.ReadInt();
                Mobile m;
                int    damage;
                for (int i = 0; i < entries; ++i)
                {
                    m      = reader.ReadMobile();
                    damage = reader.ReadInt();

                    if (m == null)
                    {
                        continue;
                    }

                    m_DamageEntries.Add(m, damage);
                }

                goto case 4;
            }

            case 4:
            {
                m_ConfinedRoaming = reader.ReadBool();
                m_Idol            = reader.ReadItem <IdolOfTheChampion>();
                m_HasBeenAdvanced = reader.ReadBool();

                goto case 3;
            }

            case 3:
            {
                m_SpawnArea = reader.ReadRect2D();

                goto case 2;
            }

            case 2:
            {
                m_RandomizeType = reader.ReadBool();

                goto case 1;
            }

            case 1:
            {
                if (version < 3)
                {
                    int oldRange = reader.ReadInt();

                    m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange), new Point2D(X + oldRange, Y + oldRange));
                }

                m_Kills = reader.ReadInt();

                goto case 0;
            }

            case 0:
            {
                if (version < 1)
                {
                    m_SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24));                                    //Default was 24
                }
                bool active = reader.ReadBool();
                m_Type         = (ChampionSpawnType)reader.ReadInt();
                m_Creatures    = reader.ReadStrongMobileList();
                m_RedSkulls    = reader.ReadStrongItemList();
                m_WhiteSkulls  = reader.ReadStrongItemList();
                m_Platform     = reader.ReadItem <ChampionPlatform>();
                m_Altar        = reader.ReadItem <ChampionAltar>();
                m_ExpireDelay  = reader.ReadTimeSpan();
                m_ExpireTime   = reader.ReadDeltaTime();
                m_Champion     = reader.ReadMobile();
                m_RestartDelay = reader.ReadTimeSpan();

                if (reader.ReadBool())
                {
                    m_RestartTime = reader.ReadDeltaTime();
                    BeginRestart(m_RestartTime - DateTime.Now);
                }

                if (version < 4)
                {
                    m_Idol = new IdolOfTheChampion(this);
                    m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map);
                }

                if (m_Platform == null || m_Altar == null || m_Idol == null)
                {
                    Delete();
                }
                else if (active)
                {
                    Start();
                }

                break;
            }
            }

            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(UpdateRegion));
        }
Beispiel #31
0
        public static void SpawnCreatures(Mobile m, double difficulty)
        {
            BaseBoat boat = BaseBoat.FindBoatAt(m.Location, m.Map);

            Type[] types = GetCreatureType(m, boat != null);

            if (types == null)
            {
                return;
            }

            int amount = Utility.RandomMinMax(3, 5);

            for (int i = 0; i < amount; i++)
            {
                BaseCreature bc = Activator.CreateInstance(types[Utility.Random(types.Length)]) as BaseCreature;

                if (bc != null)
                {
                    if (KrampusEncounterActive)
                    {
                        bc.Name = "An Icy Creature";
                    }

                    Rectangle2D zone;

                    if (boat != null)
                    {
                        if (boat.Facing == Direction.North || boat.Facing == Direction.South)
                        {
                            if (Utility.RandomBool())
                            {
                                zone = new Rectangle2D(boat.X - 7, m.Y - 4, 3, 3);
                            }
                            else
                            {
                                zone = new Rectangle2D(boat.X + 4, m.Y - 4, 3, 3);
                            }
                        }
                        else
                        {
                            if (Utility.RandomBool())
                            {
                                zone = new Rectangle2D(m.X + 4, boat.Y - 7, 3, 3);
                            }
                            else
                            {
                                zone = new Rectangle2D(m.X + 4, boat.Y + 4, 3, 3);
                            }
                        }
                    }
                    else
                    {
                        zone = new Rectangle2D(m.X - 3, m.Y - 3, 6, 6);
                    }

                    Point3D p = m.Location;

                    if (m.Map != null)
                    {
                        for (int j = 0; j < 25; j++)
                        {
                            Point3D check = m.Map.GetRandomSpawnPoint(zone);

                            if (CanFit(check.X, check.Y, check.Z, m.Map, bc))
                            {
                                p = check;
                                break;
                            }
                        }
                    }

                    foreach (Skill sk in bc.Skills.Where(s => s.Base > 0))
                    {
                        sk.Base += sk.Base * (difficulty);
                    }

                    bc.RawStr += (int)(bc.RawStr * difficulty);
                    bc.RawInt += (int)(bc.RawInt * difficulty);
                    bc.RawDex += (int)(bc.RawDex * difficulty);

                    if (bc.HitsMaxSeed == -1)
                    {
                        bc.HitsMaxSeed = bc.RawStr;
                    }

                    if (bc.StamMaxSeed == -1)
                    {
                        bc.StamMaxSeed = bc.RawDex;
                    }

                    if (bc.ManaMaxSeed == -1)
                    {
                        bc.ManaMaxSeed = bc.RawInt;
                    }

                    bc.HitsMaxSeed += (int)(bc.HitsMaxSeed * difficulty);
                    bc.StamMaxSeed += (int)(bc.StamMaxSeed * difficulty);
                    bc.ManaMaxSeed += (int)(bc.ManaMaxSeed * difficulty);

                    bc.Hits = bc.HitsMaxSeed;
                    bc.Stam = bc.RawDex;
                    bc.Mana = bc.RawInt;

                    bc.PhysicalResistanceSeed += (int)(bc.PhysicalResistanceSeed * (difficulty / 3));
                    bc.FireResistSeed         += (int)(bc.FireResistSeed * (difficulty / 3));
                    bc.ColdResistSeed         += (int)(bc.ColdResistSeed * (difficulty / 3));
                    bc.PoisonResistSeed       += (int)(bc.PoisonResistSeed * (difficulty / 3));
                    bc.EnergyResistSeed       += (int)(bc.EnergyResistSeed * (difficulty / 3));

                    bc.IsAmbusher = true;

                    if (Ambushers == null)
                    {
                        Ambushers = new Dictionary <BaseCreature, DateTime>();
                    }

                    Ambushers.Add(bc, DateTime.UtcNow + TimeSpan.FromMinutes(AmbusherDelete));

                    bc.MoveToWorld(p, m.Map);
                    Timer.DelayCall(() => bc.Combatant = m);
                }
            }

            m.LocalOverheadMessage(Server.Network.MessageType.Regular, 1150, 1155479); // *Your keen senses alert you to an incoming ambush of attackers!*
            m.SendLocalizedMessage(1049330, "", 0x22);                                 // You have been ambushed! Fight for your honor!!!
        }
Beispiel #32
0
        public override void AddGumpLayout()
        {
            AddPage(0);
            AddImage(0, 0, 0x9C49);

            AddButton(36, 97, Category == StoreCategory.Featured ? 0x9C5F : 0x9C55, 0x9C5F, 100, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 100, 125, 25, 1114513, "#1156587", 0x7FFF, false, false); // Featured

            AddButton(36, 126, Category == StoreCategory.Character ? 0x9C5F : 0x9C55, 0x9C5F, 101, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 129, 125, 25, 1114513, "#1156588", 0x7FFF, false, false); // Character

            AddButton(36, 155, Category == StoreCategory.Equipment ? 0x9C5F : 0x9C55, 0x9C5F, 102, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 158, 125, 25, 1114513, "#1078237", 0x7FFF, false, false); // Equipment

            AddButton(36, 184, Category == StoreCategory.Decorations ? 0x9C5F : 0x9C55, 0x9C5F, 103, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 187, 125, 25, 1114513, "#1044501", 0x7FFF, false, false); // Decorations

            AddButton(36, 213, Category == StoreCategory.Mounts ? 0x9C5F : 0x9C55, 0x9C5F, 104, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 216, 125, 25, 1114513, "#1154981", 0x7FFF, false, false); // Mounts

            AddButton(36, 242, Category == StoreCategory.Misc ? 0x9C5F : 0x9C55, 0x9C5F, 105, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 245, 125, 25, 1114513, "#1011173", 0x7FFF, false, false); // Miscellaneous

            AddButton(36, 271, 0x9C55, 0x9C5F, 106, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 274, 125, 25, 1114513, "#1156589", 0x7FFF, false, false); // Promotional Code

            AddButton(36, 300, 0x9C55, 0x9C5F, 107, GumpButtonType.Reply, 0);
            AddHtmlLocalized(36, 303, 125, 25, 1114513, "#1156875", 0x7FFF, false, false); // FAQ

            AddImage(36, 331, 0x9C4A);

            AddHtmlLocalized(36, 334, 125, 25, 1114513, "#1044580", 0x2945, false, false); // Sort By

            AddButton(43, 360, SortBy == SortBy.Name ? 0x9C4F : 0x9C4E, SortBy == SortBy.Name ? 0x9C4F : 0x9C4E, 108, GumpButtonType.Reply, 0);
            AddHtmlLocalized(68, 360, 88, 25, 1037013, 0x6B55, false, false); // Name

            AddButton(43, 386, SortBy == SortBy.PriceLower ? 0x9C4F : 0x9C4E, SortBy == SortBy.PriceLower ? 0x9C4F : 0x9C4E, 109, GumpButtonType.Reply, 0);
            AddHtmlLocalized(68, 386, 88, 25, 1062218, 0x6B55, false, false); // Price Down
            AddImage(110, 386, 0x9C60);

            AddButton(43, 412, SortBy == SortBy.PriceHigher ? 0x9C4F : 0x9C4E, SortBy == SortBy.PriceHigher ? 0x9C4F : 0x9C4E, 110, GumpButtonType.Reply, 0);
            AddHtmlLocalized(68, 412, 88, 25, 1062218, 0x6B55, false, false); // Price Up
            AddImage(110, 412, 0x9C61);

            AddButton(43, 438, SortBy == SortBy.Newest ? 0x9C4F : 0x9C4E, SortBy == SortBy.Newest ? 0x9C4F : 0x9C4E, 111, GumpButtonType.Reply, 0);
            AddHtmlLocalized(68, 438, 88, 25, 1156590, 0x6B55, false, false); // Newest

            AddButton(43, 464, SortBy == SortBy.Oldest ? 0x9C4F : 0x9C4E, SortBy == SortBy.Oldest ? 0x9C4F : 0x9C4E, 112, GumpButtonType.Reply, 0);
            AddHtmlLocalized(68, 464, 88, 25, 1156591, 0x6B55, false, false); // Oldest

            AddButton(598, 36, Category == StoreCategory.Cart ? 0x9C5E : 0x9C54, 0x9C5E, 113, GumpButtonType.Reply, 0);
            AddHtmlLocalized(628, 39, 123, 25, 1156593, String.Format("{0}\t{1}", UltimaStore.CartCount(User).ToString(), UltimaStore.MaxCart.ToString()), 0x7FFF, false, false);

            AddBackground(167, 516, 114, 22, 0x2486);
            AddTextEntry(167, 516, 114, 20, 0, 0, "");
            AddButton(286, 516, 0x9C52, 0x9C5C, 114, GumpButtonType.Reply, 0);
            AddHtmlLocalized(286, 519, 64, 22, 1114513, "#1154641", 0x7FFF, false, false); // Search

            AddImage(36, 74, 0x9C56);
            AddLabelCropped(59, 74, 100, 14, 0x1C7, ((int)UltimaStore.GetCurrency(User)).ToString("N0"));

            if (!Search && Category == StoreCategory.Cart)
            {
                var profile = UltimaStore.GetProfile(User);

                AddImage(167, 74, 0x9C4C);
                double total = 0;

                if (profile != null && profile.Cart != null && profile.Cart.Count > 0)
                {
                    int i = 0;
                    foreach (var kvp in profile.Cart)
                    {
                        var entry  = kvp.Key;
                        int amount = kvp.Value;
                        total += entry.Cost * amount;
                        int index = UltimaStore.Entries.IndexOf(entry);

                        if (entry.Name[0].Number > 0)
                        {
                            AddHtmlLocalized(175, 84 + (35 * i), 256, 25, entry.Name[0].Number, 0x6B55, false, false);
                        }
                        else
                        {
                            AddHtml(175, 84 + (35 * i), 256, 25, Color(C16232(0x6B55), entry.Name[0].String), false, false);
                        }

                        AddButton(431, 81 + (35 * i), 0x9C52, 0x9C5C, index + 2000, GumpButtonType.Reply, 0);

                        AddLabelCropped(457, 82 + (35 * i), 38, 22, 0x9C2, amount.ToString());
                        AddLabelCropped(531, 82 + (35 * i), 100, 14, 0x1C7, (entry.Cost * amount).ToString("N0"));

                        AddButton(653, 81 + (35 * i), 0x9C52, 0x9C5C, index + 3000, GumpButtonType.Reply, 0);
                        AddHtmlLocalized(653, 84 + (35 * i), 64, 22, 1114513, "#1011403", 0x7FFF, false, false); // Remove

                        AddImage(175, 109 + (35 * i), 0x9C4D);

                        i++;
                    }
                }

                AddHtmlLocalized(508, 482, 125, 25, 1156594, 0x6B55, false, false); // Subtotal:
                AddImage(588, 482, 0x9C56);
                AddLabelCropped(611, 480, 100, 14, 0x1C7, UltimaStore.GetSubTotal(Cart).ToString("N0"));

                AddButton(653, 516, 0x9C52, 0x9C52, 115, GumpButtonType.Reply, 0);
                AddHtmlLocalized(653, 519, 64, 22, 1114513, "#1062219", 0x7FFF, false, false); // Buy
            }
            else
            {
                if (Search)
                {
                    StoreList = UltimaStore.GetSortedList(SearchText);
                    UltimaStore.SortList(StoreList, SortBy);

                    if (StoreList.Count == 0)
                    {
                        User.SendLocalizedMessage(1154587, "", 1281); // No items matched your search.
                        return;
                    }
                }

                int listIndex = Page * 6;
                int pageIndex = 0;
                int pages     = (int)Math.Ceiling((double)StoreList.Count / 6);

                for (int i = listIndex; i < StoreList.Count && pageIndex < 6; i++)
                {
                    var entry = StoreList[i];
                    int x     = _Offset[pageIndex][0];
                    int y     = _Offset[pageIndex][1];

                    AddButton(x, y, 0x9C4B, 0x9C4B, i + 1000, GumpButtonType.Reply, 0);

                    if (entry.Tooltip > 0)
                    {
                        AddTooltip(entry.Tooltip);
                    }
                    else
                    {
                        Item item = UltimaStore.UltimaStoreContainer.FindDisplayItem(entry.ItemType);

                        if (item != null)
                        {
                            AddItemProperty(item);
                        }
                    }

                    if (IsFeatured(entry))
                    {
                        AddImage(x, y + 189, 0x9C58);
                    }

                    for (int j = 0; j < entry.Name.Length; j++)
                    {
                        if (entry.Name[j].Number > 0)
                        {
                            AddHtmlLocalized(x, y + (j * 14) + 4, 183, 25, 1114513, String.Format("#{0}", entry.Name[j].Number.ToString()), 0x7FFF, false, false);
                        }
                        else
                        {
                            AddHtml(x, y + (j * 14) + 4, 183, 25, ColorAndCenter("#FFFFFF", entry.Name[j].String), false, false);
                        }
                    }

                    if (entry.ItemID > 0)
                    {
                        Rectangle2D b = ItemBounds.Table[entry.ItemID];
                        AddItem((x + 91) - b.Width / 2 - b.X, (y + 108) - b.Height / 2 - b.Y, entry.ItemID, entry.Hue);
                    }
                    else
                    {
                        AddImage((x + 91) - 72, (y + 108) - 72, entry.GumpID);
                    }

                    AddImage(x + 60, y + 192, 0x9C56);
                    AddLabelCropped(x + 80, y + 190, 143, 25, 0x9C2, entry.Cost.ToString("N0"));

                    pageIndex++;
                    listIndex++;
                }

                if (Page + 1 < pages)
                {
                    AddButton(692, 516, 0x9C51, 0x9C5B, 116, GumpButtonType.Reply, 0);
                }

                if (Page > 0)
                {
                    AddButton(648, 516, 0x9C50, 0x9C5A, 117, GumpButtonType.Reply, 0);
                }
            }

            if (Configuration.ShowCurrencyType)
            {
                AddHtml(43, 496, 120, 16, Color("#FFFFFF", "Currency:"), false, false);
                AddHtml(43, 518, 120, 16, Color("#FFFFFF", Configuration.CurrencyName), false, false);
            }
        }
Beispiel #33
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            m_DamageEntries = new Dictionary <Mobile, int>();

            int version = reader.ReadInt();

            switch (version)
            {
            case 7:
            {
                this.m_ExpireDelay = reader.ReadTimeSpan();
                this.m_ExpireTime  = reader.ReadDeltaTime();

                goto case 6;
            }

            case 6:
            {
                this.m_Champion2 = reader.ReadMobile();

                goto case 5;
            }

            case 5:
            {
                int    entries = reader.ReadInt();
                Mobile m;
                int    damage;
                for (int i = 0; i < entries; ++i)
                {
                    m      = reader.ReadMobile();
                    damage = reader.ReadInt();

                    if (m == null)
                    {
                        continue;
                    }

                    this.m_DamageEntries.Add(m, damage);
                }

                goto case 4;
            }

            case 4:
            {
                this.m_ConfinedRoaming = reader.ReadBool();
                this.m_HasBeenAdvanced = reader.ReadBool();

                goto case 3;
            }

            case 3:
            {
                this.m_SpawnArea = reader.ReadRect2D();

                goto case 2;
            }

            case 2:
            {
                this.m_RandomizeType = reader.ReadBool();

                goto case 1;
            }

            case 1:
            {
                this.m_Kills = reader.ReadInt();
                Spwnd        = reader.ReadInt();

                goto case 0;
            }

            case 0:
            {
                bool active = reader.ReadBool();
                this.m_Type         = (MiniChampType)reader.ReadInt();
                this.m_Creatures    = reader.ReadStrongMobileList();
                this.m_Champion     = reader.ReadMobile();
                this.m_RestartDelay = reader.ReadTimeSpan();

                if (reader.ReadBool())
                {
                    this.m_RestartTime = reader.ReadDeltaTime();
                    BeginRestart(this.m_RestartTime - DateTime.Now);
                }

                if (active)
                {
                    this.Start();
                }

                break;
            }
            }

            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(UpdateRegion));
        }
Beispiel #34
0
        public void SetDisplay(int x1, int y1, int x2, int y2, int w, int h, Map map)
        {
            Width      = w;
            Height     = h;
            DisplayMap = map;

            if (x1 < 0)
            {
                x1 = 0;
            }

            if (y1 < 0)
            {
                y1 = 0;
            }

            #region SA
            if (x2 > Map.Maps[map.MapID].Width)
            {
                x2 = Map.Maps[map.MapID].Width;
            }

            if (y2 > Map.Maps[map.MapID].Height)
            {
                y2 = Map.Maps[map.MapID].Height;
            }

            if (map == Map.Trammel || map == Map.Felucca)
            {
                if (x2 >= 5120)
                {
                    x2 = 5119;
                }

                if (y2 >= 4096)
                {
                    y2 = 4095;
                }
            }
            else if (map == Map.Ilshenar)
            {
                // fyi, ilshenar's dungeons are not drawn on the map even at maximum size.

                if (x2 > 2304)
                {
                    x2 = 2304;
                }

                if (y2 > 1600)
                {
                    y2 = 1600;
                }
            }
            else if (map == Map.Malas)
            {
                if (x2 > 2560)
                {
                    x2 = 2560;
                }

                if (y2 > 2048)
                {
                    y2 = 2048;
                }
            }
            else if (map == Map.Tokuno)
            {
                if (x2 > 1448)
                {
                    x2 = 1448;
                }

                if (y2 > 1448)
                {
                    y2 = 1448;
                }
            }
            else if (map == Map.TerMur)
            {
                if (x2 > 1280)
                {
                    x2 = 1280;
                }

                if (y2 > 4096)
                {
                    y2 = 4096;
                }
            }
            #endregion

            Bounds = new Rectangle2D(x1, y1, x2 - x1, y2 - y1);
        }
Beispiel #35
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 8:
            {
                m_MinimumDuelers = (int)reader.ReadInt();
                m_LastReset      = (DateTime)reader.ReadDateTime();
                goto case 7;
            }

            case 7:
            {
                m_TimerEnabled = (bool)reader.ReadBool();
                goto case 6;
            }

            case 6:
            {
                m_CoinsPerRound = (int)reader.ReadInt();
                m_CoinsWinner   = (int)reader.ReadInt();
                goto case 5;
            }

            case 5:
            {
                m_BroadcastHue = (int)reader.ReadInt();
                goto case 4;
            }

            case 4:
            {
                m_WallHue = (int)reader.ReadInt();
                m_WallID  = (int)reader.ReadInt();
                goto case 3;
            }

            case 3:
            {
                m_WallMidPoint     = (Point3D)reader.ReadPoint3D();
                m_WallExtendWidth  = (int)reader.ReadInt();;
                m_WallNorthToSouth = (bool)reader.ReadBool();
                goto case 2;
            }

            case 2:
            {
                m_CurrentRound      = (int)reader.ReadInt();
                m_TotalParticipants = (int)reader.ReadInt();
                goto case 1;
            }

            case 1:
            {
                m_Running          = (bool)reader.ReadBool();
                m_AcceptingPlayers = (bool)reader.ReadBool();
                m_MapLocation      = (Map)reader.ReadMap();
                goto case 0;
            }

            case 0:
            {
                m_EventRate     = (TimeSpan)reader.ReadTimeSpan();
                m_StartLocation = (Point3D)reader.ReadPoint3D();
                m_LostLocation  = (Point3D)reader.ReadPoint3D();
                m_DuelLocation1 = (Point3D)reader.ReadPoint3D();
                m_DuelLocation2 = (Point3D)reader.ReadPoint3D();
                m_LastEvent     = (DateTime)reader.ReadDateTime();

                m_DuelingArea  = (Rectangle2D)reader.ReadRect2D();
                m_StageingArea = (Rectangle2D)reader.ReadRect2D();
                m_ViewingArea  = (Rectangle2D)reader.ReadRect2D();
                break;
            }
            }
            if (version == 7)
            {
                m_LastReset = DateTime.UtcNow;
            }

            if (version == 5)
            {
                m_CoinsPerRound = 2;
                m_CoinsWinner   = 10;
            }

            if (version == 4)
            {
                m_BroadcastHue = 269;
            }

            if (version == 3)
            {
                m_WallHue = 0;
                m_WallID  = 0x0081;
            }

            if (m_DuelList == null)
            {
                m_DuelList = new List <Mobile>();
            }
            if (m_CurrentDuelers == null)
            {
                m_CurrentDuelers = new List <Mobile>();
            }
            if (m_WallList == null)
            {
                m_WallList = new List <Item>();
            }
            if (m_BroadcastList == null)
            {
                m_BroadcastList = new List <Mobile>();
            }
            m_CountDown = 0;
            UpdateRegions(false);

            m_RestartTimer = new InternalTimer(this, TimeSpan.FromSeconds(1.0));

            if (m_TimerEnabled)
            {
                m_RestartTimer.Start();
            }
        }
Beispiel #36
0
        public void Initialize(int page)
        {
            m_Page = page;

            CAGNode[] nodes = m_Category.Nodes;

            int count = nodes.Length - page * EntryCount;

            if (count < 0)
            {
                count = 0;
            }
            else if (count > EntryCount)
            {
                count = EntryCount;
            }

            int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);

            AddPage(0);

            AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID);
            AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight,
                          OffsetGumpID);

            int x = BorderSize + OffsetSize;
            int y = BorderSize + OffsetSize;

            if (OldStyle)
            {
                AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID);
            }
            else
            {
                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
            }

            if (m_Category.Parent != null)
            {
                AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1);

                if (PrevLabel)
                {
                    AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
                }
            }

            x += PrevWidth + OffsetSize;

            int emptyWidth = TotalWidth - PrevWidth * 2 - NextWidth - OffsetSize * 5 -
                             (OldStyle ? SetWidth + OffsetSize : 0);

            if (!OldStyle)
            {
                AddImageTiled(x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight,
                              EntryGumpID);
            }

            AddHtml(x + TextOffsetX, y + (EntryHeight - 20) / 2, emptyWidth - TextOffsetX, EntryHeight,
                    $"<center>{m_Category.Caption}</center>");

            x += emptyWidth + OffsetSize;

            if (OldStyle)
            {
                AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID);
            }
            else
            {
                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
            }

            if (page > 0)
            {
                AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2);

                if (PrevLabel)
                {
                    AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
                }
            }

            x += PrevWidth + OffsetSize;

            if (!OldStyle)
            {
                AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
            }

            if ((page + 1) * EntryCount < nodes.Length)
            {
                AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1);

                if (NextLabel)
                {
                    AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
                }
            }

            for (int i = 0, index = page * EntryCount; i < EntryCount && index < nodes.Length; ++i, ++index)
            {
                x  = BorderSize + OffsetSize;
                y += EntryHeight + OffsetSize;

                CAGNode node = nodes[index];

                AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
                AddLabelCropped(x + TextOffsetX, y + (EntryHeight - 20) / 2, EntryWidth - TextOffsetX, EntryHeight, TextHue,
                                node.Caption);

                x += EntryWidth + OffsetSize;

                if (SetGumpID != 0)
                {
                    AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                }

                AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4);

                if (node is CAGObject obj)
                {
                    int itemID = obj.ItemID;

                    Rectangle2D bounds = ItemBounds.Table[itemID];

                    if (itemID != 1 && bounds.Height < EntryHeight * 2)
                    {
                        if (bounds.Height < EntryHeight)
                        {
                            AddItem(x - OffsetSize - 22 - i % 2 * 44 - bounds.Width / 2 - bounds.X,
                                    y + EntryHeight / 2 - bounds.Height / 2 - bounds.Y, itemID);
                        }
                        else
                        {
                            AddItem(x - OffsetSize - 22 - i % 2 * 44 - bounds.Width / 2 - bounds.X,
                                    y + EntryHeight - 1 - bounds.Height - bounds.Y, itemID);
                        }
                    }
                }
            }
        }
Beispiel #37
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                m_DeadLine  = reader.ReadDateTime();
                m_Boss      = reader.ReadMobile();
                m_Activated = reader.ReadBool();
                m_Active    = reader.ReadBool();
                m_WarpPoint = reader.ReadPoint3D();

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Item map = reader.ReadItem();

                    if (map != null && !map.Deleted && map is CorgulIslandMap)
                    {
                        m_IslandMaps.Add(map);
                        ((CorgulIslandMap)map).Altar = this;
                    }
                }

                break;
            }

            case 0:
            {
                m_DeadLine  = reader.ReadDateTime();
                m_Boss      = reader.ReadMobile();
                m_Activated = reader.ReadBool();
                m_Active    = reader.ReadBool();
                m_WarpPoint = reader.ReadPoint3D();
                //m_IslandMap = reader.ReadItem() as CorgulIslandMap;
                Item item = reader.ReadItem();
                break;
            }
            }

            InitializeBossRegion();

            if (m_Active && m_Activated && m_WarpPoint != Point3D.Zero)
            {
                if (m_DeadLine < DateTime.UtcNow || m_Boss == null || m_Boss.Deleted)
                {
                    Reset();
                }
                else
                {
                    Rectangle2D bounds = GetRectangle(m_WarpPoint);
                    m_WarpRegion = new CorgulWarpRegion(this, bounds);
                    m_WarpRegion.Register();

                    m_DeadLineTimer = Timer.DelayCall(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), OnTick);
                }
            }
        }
        public void Spawn(PlunderZone zone, int amount)
        {
            Map map = Map.Trammel;

            if (zone == PlunderZone.Fel)
            {
                map = Map.Felucca;
            }
            else if (zone > PlunderZone.Fel)
            {
                map = Map.Tokuno;
            }

            for (int i = 0; i < amount; i++)
            {
                Rectangle2D rec = _Zones[(int)zone];
                Point3D     p;

                while (true)
                {
                    p = map.GetRandomSpawnPoint(rec); //new Point3D(rec.X + Utility.Random(rec.Width), rec.Y + Utility.RandomMinMax(rec.Start.X, rec.Height), -5);

                    if (p.Z != -5)
                    {
                        p.Z = -5;
                    }

                    Rectangle2D bounds = new Rectangle2D(p.X - 7, p.Y - 7, 15, 15);

                    bool badSpot = false;

                    for (int x = bounds.Start.X; x <= bounds.Start.X + bounds.Width; x++)
                    {
                        for (int y = bounds.Start.Y; y <= bounds.Start.Y + bounds.Height; y++)
                        {
                            if (BaseBoat.FindBoatAt(new Point3D(x, y, -5), map) != null || !SpecialFishingNet.ValidateDeepWater(map, x, y))
                            {
                                badSpot = true;
                                break;
                            }
                        }

                        if (badSpot)
                        {
                            break;
                        }
                    }

                    if (!badSpot)
                    {
                        IPooledEnumerable eable = map.GetMobilesInBounds(bounds);

                        foreach (Mobile m in eable)
                        {
                            if (m.AccessLevel == AccessLevel.Player)
                            {
                                badSpot = true;
                                break;
                            }
                        }

                        eable.Free();

                        if (!badSpot)
                        {
                            PlunderBeaconAddon beacon = new PlunderBeaconAddon();
                            beacon.MoveToWorld(p, map);

                            PlunderBeacons[zone].Add(beacon);
                            break;
                        }
                    }
                }
            }
        }
Beispiel #39
0
 public SerpentPillar(string word, Rectangle2D destination) : this(word, destination, true)
 {
 }
Beispiel #40
0
        public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            try
            {
                object[]    states  = (object[])state;
                BaseCommand command = (BaseCommand)states[0];
                string[]    args    = (string[])states[1];

                Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(command, ext, out items, out mobiles))
                {
                    return;
                }

                IPooledEnumerable eable;

                if (items && mobiles)
                {
                    eable = map.GetObjectsInBounds(rect);
                }
                else if (items)
                {
                    eable = map.GetItemsInBounds(rect);
                }
                else if (mobiles)
                {
                    eable = map.GetMobilesInBounds(rect);
                }
                else
                {
                    return;
                }

                ArrayList objs = new ArrayList();

                foreach (object obj in eable)
                {
                    if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj))
                    {
                        continue;
                    }

                    if (ext.IsValid(obj))
                    {
                        objs.Add(obj);
                    }
                }

                eable.Free();

                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Beispiel #41
0
        public void SpawnMerchantAndGalleon(SpawnZone zone, Map map)
        {
            SpawnDefinition def = m_Zones[zone];

            if (map != Map.Internal && map != null)
            {
                Rectangle2D rec  = def.SpawnRegion;
                bool        garg = Utility.RandomBool();
                BaseGalleon gal;
                Point3D     p       = Point3D.Zero;
                bool        spawned = false;

                if (garg)
                {
                    gal = new GargishGalleon(Direction.North);
                }
                else
                {
                    gal = new TokunoGalleon(Direction.North);
                }

                MerchantCaptain captain = new MerchantCaptain(gal);

                for (int i = 0; i < 25; i++)
                {
                    int x = Utility.Random(rec.X, rec.Width);
                    int y = Utility.Random(rec.Y, rec.Height);
                    p = new Point3D(x, y, -5);

                    if (gal.CanFit(p, map, gal.ItemID))
                    {
                        spawned = true;
                        break;
                    }
                }

                if (!spawned)
                {
                    gal.Delete();
                    captain.Delete();
                    return;
                }

                gal.Owner    = captain;
                captain.Zone = zone;
                gal.MoveToWorld(p, map);
                gal.AutoAddCannons(captain);
                captain.MoveToWorld(new Point3D(gal.X, gal.Y - 1, gal.ZSurface), map);

                int crewCount = Utility.RandomMinMax(3, 5);

                for (int i = 0; i < crewCount; i++)
                {
                    Mobile crew = new MerchantCrew();
                    captain.AddToCrew(crew);
                    crew.MoveToWorld(new Point3D(gal.X + Utility.RandomList(-1, 1), gal.Y + Utility.RandomList(-1, 0, 1), gal.ZSurface), map);
                }

                Point2D[] course = def.GetRandomWaypoints();
                gal.BoatCourse = new BoatCourse(gal, new List <Point2D>(def.GetRandomWaypoints()));

                gal.NextNavPoint = 0;
                gal.StartCourse(false, false);

                FillHold(gal);

                m_ActiveZones[zone].Add(captain);
            }
        }
Beispiel #42
0
            public AnimalFormGump(Mobile caster, AnimalFormEntry[] entries, AnimalForm spell)
                : base(50, 50)
            {
                m_Caster = caster;
                m_Spell  = spell;

                AddPage(0);

                AddBackground(0, 0, 520, 404, 0x13BE);
                AddImageTiled(10, 10, 500, 20, 0xA40);
                AddImageTiled(10, 40, 500, 324, 0xA40);
                AddImageTiled(10, 374, 500, 20, 0xA40);
                AddAlphaRegion(10, 10, 500, 384);

                AddHtmlLocalized(14, 12, 500, 20, 1063394, 0x7FFF); // <center>Polymorph Selection Menu</center>

                AddButton(10, 374, 0xFB1, 0xFB2, 0);
                AddHtmlLocalized(45, 376, 450, 20, 1011012, 0x7FFF); // CANCEL

                double ninjitsu = caster.Skills.Ninjitsu.Value;

                int current = 0;

                for (int i = 0; i < entries.Length; ++i)
                {
                    bool enabled = ninjitsu >= entries[i].ReqSkill && BaseFormTalisman.EntryEnabled(caster, entries[i].Type);

                    int page = current / 10 + 1;
                    int pos  = current % 10;

                    if (pos == 0)
                    {
                        if (page > 1)
                        {
                            AddButton(400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page);
                            AddHtmlLocalized(440, 376, 60, 20, 1043353, 0x7FFF); // Next
                        }

                        AddPage(page);

                        if (page > 1)
                        {
                            AddButton(300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
                            AddHtmlLocalized(340, 376, 60, 20, 1011393, 0x7FFF); // Back
                        }
                    }

                    if (!enabled)
                    {
                        continue;
                    }

                    int x = pos % 2 == 0 ? 14 : 264;
                    int y = pos / 2 * 64 + 44;

                    Rectangle2D b = ItemBounds.Table[entries[i].ItemID];

                    AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entries[i].ItemID,
                                        entries[i].Hue, 40 - b.Width / 2 - b.X, 30 - b.Height / 2 - b.Y, entries[i].Tooltip);
                    AddHtmlLocalized(x + 84, y, 250, 60, entries[i].Name, 0x7FFF);

                    current++;
                }
            }
            protected override void OnTick()
            {
                m_Count--;

                if (m_Count >= 1)
                {
                    if (m_Item.m_Running)
                    {
                        m_Item.PublicOverheadMessage(MessageType.Regular, 906, true, (m_Count).ToString());
                    }
                    else
                    {
                        Stop();
                    }
                }

                if (m_Count == 0) // Complete
                {
                    Rectangle2D rect1 = new Rectangle2D(m_Item.m_FirstNW.X, m_Item.m_FirstNW.Y,
                                                        m_Item.m_FirstSE.X - m_Item.m_FirstNW.X + 1,
                                                        m_Item.m_FirstSE.Y - m_Item.m_FirstNW.Y + 1);
                    Rectangle2D rect2 = new Rectangle2D(m_Item.m_SecondNW.X, m_Item.m_SecondNW.Y,
                                                        m_Item.m_SecondSE.X - m_Item.m_SecondNW.X + 1,
                                                        m_Item.m_SecondSE.Y - m_Item.m_SecondNW.Y + 1);
                    Rectangle2D rect3 = new Rectangle2D(m_Item.m_ThirdNW.X, m_Item.m_ThirdNW.Y,
                                                        m_Item.m_ThirdSE.X - m_Item.m_ThirdNW.X + 1,
                                                        m_Item.m_ThirdSE.Y - m_Item.m_ThirdNW.Y + 1);
                    Rectangle2D rect4 = new Rectangle2D(m_Item.m_FourthNW.X, m_Item.m_FourthNW.Y,
                                                        m_Item.m_FourthSE.X - m_Item.m_FourthNW.X + 1,
                                                        m_Item.m_FourthSE.Y - m_Item.m_FourthNW.Y + 1);

                    #region Amount of boxes

                    int boxtodie;

                    switch (m_Boxes)
                    {
                    case 1:
                        boxtodie = 1;
                        break;

                    case 2:
                        boxtodie = Utility.Random(1, 2);
                        break;

                    case 3:
                        boxtodie = Utility.Random(1, 3);
                        break;

                    case 4:
                        boxtodie = Utility.Random(1, 4);
                        break;

                    default:
                        boxtodie = Utility.Random(1, 4);
                        break;
                    }

                    #endregion

                    #region Box to die

                    Rectangle2D rect;

                    switch (boxtodie)
                    {
                    case 1:
                        rect = rect1;
                        break;

                    case 2:
                        rect = rect2;
                        break;

                    case 3:
                        rect = rect3;
                        break;

                    case 4:
                        rect = rect4;
                        break;

                    default:
                        rect = rect1;
                        break;
                    }

                    #endregion

                    List <Mobile>     toKill = new List <Mobile>();
                    IPooledEnumerable eable  = m_Item.m_MapDest.GetMobilesInBounds(rect);

                    foreach (Mobile m in eable)
                    {
                        toKill.Add(m);
                    }

                    eable.Free();

                    if (toKill.Count == 0)
                    {
                        m_From.PlaySound(1050);
                        m_Item.PublicOverheadMessage(MessageType.Regular, 906, true, string.Format("Noone was killed!"));
                        m_Item.m_Running = false;
                        return;
                    }

                    #region Deathtype

                    int deathtype        = Utility.Random(5);
                    int deathsoundmale   = Utility.RandomList(1059, 1060, 1061, 1063, 346, 347, 348, 349);
                    int deathsoundfemale = Utility.RandomList(788, 789, 790, 791, 336, 337, 338, 339);

                    try
                    {
                        foreach (Mobile m in toKill)
                        {
                            if (m == null || !m.Alive)
                            {
                                continue;
                            }

                            //Add effects here
                            switch (deathtype)
                            {
                            case 0:     //Flamestrike death
                                m.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot);
                                m.PlaySound(0x208);
                                break;

                            case 1:     //Explosion death
                                m.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head);
                                m.PlaySound(519);
                                break;

                            case 2:     //Electrocution
                                m.FixedParticles(14276, 40, 50, 5044, EffectLayer.Head);
                                m.PlaySound(756);
                                new KillTimer(m).Start();
                                break;

                            case 3:     //Saw trap
                                m.FixedParticles(0x11AD, 40, 30, 5044, EffectLayer.CenterFeet);
                                m.PlaySound(0x21C);
                                break;

                            case 4:     //Lightning
                                m.BoltEffect(0);
                                break;
                            }

                            if (deathtype != 2)
                            {
                                if (m.CanBeDamaged())
                                {
                                    if (m.BodyValue == 0x190)
                                    {
                                        m.PlaySound(deathsoundmale);
                                    }
                                    else if (m.BodyValue == 0x191)
                                    {
                                        m.PlaySound(deathsoundfemale);
                                    }
                                }

                                m.Kill();
                            }
                        }
                    }
                    catch
                    {
                        m_Item.PublicOverheadMessage(MessageType.Regular, 906, true, string.Format("An error occured"));
                    }

                    #endregion

                    toKill.Clear();
                    m_Item.m_Running = false;
                }
            }
Beispiel #44
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 3:
            {
                m_State = (HouseRaffleState)reader.ReadEncodedInt();

                goto case 2;
            }

            case 2:
            {
                m_ExpireAction = (HouseRaffleExpireAction)reader.ReadEncodedInt();

                goto case 1;
            }

            case 1:
            {
                m_Deed = reader.ReadItem <HouseRaffleDeed>();

                goto case 0;
            }

            case 0:
            {
                bool oldActive = (version < 3) ? reader.ReadBool() : false;

                m_Bounds = reader.ReadRect2D();
                m_Facet  = reader.ReadMap();

                m_Winner = reader.ReadMobile();

                m_TicketPrice = reader.ReadInt();
                m_Started     = reader.ReadDateTime();
                m_Duration    = reader.ReadTimeSpan();

                int entryCount = reader.ReadInt();
                m_Entries = new List <RaffleEntry>(entryCount);

                for (int i = 0; i < entryCount; i++)
                {
                    RaffleEntry entry = new RaffleEntry(reader, version);

                    if (entry.From == null)
                    {
                        continue;         // Character was deleted
                    }
                    m_Entries.Add(entry);
                }

                InvalidateRegion();

                m_AllStones.Add(this);

                if (version < 3)
                {
                    if (oldActive)
                    {
                        m_State = HouseRaffleState.Active;
                    }
                    else if (m_Winner != null)
                    {
                        m_State = HouseRaffleState.Completed;
                    }
                    else
                    {
                        m_State = HouseRaffleState.Inactive;
                    }
                }

                break;
            }
            }
        }
Beispiel #45
0
 public override Rectangle2D ReadRect2D()
 {
     return(Rectangle2D.Parse(ReadValue <string>()));
 }
Beispiel #46
0
        public virtual bool CanMoveTo(Point3D p, Map map)
        {
            //don't allow the carpet to travel to places where you can't recall to
            if (!Server.Spells.SpellHelper.CheckTravel(map, p, Server.Spells.TravelCheckType.RecallTo))
            {
                return(false);
            }

            int zcheck = p.Z + _Extrema.Start.Z;

            for (int i = p.X + _Extrema.Start.X; i < p.X + _Extrema.End.X; i++)
            {
                for (int j = p.Y + _Extrema.Start.Y; j < p.Y + _Extrema.End.Y; j++)
                {
                    //first check the map and see if there is a problem there
                    if (map.GetAverageZ(i, j) >= zcheck)
                    {
                        return(false);
                    }

                    //check if the map tile is considered a "no fly tile"
                    int tileid = map.Tiles.GetLandTile(i, j).ID;

                    foreach (int nomovetile in NoMoveTiles)
                    {
                        if (nomovetile == tileid)
                        {
                            return(false);
                        }
                    }

                    //next check for multi's

                    //3rd parameter "true" checks multi's as well.
                    StaticTile[] tiles = map.Tiles.GetStaticTiles(i, j, true);



                    //check all static tiles
                    foreach (StaticTile tile in tiles)
                    {
                        if (tile.Z + tile.Height >= zcheck)
                        {
                            return(false);
                        }
                    }
                }
            }


            //finally, check for items and mobiles

            Rectangle2D destrect2d = new Rectangle2D(new Point2D(p.X + _Extrema.Start.X, p.Y + _Extrema.Start.Y), new Point2D(p.X + _Extrema.End.X, p.Y + _Extrema.End.Y));

            IPooledEnumerable ie = map.GetMobilesInBounds(destrect2d);

            foreach (Mobile m in ie)
            {
                //ignore mobiles already inside the addon
                if (Contains(m))
                {
                    continue;
                }
                //mobiles have a height of about 14?
                if (m.Z + 14 >= zcheck && m.Z < p.Z + _Extrema.End.Z)
                {
                    return(false);
                }
            }
            ie.Free();

            ie = map.GetItemsInBounds(destrect2d);

            foreach (Item item in ie)
            {
                //ignore items already in the addon, or that are part of the addon
                if (Contains(item) || item is MovableAddonComponent && _Components.IndexOf((MovableAddonComponent)item) != -1)
                {
                    continue;
                }

                ItemData itemData = TileData.ItemTable[item.ItemID & 0x3FFF];
                TileFlag flags    = itemData.Flags;

                //if the item is defined as impassible
                if ((flags & TileFlag.Impassable) != 0)
                {
                    int height = itemData.CalcHeight + 1;

                    //this forces it so you can't overlap movable addon components!
                    if (item is MovableAddonComponent)
                    {
                        height = 20;
                    }

                    if (item.Z + height >= zcheck && item.Z < p.Z + _Extrema.End.Z)
                    {
                        return(false);
                    }
                }
            }
            ie.Free();

            return(true);
        }
            protected override void OnTarget(Mobile m, object o)
            {
                IPoint3D point = (IPoint3D)o;

                if (c_Contract == null || c_Contract.ParentHouse == null)
                {
                    return;
                }

                if (!c_Contract.ParentHouse.Region.Contains(new Point3D(point.X, point.Y, point.Z)))
                {
                    m.SendMessage("You must target within the home.");
                    m.Target = new InternalTarget(c_Gump, c_Contract, c_Type, c_BoundOne);
                    return;
                }

                switch (c_Type)
                {
                case TargetType.SignLoc:
                    c_Contract.SignLoc = new Point3D(point.X, point.Y, point.Z);
                    c_Contract.ShowSignPreview();
                    c_Gump.NewGump();
                    break;

                case TargetType.MinZ:
                    if (!c_Contract.ParentHouse.Region.Contains(new Point3D(point.X, point.Y, point.Z)))
                    {
                        m.SendMessage("That isn't within your house.");
                    }
                    else if (c_Contract.HasContractedArea(point.Z))
                    {
                        m.SendMessage("That area is already taken by another rental contract.");
                    }
                    else
                    {
                        c_Contract.MinZ = point.Z;

                        if (c_Contract.MaxZ < c_Contract.MinZ + 19)
                        {
                            c_Contract.MaxZ = point.Z + 19;
                        }
                    }

                    c_Contract.ShowFloorsPreview(m);
                    c_Gump.NewGump();
                    break;

                case TargetType.MaxZ:
                    if (!c_Contract.ParentHouse.Region.Contains(new Point3D(point.X, point.Y, point.Z)))
                    {
                        m.SendMessage("That isn't within your house.");
                    }
                    else if (c_Contract.HasContractedArea(point.Z))
                    {
                        m.SendMessage("That area is already taken by another rental contract.");
                    }
                    else
                    {
                        c_Contract.MaxZ = point.Z + 19;

                        if (c_Contract.MinZ > c_Contract.MaxZ)
                        {
                            c_Contract.MinZ = point.Z;
                        }
                    }

                    c_Contract.ShowFloorsPreview(m);
                    c_Gump.NewGump();
                    break;

                case TargetType.BlockOne:
                    m.SendMessage("Now target the south eastern corner.");
                    m.Target = new InternalTarget(c_Gump, c_Contract, TargetType.BlockTwo, new Point3D(point.X, point.Y, point.Z));
                    break;

                case TargetType.BlockTwo:
                    Rectangle2D rect = TownHouseSetupGump.FixRect(new Rectangle2D(c_BoundOne, new Point3D(point.X + 1, point.Y + 1, point.Z)));

                    if (c_Contract.HasContractedArea(rect, point.Z))
                    {
                        m.SendMessage("That area is already taken by another rental contract.");
                    }
                    else
                    {
                        c_Contract.Blocks.Add(rect);
                        c_Contract.ShowAreaPreview(m);
                    }

                    c_Gump.NewGump();
                    break;
                }
            }
Beispiel #48
0
        private static void BuildRugBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            RedBlueCarpetDeed m_Deed = state as RedBlueCarpetDeed;

            if (m_Deed.Deleted)
            {
                return;
            }

            if (m_Deed.IsChildOf(from.Backpack))
            {
                Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

                if (rect.Width < 3 || rect.Height < 3)
                {
                    from.SendMessage("The carpet is too small. It should be longer or wider than that.");
                    return;
                }

                BaseAddon addon = new RedBlueCarpetAddon(rect);

                BaseHouse house = null;

                AddonFitResult res = addon.CouldFit(start, map, from, ref house);

                if (res == AddonFitResult.Valid)
                {
                    addon.MoveToWorld(start, map);
                }
                else if (res == AddonFitResult.Blocked)
                {
                    from.SendLocalizedMessage(500269);                       // You cannot build that there.
                }
                else if (res == AddonFitResult.NotInHouse)
                {
                    from.SendLocalizedMessage(500274);                       // You can only place this in a house that you own!
                }
                else if (res == AddonFitResult.DoorsNotClosed)
                {
                    from.SendMessage("You must close all house doors before placing this.");
                }
                else if (res == AddonFitResult.DoorTooClose)
                {
                    from.SendLocalizedMessage(500271);                       // You cannot build near the door.
                }
                if (res == AddonFitResult.Valid)
                {
                    m_Deed.Delete();

                    //if ( house != null )
                    //{
                    //foreach ( Server.Multis.BaseHouse h in house )
                    house.Addons.Add(addon);
                    //}
                }
                else
                {
                    addon.Delete();
                }
            }
            else
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
        }
 public GroupDungeonRegion(GroupDungeonStone stone, Map map, string name, Rectangle2D area) : base(name, map, 0, area)
 {
     //Link the region to a control stone, and vise-versa.
     m_Stone       = stone;
     stone.IRegion = this;
 }
Beispiel #50
0
        public void SetDisplay(int x1, int y1, int x2, int y2, int w, int h, Map map, int pX, int pY)
        {
            Point3D locataion = new Point3D(pX, pY, 0);
            string  world     = Worlds.GetMyWorld(map, locataion, pX, pY);

            Width      = w;
            Height     = h;
            DisplayMap = map;

            if (x1 < 0)
            {
                x1 = 0;
            }
            if (y1 < 0)
            {
                y1 = 0;
            }

            if (world == "the Land of Ambrosia")
            {
                if (x1 < 5122)
                {
                    x1 = 5122;
                }
                if (y1 < 3036)
                {
                    y1 = 3036;
                }
            }
            else if (world == "the Island of Umber Veil")
            {
                if (x1 < 699)
                {
                    x1 = 699;
                }
                if (y1 < 3129)
                {
                    y1 = 3129;
                }
            }
            else if (world == "the Bottle World of Kuldar")
            {
                if (x1 < 6127)
                {
                    x1 = 6127;
                }
                if (y1 < 828)
                {
                    y1 = 828;
                }
            }
            else if (world == "the Savaged Empire")
            {
                if (x1 < 136)
                {
                    x1 = 136;
                }
                if (y1 < 8)
                {
                    y1 = 8;
                }
            }

            #region SA
            if (x2 > Map.Maps[map.MapID].Width)
            {
                x2 = Map.Maps[map.MapID].Width;
            }

            if (y2 > Map.Maps[map.MapID].Height)
            {
                y2 = Map.Maps[map.MapID].Height;
            }

            if (world == "the Land of Ambrosia")
            {
                if (x2 >= 6126)
                {
                    x2 = 6126;
                }
                if (y2 >= 4095)
                {
                    y2 = 4095;
                }
            }
            else if (world == "the Island of Umber Veil")
            {
                if (x2 >= 2272)
                {
                    x2 = 2272;
                }
                if (y2 >= 4095)
                {
                    y2 = 4095;
                }
            }
            else if (world == "the Bottle World of Kuldar")
            {
                if (x2 >= 7167)
                {
                    x2 = 7167;
                }
                if (y2 >= 2742)
                {
                    y2 = 2742;
                }
            }
            else if (world == "the Land of Lodoria")
            {
                if (x2 >= 5120)
                {
                    x2 = 5119;
                }
                if (y2 >= 4096)
                {
                    y2 = 4095;
                }
            }
            else if (world == "the Land of Sosaria")
            {
                if (x2 >= 5119)
                {
                    x2 = 5118;
                }
                if (y2 >= 3127)
                {
                    y2 = 3126;
                }
            }
            else if (world == "the Underworld")
            {
                if (x2 >= 1581)
                {
                    x2 = 1581;
                }
                if (y2 >= 1599)
                {
                    y2 = 1599;
                }
            }
            else if (world == "the Serpent Island")
            {
                if (x2 >= 1870)
                {
                    x2 = 1869;
                }
                if (y2 >= 2047)
                {
                    y2 = 2046;
                }
            }
            else if (world == "the Isles of Dread")
            {
                if (x2 >= 1447)
                {
                    x2 = 1446;
                }
                if (y2 >= 1447)
                {
                    y2 = 1446;
                }
            }
            else if (world == "the Savaged Empire")
            {
                if (x2 >= 1160)
                {
                    x2 = 1159;
                }
                if (y2 >= 1792)
                {
                    y2 = 1791;
                }
            }

            int x3 = x2 - x1;
            int y3 = y2 - y1;

            if (x3 > y3)
            {
                x3 = y3;
            }
            if (y3 > x3)
            {
                y3 = x3;
            }

            #endregion

            Bounds = new Rectangle2D(x1, y1, x3, y3);
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_ChallengeArea = new Rectangle3D[0];

            switch (version)
            {
            case 2:
            case 1:
            {
                m_Disable = reader.ReadBool();
                goto case 0;
            }

            case 0:
            {
                m_Music    = (MusicName)reader.ReadInt();
                m_Priority = reader.ReadInt();
                if (version < 2)
                {
                    // old region area
                    reader.ReadRect2D();
                }
                m_ChallengeRegionName = reader.ReadString();
                string mapname = reader.ReadString();
                try{
                    m_ChallengeMap = Map.Parse(mapname);
                } catch {}
                m_CopiedRegion = reader.ReadString();

                // do the coord list
                int count = reader.ReadInt();
                if (count > 0)
                {
                    // the old version used 2D rectangles for the region area.  The new version uses 3D
                    if (version < 2)
                    {
                        Rectangle2D[] area = new Rectangle2D[count];
                        for (int i = 0; i < count; i++)
                        {
                            area[i] = reader.ReadRect2D();
                        }
                        m_ChallengeArea = Region.ConvertTo3D(area);
                    }
                    else
                    {
                        m_ChallengeArea = new Rectangle3D[count];
                        for (int i = 0; i < count; i++)
                        {
                            m_ChallengeArea[i] = new Rectangle3D(reader.ReadPoint3D(), reader.ReadPoint3D());
                        }
                    }
                }
                break;
            }
            }

            // refresh the region
            RefreshRegions();
        }
Beispiel #52
0
 public ShadowguardRegion(Rectangle2D bounds, string regionName, ShadowguardInstance instance)
     : base(String.Format("Shadowguard_{0}", regionName), Map.TerMur, Region.DefaultPriority, bounds)
 {
     Instance = instance;
 }
Beispiel #53
0
 public void SetInitialSpawnArea()
 {
     //Previous default used to be 24;
     SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24));
 }
Beispiel #54
0
        public override void StartGame(Mobile gm)
        {
            base.StartGame(gm);

            m_GameItems = new List <Item>();

            Rectangle2D playerarea = new Rectangle2D(GameAreaStartPoint.X, GameAreaStartPoint.Y,
                                                     GameAreaEndPoint.X - GameAreaStartPoint.X + 1,
                                                     GameAreaEndPoint.Y - GameAreaStartPoint.Y + 1);
            IPooledEnumerable players = Map.GetMobilesInBounds(playerarea);

            foreach (Mobile player in players)
            {
                if (player.AccessLevel == AccessLevel.Player)
                {
                    AddPlayer(player);
                }
            }

            #region Create stones for gamearea
            int startx = m_GameArea.Start.X;
            int starty = m_GameArea.Start.Y;
            int endx   = m_GameArea.End.X;
            int endy   = m_GameArea.End.Y;

            BombermanStone stone;
            for (int x = 0; x <= endx - startx; ++x)
            {
                for (int y = 0; y <= endy - starty; ++y)
                {
                    if (x != 0 && x != endx - startx && y != 0 && y != endy - starty)
                    {
                        if (x % 2 == 1 && y % 2 == 1)
                        {
                            stone = new BombermanStone(false, this);
                        }
                        else
                        {
                            stone = new BombermanStone(true, this);
                        }
                        stone.MoveToWorld(new Point3D(startx + x, starty + y, Map.Tiles.GetLandTile(startx + x, starty + y).Z), Map);
                        m_GameItems.Add(stone);
                    }
                    else if ((x == 0 || x == endx - startx) && y > 1 && y < endy - starty - 1)
                    {
                        stone = new BombermanStone(true, this);
                        stone.MoveToWorld(new Point3D(startx + x, starty + y, Map.Tiles.GetLandTile(startx + x, starty + y).Z), Map);
                        m_GameItems.Add(stone);
                    }
                    else if ((y == 0 || y == endy - starty) && x > 1 && x < endx - startx - 1)
                    {
                        stone = new BombermanStone(true, this);
                        stone.MoveToWorld(new Point3D(startx + x, starty + y, Map.Tiles.GetLandTile(startx + x, starty + y).Z), Map);
                        m_GameItems.Add(stone);
                    }
                }
            }
            #endregion

            #region Handle players: location, items, etc
            Point2D upleft    = m_GameArea.Start;
            Point2D downright = m_GameArea.End;
            Point2D upright   = new Point2D(downright.X, upleft.Y);
            Point2D downleft  = new Point2D(upleft.X, downright.Y);

            byte          index    = 0;
            List <Mobile> toRemove = new List <Mobile>();
            foreach (Mobile m in Players)
            {
                switch (index++)
                {
                case 0:
                    m.Location = new Point3D(upleft, Map.Tiles.GetLandTile(upleft.X, upleft.Y).Z);
                    break;

                case 1:
                    m.Location = new Point3D(downright, Map.Tiles.GetLandTile(upright.X, upright.Y).Z);
                    break;

                case 2:
                    m.Location = new Point3D(downleft, Map.Tiles.GetLandTile(downleft.X, downleft.Y).Z);
                    break;

                case 3:
                    m.Location = new Point3D(upright, Map.Tiles.GetLandTile(downright.X, downright.Y).Z);
                    break;

                default:
                    toRemove.Add(m);
                    PublicOverheadMessage(MessageType.Regular, 906, true, "There are more than 4 mobiles in the game area.");
                    break;
                }
            }

            foreach (Mobile mob in toRemove)
            {
                RemovePlayer(mob);
            }
            #endregion

            StartTimer timer = new StartTimer(this);
            timer.Start();

            gm.SendMessage("The game has been started.");
        }
        private static void InvBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            LogHelper Logger = new LogHelper("inventory.log", true);

            Logger.Log(LogType.Text, string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
                                                   "Qty ---",
                                                   "Item ------------",
                                                   "Damage / Protection --",
                                                   "Durability -----",
                                                   "Accuracy -----",
                                                   "Exceptional",
                                                   "Slayer ----",
                                                   "Serial ----"));

            // Create rec and retrieve items within from bounding box callback
            // result
            Rectangle2D       rect  = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
            IPooledEnumerable eable = map.GetItemsInBounds(rect);

            // Loop through and add objects returned
            foreach (object obj in eable)
            {
                if (m_ItemType == null || obj is BaseContainer)
                {
                    AddInv(obj);
                }
                else
                {
                    Type ot = obj.GetType();

                    if (ot.IsSubclassOf(m_ItemType) || ot == m_ItemType)
                    {
                        AddInv(obj);
                    }
                }
            }

            eable.Free();

            m_Inv.Sort();               // Sort results

            // Loop and log
            foreach (InvItem ir in m_Inv)
            {
                // ir.m_description += String.Format(" ({0})", it.Serial.ToString());
                string output = string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
                                              ir.m_count + ",",
                                              (ir.GetDescription()) + ",",
                                              (ir.m_damage != null ? ir.m_damage : "N/A") + ",",
                                              (ir.m_durability != null ? ir.m_durability : "N/A") + ",",
                                              (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
                                              (ir.m_quality != null ? ir.m_quality : "N/A") + ",",
                                              (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
                                              ir.m_serial.ToString()
                                              );

                Logger.Log(LogType.Text, output);

                if (m_verbose)
                {
                    output = string.Format("{0}{1}{7}{2}{3}{4}{5}{6}",
                                           ir.m_count + ",",
                                           (ir.GetDescription()) + ",",
                                           (ir.m_damage != null ? ir.m_damage : "N/A") + ",",
                                           (ir.m_durability != null ? ir.m_durability : "N/A") + ",",
                                           (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
                                           (ir.m_quality != null ? ir.m_quality : "N/A") + ",",
                                           (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
                                           ir.m_serial.ToString()
                                           );

                    from.SendMessage(output);
                }
            }

            Logger.Count--;             // count-1 for header
            Logger.Finish();
        }
        public override void AddGumpLayout()
        {
            AddImage(0, 0, 0x9CDF);

            if (Title != null)
            {
                if (Title.Number > 0)
                {
                    AddHtmlLocalized(0, 10, 600, 18, CenterLoc, string.Format("#{0}", Title.Number), 0x6B45, false, false);
                }
                else if (!string.IsNullOrEmpty(Title.String))
                {
                    AddHtml(0, 10, 600, 18, ColorAndCenter(C16232(0x6B45), Title.String), false, false);
                }
            }

            int start     = Page * 50;
            var pageIndex = 0;

            int x = 50;
            int y = 60;

            for (int i = start; i < start + 50 && i < Contents.Count; i++)
            {
                var item = Contents[i];

                if (CanTake)
                {
                    AddButton(x, y, 0x931, 0x931, i + 1000, GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(x, y, 0x931);
                }

                Rectangle2D b = ItemBounds.Table[item.ItemID];
                AddItem((x + 25) - b.Width / 2 - b.X, (y + 25) - b.Height / 2 - b.Y, item.ItemID, item.Hue);
                AddItemProperty(item);

                pageIndex++;

                if (pageIndex > 0 && pageIndex % 5 == 0)
                {
                    x += 50;
                    y  = 60;
                }
                else
                {
                    y += 50;
                }
            }

            if (Pages > 1)
            {
                AddHtmlLocalized(263, 346, 100, 18, 1153561, string.Format("{0}\t{1}", Page + 1, Pages), 0x6B45, false, false); // Page ~1_CUR~ of ~2_MAX~
            }
            else
            {
                AddHtmlLocalized(0, 346, 600, 18, 1153562, 0x6B45, false, false); // Page
            }

            AddButton(200, 346, 4014, 4016, 1, GumpButtonType.Reply, 0);
            AddButton(370, 346, 4005, 4007, 2, GumpButtonType.Reply, 0);
        }
Beispiel #57
0
        public void SpawnPirateAndGalleon(SpawnZone zone, Map map)
        {
            SpawnDefinition def = m_Zones[zone];

            if (map != Map.Internal && map != null)
            {
                Rectangle2D   rec    = def.SpawnRegion;
                OrcishGalleon gal    = new OrcishGalleon(Direction.North);
                PirateCaptain pirate = new PirateCaptain(gal);
                pirate.Zone = zone;
                gal.Owner   = pirate;
                Point3D p       = Point3D.Zero;
                bool    spawned = false;
                for (int i = 0; i < 25; i++)
                {
                    int x = Utility.Random(rec.X, rec.Width);
                    int y = Utility.Random(rec.Y, rec.Height);
                    p = new Point3D(x, y, -5);

                    if (gal.CanFit(p, map, gal.ItemID))
                    {
                        spawned = true;
                        break;
                    }
                }

                if (!spawned)
                {
                    gal.Delete();
                    pirate.Delete();
                    return;
                }

                int gold = Utility.RandomMinMax(GoldRange[0], GoldRange[1]);
                gal.MoveToWorld(p, map);
                gal.AutoAddCannons(pirate);
                pirate.MoveToWorld(new Point3D(gal.X, gal.Y - 1, gal.ZSurface), map);

                int crewCount = Utility.RandomMinMax(3, 5);

                for (int i = 0; i < crewCount; i++)
                {
                    Mobile crew = new PirateCrew();

                    if (i == 0)
                    {
                        crew.Title = "the orc captain";
                    }

                    pirate.AddToCrew(crew);
                    crew.MoveToWorld(new Point3D(gal.X + Utility.RandomList(-1, 1), gal.Y + Utility.RandomList(-1, 0, 1), gal.ZSurface), map);
                }

                Point2D[] course = def.GetRandomWaypoints();
                gal.BoatCourse = new BoatCourse(gal, new List <Point2D>(def.GetRandomWaypoints()));

                gal.NextNavPoint = 0;
                gal.StartCourse(false, false);

                FillHold(gal);

                m_Bounties.Add(pirate, gold);
                m_ActiveZones[zone].Add(pirate);
            }
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            this.m_MobFactionArea = new Rectangle3D[0];

            switch (version)
            {
                case 1:
                    {
                        this.m_EjectLocation = reader.ReadPoint3D();
                        string ejectmap = reader.ReadString();
                        try
                        {
                            this.m_EjectMap = Map.Parse(ejectmap);
                        }
                        catch
                        {
                        }

                        string factiontype = reader.ReadString();
                        try
                        {
                            this.m_FactionType = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), factiontype);
                        }
                        catch
                        {
                        }
                        this.m_FactionLevel = reader.ReadInt();

                        goto case 0;
                    }
                case 0:
                    {
                        this.m_Music = (MusicName)reader.ReadInt();
                        this.m_MobFactionPriority = reader.ReadInt();
                        if (version < 1)
                        {
                            // old region area
                            reader.ReadRect2D();
                        }
                        this.m_MobFactionRegionName = reader.ReadString();
                        string mapname = reader.ReadString();
                        try
                        {
                            this.m_MobFactionMap = Map.Parse(mapname);
                        }
                        catch
                        {
                        }
                        this.m_CopiedRegion = reader.ReadString();
                        // do the coord list
                        int count = reader.ReadInt();
                        if (count > 0)
                        {
                            // the old version used 2D rectangles for the region area.  The new version uses 3D
                            if (version < 1)
                            {
                                Rectangle2D[] area = new Rectangle2D[count];
                                for (int i = 0; i < count; i++)
                                {
                                    area[i] = reader.ReadRect2D();
                                }
                                this.m_MobFactionArea = Region.ConvertTo3D(area);
                            }
                            else
                            {
                                this.m_MobFactionArea = new Rectangle3D[count];
                                for (int i = 0; i < count; i++)
                                {
                                    this.m_MobFactionArea[i] = new Rectangle3D(reader.ReadPoint3D(), reader.ReadPoint3D());
                                }
                            }
                        }

                        break;
                    }
            }

            // refresh the region
            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(RefreshRegions));
        }
        public Item Construct()
        {
            Item item;

            try
            {
                if (m_Type == typeofStatic)
                {
                    item = new Static(m_ItemID);
                }
                else if (m_Type == typeofLocalizedStatic)
                {
                    int labelNumber = 0;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("LabelNumber"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                                break;
                            }
                        }
                    }

                    item = new LocalizedStatic(m_ItemID, labelNumber);
                }
                else if (m_Type == typeofLocalizedSign)
                {
                    int labelNumber = 0;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("LabelNumber"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                                break;
                            }
                        }
                    }

                    item = new LocalizedSign(m_ItemID, labelNumber);
                }
                else if (m_Type == typeofAnkhWest || m_Type == typeofAnkhNorth)
                {
                    bool bloodied = false;

                    for (int i = 0; !bloodied && i < m_Params.Length; ++i)
                    {
                        bloodied = (m_Params[i] == "Bloodied");
                    }

                    if (m_Type == typeofAnkhWest)
                    {
                        item = new AnkhWest(bloodied);
                    }
                    else
                    {
                        item = new AnkhNorth(bloodied);
                    }
                }
                else if (m_Type == typeofMarkContainer)
                {
                    bool bone   = false;
                    bool locked = false;
                    Map  map    = Map.Malas;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i] == "Bone")
                        {
                            bone = true;
                        }
                        else if (m_Params[i] == "Locked")
                        {
                            locked = true;
                        }
                        else if (m_Params[i].StartsWith("TargetMap"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                map = Map.Parse(m_Params[i].Substring(++indexOf));
                            }
                        }
                    }

                    MarkContainer mc = new MarkContainer(bone, locked);

                    mc.TargetMap   = map;
                    mc.Description = "strange location";

                    item = mc;
                }
                else if (m_Type == typeofHintItem)
                {
                    int      range         = 0;
                    int      messageNumber = 0;
                    string   messageString = null;
                    int      hintNumber    = 0;
                    string   hintString    = null;
                    TimeSpan resetDelay    = TimeSpan.Zero;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("Range"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                range = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                            }
                        }
                        else if (m_Params[i].StartsWith("WarningString"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                messageString = m_Params[i].Substring(++indexOf);
                            }
                        }
                        else if (m_Params[i].StartsWith("WarningNumber"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                            }
                        }
                        else if (m_Params[i].StartsWith("HintString"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                hintString = m_Params[i].Substring(++indexOf);
                            }
                        }
                        else if (m_Params[i].StartsWith("HintNumber"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                hintNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                            }
                        }
                        else if (m_Params[i].StartsWith("ResetDelay"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                            }
                        }
                    }

                    HintItem hi = new HintItem(m_ItemID, range, messageNumber, hintNumber);

                    hi.WarningString = messageString;
                    hi.HintString    = hintString;
                    hi.ResetDelay    = resetDelay;

                    item = hi;
                }
                else if (m_Type == typeofWarningItem)
                {
                    int      range         = 0;
                    int      messageNumber = 0;
                    string   messageString = null;
                    TimeSpan resetDelay    = TimeSpan.Zero;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("Range"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                range = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                            }
                        }
                        else if (m_Params[i].StartsWith("WarningString"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                messageString = m_Params[i].Substring(++indexOf);
                            }
                        }
                        else if (m_Params[i].StartsWith("WarningNumber"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                            }
                        }
                        else if (m_Params[i].StartsWith("ResetDelay"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                            }
                        }
                    }

                    WarningItem wi = new WarningItem(m_ItemID, range, messageNumber);

                    wi.WarningString = messageString;
                    wi.ResetDelay    = resetDelay;

                    item = wi;
                }
                else if (m_Type == typeofCannon)
                {
                    CannonDirection direction = CannonDirection.North;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("CannonDirection"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                direction = (CannonDirection)Enum.Parse(typeof(CannonDirection), m_Params[i].Substring(++indexOf), true);
                            }
                        }
                    }

                    item = new Cannon(direction);
                }
                else if (m_Type == typeofSerpentPillar)
                {
                    string      word        = null;
                    Rectangle2D destination = new Rectangle2D();

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("Word"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                word = m_Params[i].Substring(++indexOf);
                            }
                        }
                        else if (m_Params[i].StartsWith("DestStart"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                destination.Start = Point2D.Parse(m_Params[i].Substring(++indexOf));
                            }
                        }
                        else if (m_Params[i].StartsWith("DestEnd"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                destination.End = Point2D.Parse(m_Params[i].Substring(++indexOf));
                            }
                        }
                    }

                    item = new SerpentPillar(word, destination);
                }
                else if (m_Type.IsSubclassOf(typeofBeverage))
                {
                    BeverageType content = BeverageType.Liquor;
                    bool         fill    = false;

                    for (int i = 0; !fill && i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("Content"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                content = (BeverageType)Enum.Parse(typeof(BeverageType), m_Params[i].Substring(++indexOf), true);
                                fill    = true;
                            }
                        }
                    }

                    if (fill)
                    {
                        item = (Item)Activator.CreateInstance(m_Type, new object[] { content });
                    }
                    else
                    {
                        item = (Item)Activator.CreateInstance(m_Type);
                    }
                }
                else if (m_Type.IsSubclassOf(typeofBaseDoor))
                {
                    DoorFacing facing = DoorFacing.WestCW;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("Facing"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                facing = (DoorFacing)Enum.Parse(typeof(DoorFacing), m_Params[i].Substring(++indexOf), true);
                                break;
                            }
                        }
                    }

                    item = (Item)Activator.CreateInstance(m_Type, new object[] { facing });
                }
                else
                {
                    item = (Item)Activator.CreateInstance(m_Type);
                }
            }
            catch (Exception e)
            {
                throw new Exception(String.Format("Bad type: {0}", m_Type), e);
            }

            if (item is BaseAddon)
            {
                if (item is MaabusCoffin)
                {
                    MaabusCoffin coffin = (MaabusCoffin)item;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("SpawnLocation"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                coffin.SpawnLocation = Point3D.Parse(m_Params[i].Substring(++indexOf));
                            }
                        }
                    }
                }
                else if (m_ItemID > 0)
                {
                    List <AddonComponent> comps = ((BaseAddon)item).Components;

                    for (int i = 0; i < comps.Count; ++i)
                    {
                        AddonComponent comp = (AddonComponent)comps[i];

                        if (comp.Offset == Point3D.Zero)
                        {
                            comp.ItemID = m_ItemID;
                        }
                    }
                }
            }
            else if (item is BaseLight)
            {
                bool unlit = false, unprotected = false;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (!unlit && m_Params[i] == "Unlit")
                    {
                        unlit = true;
                    }
                    else if (!unprotected && m_Params[i] == "Unprotected")
                    {
                        unprotected = true;
                    }

                    if (unlit && unprotected)
                    {
                        break;
                    }
                }

                if (!unlit)
                {
                    ((BaseLight)item).Ignite();
                }
                if (!unprotected)
                {
                    ((BaseLight)item).Protected = true;
                }

                if (m_ItemID > 0)
                {
                    item.ItemID = m_ItemID;
                }
            }
            else if (item is Server.Mobiles.Spawner)
            {
                Server.Mobiles.Spawner sp = (Server.Mobiles.Spawner)item;

                sp.NextSpawn = TimeSpan.Zero;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("Spawn"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.SpawnNames.Add(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("MinDelay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.MinDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("MaxDelay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.MaxDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("NextSpawn"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.NextSpawn = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Count"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.Count = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Team"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.Team = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("HomeRange"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.HomeRange = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Running"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.Running = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Group"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.Group = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                }
            }
            else if (item is RecallRune)
            {
                RecallRune rune = (RecallRune)item;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("Description"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            rune.Description = m_Params[i].Substring(++indexOf);
                        }
                    }
                    else if (m_Params[i].StartsWith("Marked"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            rune.Marked = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("TargetMap"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            rune.TargetMap = Map.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Target"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            rune.Target = Point3D.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                }
            }
            else if (item is SkillTeleporter)
            {
                SkillTeleporter tp = (SkillTeleporter)item;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("Skill"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Skill = (SkillName)Enum.Parse(typeof(SkillName), m_Params[i].Substring(++indexOf), true);
                        }
                    }
                    else if (m_Params[i].StartsWith("RequiredFixedPoint"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Required = Utility.ToInt32(m_Params[i].Substring(++indexOf)) * 0.01;
                        }
                    }
                    else if (m_Params[i].StartsWith("Required"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Required = Utility.ToDouble(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("MessageString"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.MessageString = m_Params[i].Substring(++indexOf);
                        }
                    }
                    else if (m_Params[i].StartsWith("MessageNumber"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.MessageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("PointDest"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("MapDest"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Creatures"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("SourceEffect"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("DestEffect"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("SoundID"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Delay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                }

                if (m_ItemID > 0)
                {
                    item.ItemID = m_ItemID;
                }
            }
            else if (item is KeywordTeleporter)
            {
                KeywordTeleporter tp = (KeywordTeleporter)item;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("Substring"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Substring = m_Params[i].Substring(++indexOf);
                        }
                    }
                    else if (m_Params[i].StartsWith("Keyword"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Keyword = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Range"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Range = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("PointDest"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("MapDest"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Creatures"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("SourceEffect"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("DestEffect"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("SoundID"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Delay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                }

                if (m_ItemID > 0)
                {
                    item.ItemID = m_ItemID;
                }
            }
            else if (item is Teleporter)
            {
                Teleporter tp = (Teleporter)item;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("PointDest"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("MapDest"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Creatures"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("SourceEffect"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("DestEffect"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("SoundID"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("Delay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf));
                        }
                    }
                }

                if (m_ItemID > 0)
                {
                    item.ItemID = m_ItemID;
                }
            }
            else if (item is FillableContainer)
            {
                FillableContainer cont = (FillableContainer)item;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("ContentType"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            cont.ContentType = (FillableContentType)Enum.Parse(typeof(FillableContentType), m_Params[i].Substring(++indexOf), true);
                        }
                    }
                }

                if (m_ItemID > 0)
                {
                    item.ItemID = m_ItemID;
                }
            }
            else if (m_ItemID > 0)
            {
                item.ItemID = m_ItemID;
            }

            item.Movable = false;

            for (int i = 0; i < m_Params.Length; ++i)
            {
                if (m_Params[i].StartsWith("Light"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        item.Light = (LightType)Enum.Parse(typeof(LightType), m_Params[i].Substring(++indexOf), true);
                    }
                }
                else if (m_Params[i].StartsWith("Hue"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        int hue = Utility.ToInt32(m_Params[i].Substring(++indexOf));

                        if (item is DyeTub)
                        {
                            ((DyeTub)item).DyedHue = hue;
                        }
                        else
                        {
                            item.Hue = hue;
                        }
                    }
                }
                else if (m_Params[i].StartsWith("Name"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        item.Name = m_Params[i].Substring(++indexOf);
                    }
                }
                else if (m_Params[i].StartsWith("Amount"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        // Must supress stackable warnings

                        bool wasStackable = item.Stackable;

                        item.Stackable = true;
                        item.Amount    = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        item.Stackable = wasStackable;
                    }
                }
            }

            return(item);
        }
Beispiel #60
-31
 /**
  * Auto-shapes are defined in the [0,21600] coordinate system.
  * We need to transform it into normal slide coordinates
  *
 */
 public static java.awt.Shape transform(java.awt.Shape outline, Rectangle2D anchor){
     AffineTransform at = new AffineTransform();
     at.translate(anchor.GetX(), anchor.GetY());
     at.scale(
             1.0f/21600*anchor.Width,
             1.0f/21600*anchor.Height
     );
     return at.CreateTransformedShape(outline);
 }