public void AddItemFor(Item item, Mobile mob) 
		{
            if (item == null || mob == null)
                return;

			DropItem(item);
			item.SetLastMoved();
			
			if (m_Instancing == null) 
				m_Instancing = new Dictionary<Item, Mobile>();
				
			m_Instancing[item] = mob;
		}
		public void ReleaseSecure( Mobile m, Item item )
		{
			if ( m_Secures == null || !IsOwner( m ) || item is StrongBox || !IsActive )
				return;

			for ( int i = 0; i < m_Secures.Count; ++i )
			{
				SecureInfo info = (SecureInfo)m_Secures[i];

				if ( info.Item == item && HasSecureAccess( m, info.Level ) )
				{
					item.IsLockedDown = false;
					item.IsSecure = false;

					#region Mondain's Legacy
					if ( item is BaseAddonContainer )
						item.Movable = false;
					else
					#endregion

					item.Movable = true;
					item.SetLastMoved();
					item.PublicOverheadMessage( Server.Network.MessageType.Label, 0x3B2, 501656 );//[no longer secure]
					m_Secures.RemoveAt( i );
					return;
				}
			}

			m.SendLocalizedMessage( 501717 );//This isn't secure...
		}
		private void SetLockdown( Item i, bool locked, bool checkContains )
		{
			if ( m_LockDowns == null )
				return;

			#region Mondain's Legacy
			if ( i is BaseAddonContainer )
				i.Movable = false;
			else
			#endregion

			i.Movable = !locked;
			i.IsLockedDown = locked;

			if ( locked )
			{
				if ( i is VendorRentalContract )
				{
					if ( !VendorRentalContracts.Contains( i ) )
						VendorRentalContracts.Add( i );
				}
				else
				{
					if ( !checkContains || !m_LockDowns.Contains( i ) )
						m_LockDowns.Add( i );
				}
			}
			else
			{
				VendorRentalContracts.Remove( i );
				m_LockDowns.Remove( i );
			}

			if ( !locked )
				i.SetLastMoved();

			if ( (i is Container) && (!locked || !(i is BaseBoard)) )
			{
				foreach ( Item c in i.Items )
					SetLockdown( c, locked, checkContains );
			}
		}
Beispiel #4
0
		private void SetLockdown( Item i, bool locked, bool checkContains )
		{
			if ( m_LockDowns == null )
				return;

			i.Movable = !locked;
			i.IsLockedDown = locked;

			if ( locked )
			{
				if ( i is VendorRentalContract )
				{
					if ( !VendorRentalContracts.Contains( i ) )
						VendorRentalContracts.Add( i );
				}
				else
				{
					if ( !checkContains || !m_LockDowns.Contains( i ) )
						m_LockDowns.Add( i );
				}
			}
			else
			{
				VendorRentalContracts.Remove( i );
				m_LockDowns.Remove( i );
			}

			if ( !locked )
				i.SetLastMoved();

            if ((i is Container) && (!locked || !(i is BaseBoard || i is Aquarium || i is FishBowl)))
            {
				foreach ( Item c in i.Items )
					SetLockdown( c, locked, checkContains );
			}
		}
Beispiel #5
0
        public void ReleaseSecure( Mobile m, Item item )
        {
            if ( m_Secures == null || item is StrongBox || !IsActive )
                return;

            for ( int i = 0; i < m_Secures.Count; ++i )
            {
                SecureInfo info = (SecureInfo)m_Secures[i];

                if ( info.Item == item )
                {
                    item.IsLockedDown = false;
                    item.IsSecure = false;
                    item.Movable = true;
                    item.SetLastMoved();
                    item.PublicOverheadMessage( Server.Network.MessageType.Label, 0x3B2, true, "no longer secure" );//no longer secure
                    m_Secures.RemoveAt( i );

                    //disable protection
                    if ( this.LockDownCount == 0 && this.SecureCount == 0 )
                    {
                        DisableProtection( m );
                    }
                    return;
                }
            }

            m.SendAsciiMessage( "This isn't secure..." );//This isn't secure...
        }
