Пример #1
0
        public void Carve(Mobile from, Item item)
        {
            Item ribcage = new RibCage();
            Item heart = new Item( 7405 );
            Item liver = new Item( 7406 );
            Item entrails = new Item( 7407 );

            if ( m_Owner != null )
            {
                ribcage.Name = "ribcage of " + m_Owner.Name;
                liver.Name = "liver of " + m_Owner.Name;
                heart.Name = "heart of " + m_Owner.Name;
                entrails.Name = "entrails of " + m_Owner.Name;
            }

            if ( !(Parent is Container) )
            {
                ribcage.MoveToWorld( GetWorldLocation(), Map );
                liver.MoveToWorld( GetWorldLocation(), Map );
                heart.MoveToWorld( GetWorldLocation(), Map );
                entrails.MoveToWorld( GetWorldLocation(), Map );
            }
            else
            {
                Container cont = (Container)Parent;
                cont.DropItem( ribcage );
                cont.DropItem( liver );
                cont.DropItem( heart );
                cont.DropItem( entrails );
            }

            Delete();
        }
Пример #2
0
		public virtual void AddItem( Item item, int xOffset, int yOffset, int zOffset )
		{
			m_Items.Add( item );

            int zavg = Map.GetAverageZ(X + xOffset, Y + yOffset);
            item.MoveToWorld(new Point3D(X + xOffset, Y + yOffset, zavg + zOffset), Map);
		}
Пример #3
0
		public override void Execute( CommandEventArgs args, object o )
		{
			if( o is AddonComponent )
			{
				BaseAddon addon = ((AddonComponent)o).Addon;

				if( addon.Components.Count > 0 )
				{
					for( int i = 0; i < addon.Components.Count; i++ )
					{
						AddonComponent component = addon.Components[i];
						Item newItem = new Item( component.ItemID );

						newItem.Hue = component.Hue;
						newItem.Light = component.Light;
						newItem.Movable = true;
						newItem.Name = component.Name;

						newItem.MoveToWorld( component.Location, component.Map );
					}
				}

				addon.Delete();

				AddResponse( "The add-on has been converted into individual items." );
			}
			else if( o is Item )
			{
				Item i = (Item)o;
				Item newItem = new Item( i.ItemID );

				newItem.Hue = i.Hue;
				newItem.Layer = i.Layer;
				newItem.Light = i.Light;
				newItem.Movable = true;
				newItem.Name = i.Name;

				newItem.MoveToWorld( i.Location, i.Map );

				if( i.Parent == args.Mobile )
					newItem.Bounce( args.Mobile );

				if( i is Container )
					((Container)i).Destroy();
				else
					i.Delete();

				AddResponse( "The item has been converted to an item." );
			}
			else
			{
				LogFailure( "This command only works with item objects." );
			}
		}
Пример #4
0
		protected override void OnTarget( Mobile from, object targeted ) 
		{ 
			if ( from.Name == null)
			{
				from.SendMessage("Your name is not valid fix it now");
				return;
			}
           
			if ( targeted is Mobile )
			{ 
				Mobile m_target = (Mobile)targeted;
				from.PublicOverheadMessage(MessageType.Emote ,20, true,"*" + from.Name + " Points at*");
            	
				if ( m_target.Name != null)
					m_target.PublicOverheadMessage(MessageType.Emote ,20,true, "*" + m_target.Name + "*");
				else
					m_target.PublicOverheadMessage(MessageType.Emote ,20,true,"*"+ from.Name + " whatever it is!*");
			}
			else if ( targeted is Item ) 
			{ 
				Item m_target = (Item)targeted;
				from.PublicOverheadMessage(MessageType.Emote ,20, true,"*" + from.Name + " Points at*");
				if (m_target.Name != null)
					m_target.PublicOverheadMessage(MessageType.Emote ,20,true, "* " + m_target.Name + "*");
				else
					m_target.PublicOverheadMessage(MessageType.Emote ,20,true, "*Points Here*");
			}
			else 
			{
				IPoint3D p = targeted as IPoint3D; 

				if ( p != null ) 
				{
					Map map = from.Map;
					Item pointer = new Item (8302);
					Point3D m_point = new Point3D(p);
					pointer.MoveToWorld(m_point,map);
					pointer.Movable = false;
					PointTimer p_time = new PointTimer(pointer);
					from.PublicOverheadMessage(MessageType.Emote ,20, true, "*" + from.Name.ToString() + " Points at*");
					pointer.PublicOverheadMessage(MessageType.Emote ,20, true, "*This Spot*" );
				}
				else
				{ 
					from.SendMessage( "Cannot point at this for some reason!" ); 
				} 
			}     
		}