Beispiel #6
0
        public virtual void Lift( Item item, int amount, out bool rejected, out LRReason reject )
        {
            rejected = true;
            reject = LRReason.Inspecific;

            if ( item == null )
                return;

            Mobile from = this;
            NetState state = m_NetState;

            if ( from.AccessLevel >= AccessLevel.GameMaster || Core.Now >= from.NextActionTime )
            {
                if ( from.CheckAlive() )
                {
                    from.DisruptiveAction();

                    if ( from.Holding != null )
                    {
                        reject = LRReason.AreHolding;
                    }
                    else if ( from.AccessLevel < AccessLevel.GameMaster && !from.InRange( item.GetWorldLocation(), 2 ) )
                    {
                        reject = LRReason.OutOfRange;
                    }
                    else if ( !from.CanSee( item ) || !from.InLOS( item ) )
                    {
                        reject = LRReason.OutOfSight;
                    }
                    else if ( !item.VerifyMove( from ) )
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if ( item.InSecureTrade || !item.IsAccessibleTo( from ) )
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if ( !item.CheckLift( from, item ) )
                    {
                        reject = LRReason.Inspecific;
                    }
                    else
                    {
                        object root = item.RootParent;

                        if ( root != null && root is Mobile && !((Mobile)root).CheckNonlocalLift( from, item ) )
                        {
                            reject = LRReason.TryToSteal;
                        }
                        else if ( !from.OnDragLift( item ) || !item.OnDragLift( from ) )
                        {
                            reject = LRReason.Inspecific;
                        }
                        else if ( !from.CheckAlive() )
                        {
                            reject = LRReason.Inspecific;
                        }
                        else
                        {
                            item.SetLastMoved();

                            if ( amount == 0 )
                                amount = 1;

                            if ( amount > item.Amount )
                                amount = item.Amount;

                            int oldAmount = item.Amount;
                            item.Amount = amount;

                            if ( amount < oldAmount )
                                item.Dupe( oldAmount - amount );

                            Map map = from.Map;

                            if ( Mobile.DragEffects && map != null && (root == null || root is Item))
                            {
                                IPooledEnumerable eable = map.GetClientsInRange( from.Location );
                                Packet p = null;

                                foreach ( NetState ns in eable )
                                {
                                    if ( ns.Mobile != from && ns.Mobile.CanSee( from ) )
                                    {
                                        if ( p == null )
                                        {
                                            IEntity src;

                                            if ( root == null )
                                                src = new Entity( Serial.Zero, item.Location, map );
                                            else
                                                src = new Entity( ((Item)root).Serial, ((Item)root).Location, map );

                                            p = new DragEffect( src, from, item.ItemID, item.Hue, amount );
                                        }

                                        ns.Send( p );
                                    }
                                }

                                eable.Free();
                            }

                            Point3D fixLoc = item.Location;
                            Map fixMap = item.Map;
                            bool shouldFix = ( item.Parent == null );

                            item.RecordBounce();
                            item.OnItemLifted( from, item );
                            item.Internalize();

                            from.Holding = item;

                            int liftSound = item.GetLiftSound( from );

                            if ( liftSound != -1 )
                                from.Send( new PlaySound( liftSound, from ) );

                            from.NextActionTime = Core.Now + TimeSpan.FromSeconds( 0.5 );

                            if ( fixMap != null && shouldFix )
                                fixMap.FixColumn( fixLoc.m_X, fixLoc.m_Y );

                            reject = LRReason.Inspecific;
                            rejected = false;
                        }
                    }
                }
                else
                {
                    reject = LRReason.Inspecific;
                }
            }
            else
            {
                SendActionMessage();
                reject = LRReason.Inspecific;
            }

            if ( rejected && state != null )
            {
                state.Send( new LiftRej( reject ) );

                if( item.Parent is Item ) {
                    if ( state.IsPost6017 )
                        state.Send( new ContainerContentUpdate6017( item ) );
                    else
                        state.Send( new ContainerContentUpdate( item ) );
                } else if( item.Parent is Mobile )
                    state.Send( new EquipUpdate( item ) );
                else
                    item.SendInfoTo( state );

                if ( ObjectPropertyList.Enabled && item.Parent != null )
                    state.Send( item.OPLPacket );
            }
        }
Beispiel #7
0
        public void Lift( Item item, int amount, out bool rejected, out LRReason reject )
        {
            rejected = true;
            reject = LRReason.Inspecific;

            if ( item == null )
                return;

            Mobile from = this;
            GameClient state = m_Client;

            if ( from.AccessLevel >= AccessLevel.GameMaster || DateTime.Now >= from.NextActionTime )
            {
                if ( from.CheckAlive() )
                {
                    from.DisruptiveAction();

                    if ( from.Holding != null )
                    {
                        reject = LRReason.AreHolding;
                    }
                    else if ( from.AccessLevel < AccessLevel.GameMaster && !from.InRange( item.GetWorldLocation(), 2 ) )
                    {
                        reject = LRReason.OutOfRange;
                    }
                    else if ( !from.CanSee( item ) || !from.InLOS( item ) )
                    {
                        reject = LRReason.OutOfSight;
                    }
                    else if ( !item.VerifyMove( from ) )
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if ( !item.IsAccessibleTo( from ) )
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if ( item.CheckLift( from, item, ref reject ) )
                    {
                        object root = item.RootParent;

                        if ( root != null && root is Mobile && !( (Mobile) root ).CheckNonlocalLift( from, item ) )
                        {
                            reject = LRReason.TryToSteal;
                        }
                        else if ( !from.OnDragLift( item ) || !item.OnDragLift( from ) )
                        {
                            reject = LRReason.Inspecific;
                        }
                        else if ( !from.CheckAlive() )
                        {
                            reject = LRReason.Inspecific;
                        }
                        else
                        {
                            if ( item.Parent != null && item.Parent is Container )
                                ( (Container) item.Parent ).FreePosition( item.GridLocation );

                            item.SetLastMoved();

                            if ( item.Spawner != null )
                            {
                                item.Spawner.Remove( item );
                                item.Spawner = null;
                            }

                            if ( amount == 0 )
                                amount = 1;

                            if ( amount > item.Amount )
                                amount = item.Amount;

                            int oldAmount = item.Amount;
                            //item.Amount = amount; //Set in LiftItemDupe

                            if ( amount < oldAmount )
                                LiftItemDupe( item, amount );

                            InvokeItemLifted( new ItemLiftedEventArgs( item, amount ) );

                            item.RecordBounce();
                            item.OnItemLifted( from, item );
                            item.Internalize();

                            from.Holding = item;

                            from.NextActionTime = DateTime.Now + TimeSpan.FromSeconds( 0.5 );

                            Point3D fixLoc = item.Location;
                            Map fixMap = item.Map;
                            bool shouldFix = ( item.Parent == null );

                            if ( fixMap != null && shouldFix )
                                fixMap.FixColumn( fixLoc.X, fixLoc.Y );

                            reject = LRReason.Inspecific;
                            rejected = false;
                        }
                    }
                }
                else
                {
                    reject = LRReason.Inspecific;
                }
            }
            else
            {
                SendActionMessage();
                reject = LRReason.Inspecific;
            }

            if ( rejected && state != null )
            {
                state.Send( LiftRej.Instantiate( reject ) );

                if ( item.Parent is Item )
                    state.Send( new ContainerContentUpdate( item ) );
                else if ( item.Parent is Mobile )
                    state.Send( new EquipUpdate( item ) );
                else
                    item.SendInfoTo( state );

                if ( ObjectPropertyListPacket.Enabled && item.Parent != null )
                    state.Send( item.OPLPacket );
            }
        }
Beispiel #8
0
		public void ReleaseSecure(Item item)
		{
			if (m_Secures == null)
				return;

			for (int i = 0; i < m_Secures.Count; ++i)
			{
				SecureInfo info = (SecureInfo)m_Secures[i];

				if (info.Item == item)
				{
					item.IsLockedDown = false;
					item.IsSecure = false;
					item.Movable = true;
					item.SetLastMoved();
					m_Secures.RemoveAt(i);
					return;
				}
			}
		}
Beispiel #9
0
		private void SetLockdown(Item i, bool locked, bool checkContains)
		{
			if (m_LockDowns == null)
				return;

			i.Movable = !locked;
			i.IsLockedDown = locked;

			if (locked)
			{
				if (!checkContains || !m_LockDowns.Contains(i))
					if (i is Container && !IsExceptionContainer(i) /*&& !m_Public*/ )
						m_LockBoxCount += 1;

				m_LockDowns.Add(i);
			}
			else
			{
				if (i is Container && !IsExceptionContainer(i) /*&& !m_Public*/ )
					m_LockBoxCount -= 1;

				m_LockDowns.Remove(i);
			}

			if (!locked)
				i.SetLastMoved();


		}