Пример #5
0
		public static Item TryCreateItem( int x, int y, int z, Item srcItem )
		{
			IPooledEnumerable eable = Map.Felucca.GetItemsInBounds( new Rectangle2D( x, y, 1, 1 ) );

				foreach ( Item item in eable )
				{
					if ( item.GetType() == srcItem.GetType() )
					{
						eable.Free();
						srcItem.Delete();
						return item;
					}
				}

			eable.Free();
			srcItem.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
			m_Count++;

			return srcItem;
		}
Пример #6
0
		public override void Execute( Server.Commands.CommandEventArgs args, object o )
		{
			if( o is AddonComponent )
			{
				BaseAddon addon = ((AddonComponent)o).Addon;
				
				if( addon.Components.Count > 0 )
				{
					for( int i = 0; i < addon.Components.Count; i++ )
					{
						AddonComponent component = (addon.Components)[i];
                        Item newItem = new Item( component.ItemID) {Hue = component.Hue, Name = component.Name};

					    newItem.MoveToWorld( new Point3D( component.Location ), component.Map );
					}
				}
				
				addon.Delete();
				
				AddResponse( "The add-on has been converted to an item." );
			}
			else if( o is Static )
			{
				Static s = (Static)o;
				Item newItem = new Item( s.ItemID ) {Hue = s.Hue, Layer = s.Layer, Light = s.Light, Name = s.Name};

			    newItem.MoveToWorld( new Point3D( s.Location ), s.Map );
				
				if( s.Parent == args.Mobile )
					newItem.Bounce( args.Mobile );

				s.Delete();
				
				AddResponse( "The static has been converted to an item." );
			}
			else
			{
				LogFailure( "This command only works with static items or add-ons." );
			}
		}
Пример #7
0
        public static void GiveArtifactTo( Mobile m, Item artifact )
        {
            bool message = true;

            if ( !m.AddToBackpack( artifact ) )
            {
                Container bank = m.BankBox;

                if ( !( bank != null && bank.TryDropItem( m, artifact, false ) ) )
                {
                    m.SendLocalizedMessage( 1072523, "", 64 ); // You find an artifact, but your backpack and bank are too full to hold it.

                    message = false;

                    artifact.MoveToWorld( m.Location, m.Map );
                }
            }

            if ( message )
                m.SendLocalizedMessage( 1062317, "", 64 ); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.

            EffectPool.ArtifactDrop( m );
        }
Пример #8
0
        private void AddRubble(Item i, Point3D p)
        {
            i.MoveToWorld(p, this.Map);

            if (Rubble == null)
                Rubble = new List<Item>();

            Rubble.Add(i);
        }
Пример #9
0
 public void DoSwap(Item firstHand, Item secondHand)
 {
     if (secondHand == null)
     {
         if (m_Cont == null)
         {
             //m_Mobile.SendMessage(MessageColorization ? this.Hue : 49, "You swapped {0} for {1}.", this.Name != null ? this.Name : this.ItemData.Name, firstHand.Name != null ? firstHand.Name : firstHand.ItemData.Name);
             firstHand.MoveToWorld(this.Location);
             m_Mobile.EquipItem(this);
         }
         else if (m_Cont.TryDropItem(m_Mobile, firstHand, true))
         {
             //m_Mobile.SendMessage(MessageColorization ? this.Hue : 49, "You swapped {0} for {1}.", this.Name != null ? this.Name : this.ItemData.Name, firstHand.Name != null ? firstHand.Name : firstHand.ItemData.Name);
             firstHand.Location = this.Location;
             m_Mobile.EquipItem(this);
         }
     }
     else
     {
         if (m_Cont == null)
         {
             //m_Mobile.SendMessage(MessageColorization ? this.Hue : 49, "You swapped {0} for {1} and {2}.", this.Name != null ? this.Name : this.ItemData.Name, firstHand.Name != null ? firstHand.Name : firstHand.ItemData.Name, secondHand.Name != null ? secondHand.Name : secondHand.ItemData.Name);
             firstHand.MoveToWorld(this.Location);
             secondHand.MoveToWorld(this.Location);
             m_Mobile.EquipItem(this);
         }
         else if (m_Cont.TryDropItem(m_Mobile, firstHand, true) && m_Cont.TryDropItem(m_Mobile, secondHand, true))
         {
             //m_Mobile.SendMessage(MessageColorization ? this.Hue : 49, "You swapped {0} for {1} and {2}.", this.Name != null ? this.Name : this.ItemData.Name, firstHand.Name != null ? firstHand.Name : firstHand.ItemData.Name, secondHand.Name != null ? secondHand.Name : secondHand.ItemData.Name);
             firstHand.Location = this.Location;
             secondHand.Location = this.Location;
             m_Mobile.EquipItem(this);
         }
     }
 }
Пример #10
0
		protected bool SpawnItem( Item item )
		{
			for ( int i = 0; i < 5; i++ ) // Try 5 times
			{
				int x = Location.X + Utility.RandomMinMax( -1, 1 );
				int y = Location.Y + Utility.RandomMinMax( -1, 1 );
				int z = Map.GetAverageZ( x, y );

				if ( Map.CanFit( x, y, Location.Z, 1 ) )
				{
					item.MoveToWorld( new Point3D( x, y, Location.Z ), Map );
					return true;
				}
				else if ( Map.CanFit( x, y, z, 1 ) )
				{
					item.MoveToWorld( new Point3D( x, y, z ), Map );
					return true;
				}
			}

			return false;
		}
Пример #11
0
        private FoundationType m_Type; // Graphic type of this foundation.

        #endregion Fields

        #region Constructors

        public HouseFoundation( Mobile owner, int multiID, int maxLockdowns, int maxSecures )
            : base(multiID, owner, maxLockdowns, maxSecures)
        {
            m_SignpostGraphic = 9;

            m_Fixtures = new ArrayList();

            int x = Components.Min.X;
            int y = Components.Height - 1 - Components.Center.Y;

            m_SignHanger = new Static( 0xB98 );
            m_SignHanger.MoveToWorld( new Point3D( X + x, Y + y, Z + 7 ), Map );

            CheckSignpost();

            SetSign( x, y, 7 );

            BanLocation = new Point3D( x, y, 0 );
        }
Пример #12
0
        public void SetWhiteSkullCount(int val)
        {
            for (int i = m_WhiteSkulls.Count - 1; i >= val; --i)
            {
                m_WhiteSkulls[i].Delete();
                m_WhiteSkulls.RemoveAt(i);
            }

            for (int i = m_WhiteSkulls.Count; i < val; ++i)
            {
                Item skull = new Item(0x1854);

                skull.Movable = false;
                skull.Light = LightType.Circle150;

                skull.MoveToWorld(GetWhiteSkullLocation(i), Map);

                m_WhiteSkulls.Add(skull);

                Effects.PlaySound(skull.Location, skull.Map, 0x29);
                Effects.SendLocationEffect(new Point3D(skull.X + 1, skull.Y + 1, skull.Z), skull.Map, 0x3728, 10);
            }
        }
Пример #13
0
 public void AddFixture( Item item, MultiTileEntry mte )
 {
     m_Fixtures.Add( item );
     item.MoveToWorld( new Point3D( X + mte.m_OffsetX, Y + mte.m_OffsetY, Z + mte.m_OffsetZ ), Map );
 }
Пример #14
0
        public virtual void AddItem( Item item, int xOffset, int yOffset, int zOffset )
        {
            m_Items.Add( item );

            item.MoveToWorld( new Point3D( X + xOffset, Y + yOffset, Z + zOffset ), Map );
        }
Пример #15
0
        private void MoveParticipants()
        {
            m_Region = new DuelRegion(this);
            m_Region.Register();

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

            IPooledEnumerable ip = Map.GetItemsInBounds(Area2D);

            foreach (Item item in ip)
                if (item != null && item.GetType().IsDefined(typeof(DispellableFieldAttribute), false))
                    fieldstoremove.Add(item);

            ip.Free();

            foreach (Item item in fieldstoremove)
                if(!item.Deleted)
                    item.Delete();

            for(int i = 0; i < Participants.Length; i++)
            {
                Mobile m = Participants[i];

                    if (DuelType is DDDuelType)
                    m.SendLocalizedMessage(1060398, DuelSystem.GoldCost2v2.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.

                else
                    m.SendLocalizedMessage(1060398, DuelSystem.GoldCost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.

                m.Frozen = true;
                m.Hidden = false;
                m.Map = Map;
                m.Hits = m.HitsMax;
                m.Mana = m.ManaMax;
                m.Stam = m.StamMax;

                TransformationSpellHelper.RemoveContext(m, true);
                for(int j = m.StatMods.Count -1; j >= 0; j--)
                {
                    StatMod st = m.StatMods[j];
                    if (st.Name.StartsWith("[Magic]"))
                        m.StatMods.RemoveAt(j);
                }
                if (m.Spell != null && m.Spell.IsCasting)
                    m.Spell.OnCasterHurt();
                Targeting.Target.Cancel(m);
                m.CloseGump(typeof(SummonFamiliarGump));
                List<Item> armthis = new List<Item>();
                MoveMob(m, 1);

                SunnySystem.Undress(m, ItemNotAllowed);

                if (SpellWatch)
                {
                    SpellWatcher sw = new SpellWatcher(m);
                    SpellWatchList.Add(sw);
                }

                if (DuelType is TMFDuelType || DuelType is UMFDuelType)
                {
                    DuelBlockAddon dba = new DuelBlockAddon();
                    if (m == Starter)
                        blockadd0 = dba;
                    else
                        blockadd1 = dba;
                    dba.MoveToWorld(m.Location, m.Map);

                    if (DuelType is UMFDuelType)
                    {
                        armthis.Add(new Spellbook(ulong.MaxValue));
                        if (m.Skills[SkillName.Magery].Value > 80)
                        {
                            NecromancerSpellbook book = new NecromancerSpellbook();
                            book.Content = 0x1FFFF;
                            armthis.Add(book);
                        }
                        GoldRing ring = new GoldRing();
                        ring.Attributes.LowerRegCost = 100;
                        ring.LootType = LootType.Cursed;
                        armthis.Add(ring);
                    }
                }

                if (DuelType is UDFDuelType)
                {
                    armthis.Add(new Bandage(75));

                    if (m.Skills[SkillName.Chivalry].Value > 80)
                    {
                        BookOfChivalry bookch = new BookOfChivalry();
                        bookch.Content = 1023;
                        armthis.Add(bookch);
                    }

                    if (m.Skills[SkillName.Necromancy].Value > 80)
                    {
                        NecromancerSpellbook book = new NecromancerSpellbook();
                        book.Content = 0x1FFFF;
                        armthis.Add(book);
                    }

                    GoldRing ring = new GoldRing();
                    ring.Attributes.LowerRegCost = 100;
                    armthis.Add(ring);

                    if (m.Skills[SkillName.Fencing].Value > 80)
                    {
                        armthis.Add(new BladedStaff());
                        armthis.Add(new DoubleBladedStaff());
                        armthis.Add(new Pike());
                        armthis.Add(new Pitchfork());
                        armthis.Add(new ShortSpear());
                        armthis.Add(new Spear());
                        armthis.Add(new Kryss());
                        armthis.Add(new WarFork());
                    }

                    if (m.Skills[SkillName.Swords].Value > 80)
                    {
                        //armthis.Add(new BoneHarvester());
                        armthis.Add(new Broadsword());
                        //armthis.Add(new Pike());
                        armthis.Add(new CrescentBlade());
                        //armthis.Add(new Cutlass());
                        armthis.Add(new Katana());
                        armthis.Add(new Longsword());
                        armthis.Add(new Scimitar());
                        //armthis.Add(new VikingSword());
                        //armthis.Add(new Bardiche());
                        //armthis.Add(new Halberd());
                        armthis.Add(new BattleAxe());
                        armthis.Add(new Pickaxe());
                        //armthis.Add(new WarAxe());
                    }

                    if (m.Skills[SkillName.Macing].Value > 80)
                    {
                        armthis.Add(new Club());
                        armthis.Add(new HammerPick());
                        armthis.Add(new Mace());
                        armthis.Add(new Maul());
                        armthis.Add(new Scepter());
                        armthis.Add(new WarHammer());
                        armthis.Add(new WarMace());
                    }

                    if (m.Skills[SkillName.Archery].Value > 80)
                    {
                        armthis.Add(new Bolt(50));
                        armthis.Add(new Arrow(50));
                        armthis.Add(new Bow());
                        armthis.Add(new CompositeBow());
                        armthis.Add(new Crossbow());
                        armthis.Add(new HeavyCrossbow());
                        armthis.Add(new RepeatingCrossbow());
                    }

                    if (m.Skills[SkillName.Parry].Value > 80)
                        armthis.Add(new MetalKiteShield());
                }

                if (armthis.Count > 0)
                    SunnySystem.ArmPlayer(m, armthis);
            }

            m_Wall = new DuelWall();
            if (m_Wid != 0)
                m_Wall.ItemID = m_Wid;
            m_Wall.Hue = m_Wue;
            m_Wall.MoveToWorld(Locations[1], Map);

            new DuelTimer(this, 10, TimeSpan.FromSeconds(1.0)).Start();
        }
Пример #16
0
        /// <summary>
        /// This is the function that starts the game.
        /// </summary>
        /// <param name="lenght">Lenght of the game.</param>
        /// <param name="draw">If this is a draw game.</param>
        public static void StartGame(TimeSpan lenght, bool draw)
        {
            if( draw )
            {
                CTFMessage( string.Format( "A Draw! Game will continue for {0}", MiscUtility.FormatTimeSpan( lenght ) ) );
            }
            else
            {
                if (Spawn != null)
                    Spawn.StartTimer();

                Teams = Stone.Teams;
                if (Teams == 0) {
                    int number = PlayerJoinList.Count;
                    if ( number < 20 ) // Silver edit, old: (number < 16) || (number == 18)
                        Teams = 2;
                    else
                        Teams = 4;
                }

                Item wall;
                if (Teams == 3) {
                    wall = new Item(578);
                    wall.Hue = 1150;
                    wall.Movable = false;
                    wall.MoveToWorld(new Point3D(5943, 451, 22), Map.Felucca);
                    walls[0] = wall;
                    wall = new Item(578);
                    wall.Hue = 1150;
                    wall.Movable = false;
                    wall.MoveToWorld(new Point3D(5943, 452, 22), Map.Felucca);
                    walls[1] = wall;
                } else if (Teams == 2) {
                    wall = new Item(578);
                    wall.Hue = 1150;
                    wall.Movable = false;
                    wall.MoveToWorld(new Point3D(5943, 451, 22), Map.Felucca);
                    walls[0] = wall;
                    wall = new Item(578);
                    wall.Hue = 1150;
                    wall.Movable = false;
                    wall.MoveToWorld(new Point3D(5943, 452, 22), Map.Felucca);
                    walls[1] = wall;
                    wall = new Item(577);
                    wall.Hue = 33;
                    wall.Movable = false;
                    wall.MoveToWorld(new Point3D(5955, 455, 22), Map.Felucca);
                    walls[2] = wall;
                    wall = new Item(577);
                    wall.Hue = 33;
                    wall.Movable = false;
                    wall.MoveToWorld(new Point3D(5956, 455, 22), Map.Felucca);
                    walls[3] = wall;
                }

                for (int i = 0; i < Teams; i++)
                    GameData.TeamList.Add(new CTFTeamGameData(TeamArray[i]));

                List<CTFPlayerData> playerlist = new List<CTFPlayerData>();

                foreach (Mobile m in PlayerJoinList)
                {
                    CTFPlayerData pd = CTFData.GetPlayerData(m);

                    if (pd != null)
                        playerlist.Add(pd);

                    else
                    {
                        pd = new CTFPlayerData(m);
                        CTFData.PlayerDictionary[m] = pd;
                        CTFData.PlayerList.Add(pd);
                        playerlist.Add(pd);
                    }
                }

                playerlist.Sort();

                // Selection System by Silver

                int idx = 0;
                int max = playerlist.Count;

                if( Stone.CTFLeagueGame )
                {
                    int CTFLeagueTeam = -1;

                    while( idx < max )
                    {
                        CTFLeagueTeam = -1;

                        CTFPlayerData pd = playerlist[idx];

                        if( pd.Mob.SolidHueOverride == 1109 )
                            CTFLeagueTeam = 0;
                        else if( pd.Mob.SolidHueOverride == 1266 )
                            CTFLeagueTeam = 1;
                        else
                            LeaveGame( pd.Mob );

                        if( CTFLeagueTeam != -1 )
                        {
                            CTFPlayerGameData pgd = new CTFPlayerGameData(pd.Mob, TeamArray[CTFLeagueTeam]);
                            GameData.PlayerDictionary[pd.Mob] = pgd;
                            GameData.PlayerList.Add(pgd);
                            GameData.TeamList[CTFLeagueTeam].PlayerList.Add(pgd);
                            ArmPlayer(pgd);
                            pd.Mob.SendGump(new CTFRewardGump(pd.Mob, 0));
                        }

                        pd.Mob.SolidHueOverride = -1;
                        idx++;
                    }
                }
                else
                {
                    int startTeam = Utility.Random(Teams);
                    bool revert = false;

                    while( idx < max )
                    {
                        for( int team = 0; team < Teams && idx < max; team++ )
                        {
                            CTFPlayerData pd = playerlist[idx];
                            CTFPlayerGameData pgd = new CTFPlayerGameData(pd.Mob, TeamArray[((revert ? (Teams - team - 1) : team) + startTeam)%Teams]);
                            GameData.PlayerDictionary[pd.Mob] = pgd;
                            GameData.PlayerList.Add(pgd);
                            GameData.TeamList[((revert ? (Teams - team - 1) : team) + startTeam)%Teams].PlayerList.Add(pgd);
                            ArmPlayer(pgd);
                            pd.Mob.SendGump(new CTFRewardGump(pd.Mob, 0));

                            idx++;
                        }
                        revert = !revert;
                    }
                }

                PlayerJoinList.Clear();
                ResetTeams();
                CTFMessage( "The game has started." );
            }

            // Set idle check 4 min after game starts
            NextIdleCheck = DateTime.Now + CTFGame.IdleTime;

            StartTime = DateTime.Now;
            CurLength = lenght;

            GameTimer = new CtfGameTimer(lenght, TimeSpan.FromMinutes(1.0));
            GameTimer.Start();
        }
Пример #17
0
        public void TryBuyItem(Mobile from, Item item)
        {
            if (item.Deleted || !this.Backpack.Items.Contains(item) || !m_ItemTable.ContainsKey(item))
            {
                from.SendMessage("This item is no longer available.");
                return;
            }

            int points = 0;
            int cost = m_ItemTable[item];

            if (DespiseController.Instance != null)
                points = DespiseController.Instance.GetDespisePoints(from);

            if (points >= cost)
            {
                DespiseController.Instance.DeductDespisePoints(from, cost);
                item.Movable = true;

                if (from.Backpack == null || !from.Backpack.TryDropItem(from, item, false))
                    item.MoveToWorld(from.Location, from.Map);

                from.SendLocalizedMessage(1153427, cost.ToString()); // You have spent ~1_AMT~ Dungeon Crystal Points of Despise.

                InternalGump.Resend(this);
            }
            else
                from.SendMessage("You need {0} more Despise dungeon crystal points for this.", cost - points);
        }
Пример #18
0
		public static void StoreAt( Item source, Item toplace )
		{
			if( source.Parent != null )
			{
				Container container = (Container)source.Parent;
					
				container.DropItem( toplace );
				toplace.X = source.X;
				toplace.Y = source.Y;
			}
			else
			{
				toplace.MoveToWorld( source.Location, source.Map );
				if( !source.Movable )
				{
					BaseHouse house = BaseHouse.FindHouseAt( source );
					
					if( house != null )
					{
						house.LockDown( house.Owner, toplace );
					}
					else
					{
						toplace.Movable = false;
					}
				}
				
			}
		}
Пример #19
0
		//
		// Given two Items, copies the properties of the first to the second
		// then places the second one where the first is and deletes the first.
		//
		public static void ReplaceItem( Item replacement, Item itemToReplace, bool copyDeep )
		{
			Container pack;

			if ( null != itemToReplace && !itemToReplace.Deleted )
			{
				if ( copyDeep )
					CopyProperties( replacement, itemToReplace );
				else
					CopyPropertiesShallow( replacement, itemToReplace );

				if ( itemToReplace.Parent is Container )
					pack = (Container)itemToReplace.Parent;
				else if ( itemToReplace.Parent is Mobile )
					pack = ((Mobile)itemToReplace.Parent).Backpack;
				else
					pack = null;

				replacement.Parent = null;

				if ( pack != null )
					pack.DropItem( replacement );
				else
					replacement.MoveToWorld( itemToReplace.Location, itemToReplace.Map );

				itemToReplace.Delete();
			}
		}
        private static void MoveItem( Item src, Item target )
        {
            Container pack = null;
            if ( src.Parent is Container )
                pack = (Container)src.Parent;
            else if ( src.Parent is Mobile )
                pack = ((Mobile)src.Parent).Backpack;

            if ( pack != null )
                pack.DropItem( target );
            else
                target.MoveToWorld( src.Location, src.Map );
        }
Пример #21
0
		public override void ReplaceWith(Item newItem)
		{
			if (Parent is Container)
			{
				var cont = (Container)Parent;

				if (newItem is BaseFireworkStar)
				{
					BaseFireworkStar star = (BaseFireworkStar)newItem;
					Type starType = star.GetType();
					BaseFireworkStar stackWith =
						cont.FindItemsByType<BaseFireworkStar>()
							.FirstOrDefault(
								s =>
								s.Stackable && s.Resource == star.Resource && s.Amount + star.Amount <= 60000 && s.GetType().IsEqual(starType));

					if (stackWith != null)
					{
						stackWith.Amount += newItem.Amount;
						newItem.Delete();
					}
					else
					{
						cont.AddItem(newItem);

						newItem.Location = Location;
					}
				}
				else
				{
					cont.AddItem(newItem);

					newItem.Location = Location;
				}
			}
			else
			{
				newItem.MoveToWorld(GetWorldLocation(), Map);
			}

			Delete();
		}
		public static Item AddLeverPuzzlePart( int[] Loc, Item newitem  )
		{
			if( newitem == null || newitem.Deleted  )
			{
				installed=false;
			}
			else
			{
				newitem.MoveToWorld( new Point3D(Loc[0], Loc[1], Loc[2]), Map.Malas );
			}
			return newitem;
		}
Пример #23
0
        public virtual void ScissorHelper( Mobile from, Item newItem, int amountPerOldItem, bool carryHue )
        {
            int amount = Amount;

            if ( amount > (60000 / amountPerOldItem) ) // let's not go over 60000
                amount = (60000 / amountPerOldItem);

            Amount -= amount;

            int ourHue = Hue;
            Map thisMap = this.Map;
            object thisParent = this.m_Parent;
            Point3D worldLoc = this.GetWorldLocation();
            LootType type = this.LootType;

            if ( Amount == 0 )
                Delete();

            newItem.Amount = amount * amountPerOldItem;

            if ( carryHue )
                newItem.Hue = ourHue;

            if ( m_ScissorCopyLootType )
                newItem.LootType = type;

            if ( !(thisParent is Container) || !((Container)thisParent).TryDropItem( from, newItem, false ) )
                newItem.MoveToWorld( worldLoc, thisMap );
        }
Пример #24
0
        public bool AddToBackpack( Item item )
        {
            if ( item.Deleted )
                return false;

            if ( !PlaceInBackpack( item ) )
            {
                Point3D loc = m_Location;
                Map map = m_Map;

                if ( (map == null || map == Map.Internal) && m_LogoutMap != null )
                {
                    loc = m_LogoutLocation;
                    map = m_LogoutMap;
                }

                item.MoveToWorld( loc, map );
                return false;
            }

            return true;
        }
Пример #25
0
        public static void AddSpawnItem(XmlSpawner spawner, object invoker, XmlSpawner.SpawnObject theSpawn, Item item, Point3D location, Map map, Mobile trigmob, bool requiresurface,
            List<XmlSpawner.SpawnPositionInfo> spawnpositioning, string propertyString, bool smartspawn, out string status_str)
        {
            status_str = null;
            if (item == null || theSpawn == null) return;

            // add the item to the spawned list
            theSpawn.SpawnedObjects.Add(item);

            item.Spawner = spawner;

            if (spawner != null)
            {
                // this is being called by a spawner so use spawner information for placement
                if (!spawner.Deleted)
                {
                    // set the item amount
                    if (spawner.StackAmount > 1 && item.Stackable)
                    {
                        item.Amount = spawner.StackAmount;
                    }
                    // if this is in any container such as a pack then add to the container.
                    if (spawner.Parent is Container)
                    {
                        Container c = (Container)spawner.Parent;

                        Point3D loc = spawner.Location;

                        if (!smartspawn)
                        {
                            item.OnBeforeSpawn(loc, map);
                        }

                        item.Location = loc;

                        // check to see whether we drop or add the item based on the spawnrange
                        // this will distribute multiple items around the spawn point, and allow precise
                        // placement of single spawns at the spawn point
                        if (spawner.SpawnRange > 0)
                            c.DropItem(item);
                        else
                            c.AddItem(item);

                    }
                    else
                    {
                        // if the spawn entry is in a subgroup and has a packrange, then get the packcoord

                        Point3D packcoord = Point3D.Zero;
                        if (theSpawn.PackRange >= 0 && theSpawn.SubGroup > 0)
                        {
                            packcoord = spawner.GetPackCoord(theSpawn.SubGroup);
                        }
                        Point3D loc = spawner.GetSpawnPosition(requiresurface, theSpawn.PackRange, packcoord, spawnpositioning);

                        if (!smartspawn)
                        {
                            item.OnBeforeSpawn(loc, map);
                        }

                        // standard placement for all items in the world
                        item.MoveToWorld(loc, map);
                    }
                }
                else
                {
                    // if the spawner has already been deleted then delete the item since it cannot be cleaned up by spawner deletion any longer
                    item.Delete();
                    return;
                }
            }
            else
            {
                if (!smartspawn)
                {
                    item.OnBeforeSpawn(location, map);
                }
                // use the location and map info passed in
                // this allows AddSpawnItem to be called by objects other than spawners as long as they pass in a valid SpawnObject
                item.MoveToWorld(location, map);
            }

            // clear the taken flag on all newly spawned items
            ItemFlags.SetTaken(item, false);

            if (!smartspawn)
            {
                item.OnAfterSpawn();
            }

            // apply the parsed arguments from the typestring using setcommand
            // be sure to do this after setting map and location so that errors dont place the mob on the internal map
            BaseXmlSpawner.ApplyObjectStringProperties(spawner, propertyString, item, trigmob, spawner, out status_str);

            // if the object has an OnAfterSpawnAndModify method, then invoke it
            //InvokeOnAfterSpawnAndModify(item);
        }
Пример #26
0
		public void GiveItem(Mobile from, Item item)
		{
			Container pack = from.Backpack;
			
			if(pack == null || !pack.TryDropItem(from, item, false))
				item.MoveToWorld(from.Location, from.Map);
		}
Пример #27
0
        public void CheckSignpost()
        {
            MultiComponentList mcl = this.Components;

            int x = mcl.Min.X;
            int y = mcl.Height - 2 - mcl.Center.Y;

            if ( CheckWall( mcl, x, y ) )
            {
                if ( m_Signpost != null )
                    m_Signpost.Delete();

                m_Signpost = null;
            }
            else if ( m_Signpost == null )
            {
                m_Signpost = new Static( m_SignpostGraphic );
                m_Signpost.MoveToWorld( new Point3D( X + x, Y + y, Z + 7 ), Map );
            }
            else
            {
                m_Signpost.ItemID = m_SignpostGraphic;
                m_Signpost.MoveToWorld( new Point3D( X + x, Y + y, Z + 7 ), Map );
            }
        }
Пример #28
0
 public void AddAddon( Item item, int xoff, int yoff, int zoff )
 {
     item.MoveToWorld( new Point3D( xoff+this.X, yoff+this.Y, zoff+this.Z ), this.Map );
     m_Addons.Add( item );
 }
Пример #29
0
		public virtual bool Give( Mobile m, Item item, bool placeAtFeet )
		{
			if ( m.PlaceInBackpack( item ) )
				return true;

			if ( !placeAtFeet )
				return false;

			Map map = m.Map;

			if ( map == null )
				return false;

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

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

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

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

			item.MoveToWorld( m.Location, map );
			return true;
		}
Пример #30
0
        public static bool DropItemInBagOrFeet(PlayerMobile player, MasterLooterBackpack backpack, Item item)
		{
			if ( player == null || item == null )
				return false;
			if ( backpack == null )
				backpack = GetMasterLooter(player);
			if ( backpack != null && backpack.TryDropItem(player, item, false) )
				return true;
			if ( player.Backpack != null && player.Backpack.TryDropItem(player, item, false) )
				return true;
			
			Map map = player.Map;
            if (map == null)
                return false;

            List<Item> atFeet = new List<Item>();
            foreach (Item obj in player.GetItemsInRange(0))
                atFeet.Add(obj);
            for (int i = 0; i < atFeet.Count; ++i)
            {
                Item check = atFeet[i];

                if (check.StackWith(player, item, false))
                    break;
            }
            item.MoveToWorld(player.Location, map);
			return true;
		}