public override void OnDoubleClick( Mobile from )
		{
			from.CloseGump(typeof(WebstoneGump));
			from.SendSound (1224);// 1224= click noise
			from.SendGump( new WebstoneGump() );
			from.SendSound (240);
		}
Example #2
0
		public virtual void SendSound(Mobile m, int soundID)
		{
			if (Options.Sounds.Enabled && m != null && !m.Deleted && soundID > 0)
			{
				m.SendSound(soundID);
			}
		}
Example #3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                if (Amount > 1)
                {
                    Container pack = from.Backpack;

                    if(pack != null)
                    {
                        Matches match = new Matches();

                        if (pack.CheckHold(from, match, true))
                        {
                            pack.DropItem(match);
                            this.Amount--;

                            match.ItemID = 2578;
                            from.SendSound(0x047);
                            match.IsLight = true;
                        }
                        else
                            match.Delete();
                    }
                }
                else if (!m_IsLight)
                {
                    new InternalTimer(this);
                    from.SendLocalizedMessage(1116114); //You ignite the match.

                    ItemID = 2578;
                    from.SendSound(0x047);
                    m_IsLight = true;
                }
                else
                {
                    from.Target = new InternalTarget(this);
                    from.SendLocalizedMessage(1116113); //Target the cannon whose fuse you wish to light.
                }
            }
        }
Example #4
0
        public override bool OnDragDropInto( Mobile from, Item item, Point3D p, byte gridloc )
        {
            if ( !CheckHold( from, item, true, true ) )
                return false;

            var house = HousingHelper.FindHouseAt( this );

            if ( house != null && house.IsLockedDown( this ) )
            {
                if ( item is VendorRentalContract || ( item is Container && ( (Container) item ).FindItemByType( typeof( VendorRentalContract ) ) != null ) )
                {
                    from.SendLocalizedMessage( 1062492 ); // You cannot place a rental contract in a locked down container.
                    return false;
                }

                if ( !house.LockDown( from, item, false ) )
                    return false;
            }

            item.Location = new Point3D( p.X, p.Y, 0 );
            item.SetGridLocation( gridloc, this );
            AddItem( item );

            from.SendSound( GetDroppedSound( item ), GetWorldLocation() );

            return true;
        }
Example #5
0
		public override bool OnDragDrop( Mobile from, Item dropped )
		{
			if ( dropped is LargeBOD || dropped is SmallBOD )
			{
				if ( !IsChildOf( from.Backpack ) )
				{
					from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
					return false;
				}
				else if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
					return false;
				else if ( m_Entries.Count < 500 )
				{
					if ( dropped is LargeBOD )
						m_Entries.Add( new BOBLargeEntry( (LargeBOD)dropped ) );
					else if ( dropped is SmallBOD ) // Sanity
						m_Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );

					InvalidateProperties();

					if ( m_Entries.Count / 5 > m_ItemCount )
					{
						m_ItemCount++;
						InvalidateItems();
					}

					from.SendSound(0x42, GetWorldLocation());
					from.SendLocalizedMessage( 1062386 ); // Deed added to book.

					if ( from is PlayerMobile )
						from.SendGump( new BOBGump( (PlayerMobile)from, this ) );

					dropped.Delete();

					return true;
				}
				else
				{
					from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
					return false;
				}
			}

			from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
			return false;
		}
		public static void CheckSpawn( Mobile killer, Mobile victim ) {
			if ( killer != null && victim != null ) {
				PlayerState ps = PlayerState.Find( victim );

				if ( ps != null ) {
					int chance = ps.Rank.Rank;

					if ( chance > Utility.Random( 100 ) ) {
						int weight = 0;

						foreach ( WeightedItem item in _items ) {
							weight += item.Weight;
						}

						weight = Utility.Random( weight );

						foreach ( WeightedItem item in _items ) {
							if ( weight < item.Weight ) {
								Item obj = item.Construct();

								if ( obj != null ) {
									killer.AddToBackpack( obj );

									killer.SendSound( 1470 );
									killer.LocalOverheadMessage(
										Server.Network.MessageType.Regular, 2119, false,
										"You notice a strange item on the corpse, and decide to pick it up."
									);

									try {
										using ( StreamWriter op = new StreamWriter( "faction-power-items.log", true ) ) {
											op.WriteLine( "{0}\t{1}\t{2}\t{3}", DateTime.UtcNow, killer, victim, obj );
										}
									} catch {
									}
								}

								break;
							} else {
								weight -= item.Weight;
							}
						}
					}
				}
			}
		}
        public bool DoPrayerEffect(PlayerMobile from, Mobile target)
        {
            if (target == null || target.Deleted || !target.Alive || target.IsDeadBondedPet)
                return false;
            if (from == null || from.Deleted)
                return false;

            if (!String.IsNullOrEmpty(m_Message))
                target.SendMessage(m_Message);
            target.SendSound(SoundID);
            int offset = m_Intensity + PowerBonus(from);
            switch (m_Effect)
            {
                case PrayerEffect.Strength:
                    {
                        #region Strength

                        string name = String.Format("[Prayer] {0} Offset", m_Effect);

                        StatMod mod = target.GetStatMod(name);

                        //one is negative and the other is positive, so adding up
                        if (mod != null && ((mod.Offset <= 0 && offset > 0) || (offset < 0 && mod.Offset >= 0)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.Str, name, mod.Offset + offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //nothing to replace, just adding
                        else if (mod == null)
                        {
                            target.AddStatMod(new StatMod(StatType.Str, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //replacing the current mod with a larger one
                        else if (mod != null && ((mod.Offset <= 0 && offset < mod.Offset) || (mod.Offset >= 0 && mod.Offset < offset)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.Str, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }

                        return false;
                        #endregion
                    }
                case PrayerEffect.Dexterity:
                    {
                        #region Dexterity
                        string name = String.Format("[Prayer] {0} Offset", m_Effect);

                        StatMod mod = target.GetStatMod(name);

                        //one is negative and the other is positive, so adding up
                        if (mod != null && ((mod.Offset <= 0 && offset > 0) || (offset < 0 && mod.Offset >= 0)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.Dex, name, mod.Offset + offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //nothing to replace, just adding
                        else if (mod == null)
                        {
                            target.AddStatMod(new StatMod(StatType.Dex, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //replacing the current mod with a larger one
                        else if (mod != null && ((mod.Offset <= 0 && offset < mod.Offset) || (mod.Offset >= 0 && mod.Offset < offset)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.Dex, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }

                        return false;
                        #endregion
                    }
                case PrayerEffect.Intelligence:
                    {
                        #region Intelligence

                        string name = String.Format("[Prayer] {0} Offset", m_Effect);

                        StatMod mod = target.GetStatMod(name);

                        //one is negative and the other is positive, so adding up
                        if (mod != null && ((mod.Offset <= 0 && offset > 0) || (offset < 0 && mod.Offset >= 0)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.Int, name, mod.Offset + offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //nothing to replace, just adding
                        else if (mod == null)
                        {
                            target.AddStatMod(new StatMod(StatType.Int, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //replacing the current mod with a larger one
                        else if (mod != null && ((mod.Offset <= 0 && offset < mod.Offset) || (mod.Offset >= 0 && mod.Offset < offset)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.Int, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }

                        return false;

                        #endregion
                    }
                case PrayerEffect.RawHitPoints:
                    {
                        #region RawHits

                        string name = String.Format("[Prayer] {0} Offset", m_Effect);

                        StatMod mod = target.GetStatMod(name);

                        //one is negative and the other is positive, so adding up
                        if (mod != null && ((mod.Offset <= 0 && offset > 0) || (offset < 0 && mod.Offset >= 0)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.HitsMax, name, mod.Offset + offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //nothing to replace, just adding
                        else if (mod == null)
                        {
                            target.AddStatMod(new StatMod(StatType.HitsMax, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //replacing the current mod with a larger one
                        else if (mod != null && ((mod.Offset <= 0 && offset < mod.Offset) || (mod.Offset >= 0 && mod.Offset < offset)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.HitsMax, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }

                        return false;

                        #endregion
                    }
                case PrayerEffect.CurrentHitPoints:
                    {
                        target.Hits += offset;
                        return true;
                    }
                case PrayerEffect.RawStamina:
                    {
                        #region RawStam

                        string name = String.Format("[Prayer] {0} Offset", m_Effect);

                        StatMod mod = target.GetStatMod(name);

                        //one is negative and the other is positive, so adding up
                        if (mod != null && ((mod.Offset <= 0 && offset > 0) || (offset < 0 && mod.Offset >= 0)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.StamMax, name, mod.Offset + offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //nothing to replace, just adding
                        else if (mod == null)
                        {
                            target.AddStatMod(new StatMod(StatType.StamMax, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //replacing the current mod with a larger one
                        else if (mod != null && ((mod.Offset <= 0 && offset < mod.Offset) || (mod.Offset >= 0 && mod.Offset < offset)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.StamMax, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }

                        return false;

                        #endregion
                    }
                case PrayerEffect.CurrentStamina:
                    {
                        target.Stam += offset;
                        return true;
                    }
                case PrayerEffect.RawMana:
                    {
                        #region RawMana

                        string name = String.Format("[Prayer] {0} Offset", m_Effect);

                        StatMod mod = target.GetStatMod(name);

                        //one is negative and the other is positive, so adding up
                        if (mod != null && ((mod.Offset <= 0 && offset > 0) || (offset < 0 && mod.Offset >= 0)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.ManaMax, name, mod.Offset + offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //nothing to replace, just adding
                        else if (mod == null)
                        {
                            target.AddStatMod(new StatMod(StatType.ManaMax, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }
                        //replacing the current mod with a larger one
                        else if (mod != null && ((mod.Offset <= 0 && offset < mod.Offset) || (mod.Offset >= 0 && mod.Offset < offset)))
                        {
                            target.RemoveStatMod(name);
                            target.AddStatMod(new StatMod(StatType.ManaMax, name, offset, TimeSpan.FromSeconds(m_Duration)));
                            return true;
                        }

                        return false;

                        #endregion
                    }
                case PrayerEffect.CurrentMana:
                    {
                        target.Mana += offset;
                        return true;
                    }
                case PrayerEffect.BluntResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Blunt, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.PiercingResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Piercing, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.SlashingResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Slashing, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.ColdResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Cold, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.FireResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Fire, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.PoisonResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Poison, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.EnergyResistance:
                    {
                        ResistancePrayerTimer timer = new ResistancePrayerTimer(target, ResistanceType.Energy, offset, m_Duration);
                        timer.Start();
                        return true;
                    }
                case PrayerEffect.AttackChance:
                    {
                        XmlAosAttribute att = new XmlAosAttribute(AosAttribute.AttackChance, offset, m_Duration);
                        att.Name = String.Format("[Prayer] {0} Offset", m_Effect);
                        XmlAttach.AttachTo(target, att);
                        return true;
                    }
                case PrayerEffect.DefendChance:
                    {
                        XmlAosAttribute att = new XmlAosAttribute(AosAttribute.DefendChance, offset, m_Duration);
                        att.Name = String.Format("[Prayer] {0} Offset", m_Effect);
                        XmlAttach.AttachTo(target, att);
                        return true;
                    }
                default: return false;
            }
        }
Example #8
0
		public override	bool OnDragDrop( Mobile	from, Item dropped )
		{
			if ( !Movable && !CheckAccess( from	) )
			{
				from.SendMessage("You cannot access	this");	
				return false;
			}

			if ( !(	dropped	is Seed	) )
			{
				from.SendMessage( "You can only	store seeds	in this	box." );
				return	false;
			}
			BaseHouse house	= BaseHouse.FindHouseAt( from );
			int	lockdowns =	0;
			if(house !=null)
				lockdowns =	house.LockDownCount;
			int	seeds =	lockdowns +1;
			
			if(house !=	null &&	!Movable &&	seeds >	house.MaxLockDowns)
			{
				from.SendMessage( "This	would exceed the houses	lockdown limit." );
				return false;	
			}

			int seedcount = SeedCount();
			if(	seedcount > m_maxSeeds )
			{
				from.SendMessage( "This	seed box cannot	hold any more seeds." );
				return false;
			}
			
			
			Seed seed = ( Seed	) dropped;
			int type =	ConvertType( seed.PlantType	);
			int hue = ConvertHue( seed.PlantHue );

			m_counts[ type,	hue	] ++;
			itemcount =	SeedCount()	/5;
			this.TotalItems	= itemcount;

			if (Parent is Container)
			{
				// calling the full version with (-itemcount - 1) prevents double-counting the seedbox
				if (!((Container)Parent).CheckHold(from, this, true, true, (-TotalItems - 1), (int)(-TotalWeight - Weight)))
				{
					m_counts[type, hue]--; // reverse the change to our state
					itemcount = SeedCount() / 5;
					TotalItems = itemcount;
					return false;
				}
			}

			from.SendSound( ((dropped.GetDropSound() != -1) ? dropped.GetDropSound() : 0x42), GetWorldLocation() );

			dropped.Delete();
			InvalidateProperties();
			return true;
		}
Example #9
0
        public override bool OnDragDrop( Mobile from, Item dropped )
        {
            if ( !( dropped is BaseBook ) && !( dropped is Runebook )
                || ( dropped is BaseBook && ( (BaseBook)dropped ).Writable ) )
            {
                from.SendMessage( "You may only add runebooks and sealed books to a library." );
                return false;
            }

            if ( !CheckAccess( from ) )
            {
                from.SendMessage( "Only owners and co-owners can add books to a locked-down library." );
                return false;
            }

            BaseHouse house = BaseHouse.FindHouseAt( from );
            int lockdowns = 0;
            if ( house != null )
                lockdowns = house.LockDownCount;
            int maxbooks = lockdowns + 1;

            if ( house != null && maxbooks > house.MaxLockDowns )
            {
                from.SendMessage( "This would exceed the houses lockdown limit." );
                return false;
            }

            if ( this.TotalItems > Max_Books )
            {
                from.SendMessage( "The library is full." );
                return false;
            }
            //add the book everything checks out
            dropped.IsLockedDown = true;
            AddItem( dropped );
            m_Books.Add( dropped );

            from.SendSound( DropSound, GetWorldLocation( ) );

            return true;
        }
Example #10
0
      public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
      	{
      	from.SendSound(1224);// 1224= click noise
 			base.GetContextMenuEntries(from, list);
 			list.Add(new MenuEntry(from, this));
      	}
Example #11
0
        public virtual void OnCrack(Mobile from)
        {
            Item item;
            from.SendSound(0x3B3);

            if (from.RawStr < Utility.Random(150))
            {
                from.SendMessage("You swing, but fail to crack the rock any further.");
                return;
            }

            switch (Utility.Random(5))
            {
                default:
                case 0: item = new GeodeEast(); break;
                case 1: item = new GeodeSouth(); break;
                case 2: item = new GeodeShardEast(); break;
                case 3: item = new GeodeShardSouth(); break;
                case 4: item = new LavaRock(); break;
            }

            if (item != null)
            {
                from.AddToBackpack(item);
                from.SendMessage("You have split the lava rock!");
                Delete();
            }
        }
Example #12
0
        /*
         * Kaltar
         *
         * Reduz a metade dos atributos do jogador se estiver com fome ou sede.
         * As penalidades são comulativas de sede e fome.
         */
        private static void verificarFomeSede(Mobile m)
        {
            if (!m.Alive)
            {
                return;
            }

            string estadoFome = null;
            string estadoSede = null;

            if(m.Hunger < -8) {
                estadoFome = "a beira da morte por fome";
            }
            else if(m.Hunger < -5) {
                estadoFome = "morrendo de fome";
            }
            else if(m.Hunger < 0) {
                estadoFome = "com muita fome";
            }
            else if(m.Hunger < 2) {
                estadoFome = "com fome";
            }

            if(m.Thirst < -8) {
                estadoSede = "a beira da morte por sede";
            }
            else if(m.Thirst < -5) {
                estadoSede = "morrendo de sede";
            }
            else if(m.Thirst < 0) {
                estadoSede = "com muita sede";
            }
            else if(m.Thirst < 2) {
                estadoSede = "com sede";
            }

            if(estadoFome != null || estadoSede != null) {
                m.SendMessage("Você esta {0} e {1}.", (estadoFome != null ? estadoFome : "alimentado"), (estadoSede != null ? estadoSede : "hidratado"));

                if(!m.Female) {
                    m.SendSound(1077); //son de reclamando
                }
                else {
                    m.SendSound(805);  //son de reclamando
                }
            }

            if(m.Thirst < -10) {
                m.Thirst = -10;

                if(m.AccessLevel == AccessLevel.Player) {
                    m.Hits /= 2;
                    m.Mana /= 2;
                    m.Stam /=2;
                }
            }

            if(m.Hunger < -10) {
                m.Hunger = -10;

                if(m.AccessLevel == AccessLevel.Player) {
                    m.Hits /= 2;
                    m.Mana /= 2;
                    m.Stam /=2;
                }
            }
        }
Example #13
0
        public virtual bool HandleDrop( Mobile from, Item dropped )
        {
            if (m_Collected >= m_Needed)
            {
                from.SendAsciiMessage("We have received all that we need of that already!  Thanks anyways!");
                return false;
            }

            if (m_Type == null)
            {
                if (CollectionType == null)
                {
                    from.SendAsciiMessage("That does not belong in this collection barrel!");
                    return false;
                }

                try
                {
                    m_Type = ScriptCompiler.FindTypeByName(CollectionType, true);
                }
                catch
                {
                }

                if (m_Type == null)
                {
                    from.SendAsciiMessage("That does not belong in this collection barrel!");
                    return false;
                }
            }

            if (CheckItem(dropped))
            {
                from.SendAsciiMessage("Thank you for your donation to our cause!");
                from.SendSound(GetDroppedSound(dropped), GetWorldLocation());

                m_Collected += dropped.Amount;

                if ( m_Record.ContainsKey( from ) )
                {
                    m_Record[from] += dropped.Amount;
                }
                else
                {
                    m_Record.Add( from, dropped.Amount );
                }

                dropped.Delete();

                return true;
            }
            else
            {
                from.SendAsciiMessage("That does not belong in this collection barrel!");
                return false;
            }
        }
Example #14
0
		public override bool OnDragDropInto( Mobile from, Item dropped, Point3D point3d )
		{
			
			BaseHouse housefoundation = BaseHouse.FindHouseAt(this);
        	Item item = dropped as Item;

        	if (dropped.Weight + dropped.TotalWeight + this.TotalWeight >= this.MaxWeight)
        	{
        		if (IsLockedDown)
	        		from.SendMessage(38,"Seems to be just a Decoration Mailbox.");

        		if (IsSecure)
        			from.SendMessage(38,"This will be to much weight for the Mailbox to hold.");
        		return false;
        	}

        	if ((housefoundation == null) & (this.PublicCanDrop == true))
        	{
        		from.SendMessage(68,"You put that into the Mailbox.");
        		DropItem( dropped );
        		from.SendSound( GetDroppedSound( item ), GetWorldLocation() );
        		AdjustMailboxFlagUp(this);        		
        		return true;//false for the moment cause of losing bag
        	}
        	else if((housefoundation != null) & (this.IsSecure))
        	{
        		from.SendMessage(68,"You put that into the Mailbox.");
        		DropItem( dropped );
        		from.SendSound( GetDroppedSound( item ), GetWorldLocation() );
        		AdjustMailboxFlagUp(this);
        		return true;//false for the moment cause of losing bag
        	}
        	else
        	{
        		from.SendMessage(38,"You can not do that.");
        		return false;
        	}
		}        
Example #15
0
        public override void OnDoubleClick(Mobile from)
        	{
        	SecureLevel securelevel = this.m_Level;
        	BaseHouse housefoundation = BaseHouse.FindHouseAt(this);

        	if (from.InRange( this, 2 ))
        		{
        		if ( housefoundation == null )
        			{
        			if (from.AccessLevel >= AccessLevel.Counselor || this.PublicCanOpen == true )
        				{
        				if (from.AccessLevel >= AccessLevel.Counselor)
        				{//if a GMs opens
        					AdjustMailboxFlagDown(this);
        					from.SendSound (45);
        					base.OnDoubleClick(from);
        					return;
        				}
        				else
        				{//if a regular player opens a public mailbox
        					from.SendMessage("You can look inside the mailbox, but you can not reach anything.");
        					from.SendSound (45);
        					base.OnDoubleClick(from);
        					return;
        				}
        			}
        			else
        			{
        				from.SendMessage("You can not open this mailbox.");
        			}
        		}
        		else if (CheckAccess( from ) && housefoundation.IsFriend( from ) )
        		{
        			base.OnDoubleClick(from);
        			AdjustMailboxFlagDown(this);
					from.SendSound (45);
					}
        		else
        			{
        			from.SendMessage("You are not allowed to open that.");
        			}
        		}
        	else
        		{
        		from.SendLocalizedMessage( 500446 ); // That is too far away.
        		}
        	}
Example #16
0
        public virtual bool DropToWorld( Mobile from, Point3D p )
        {
            if ( Deleted || from.Deleted || from.Map == null )
                return false;
            else if ( !from.InRange( p, 2 ) )
                return false;

            Map map = from.Map;

            if ( map == null )
                return false;

            int x = p.m_X, y = p.m_Y;
            int z = int.MinValue;

            int maxZ = from.Z + 16;

            Tile landTile = map.Tiles.GetLandTile( x, y );
            TileFlag landFlags = TileData.LandTable[landTile.ID & 0x3FFF].Flags;

            int landZ = 0, landAvg = 0, landTop = 0;
            map.GetAverageZ( x, y, ref landZ, ref landAvg, ref landTop );

            if ( !landTile.Ignored && (landFlags & TileFlag.Impassable) == 0 )
            {
                if ( landAvg <= maxZ )
                    z = landAvg;
            }

            Tile[] tiles = map.Tiles.GetStaticTiles( x, y, true );

            for ( int i = 0; i < tiles.Length; ++i )
            {
                Tile tile = tiles[i];
                ItemData id = TileData.ItemTable[tile.ID & 0x3FFF];

                if ( !id.Surface )
                    continue;

                int top = tile.Z + id.CalcHeight;

                if ( top > maxZ || top < z )
                    continue;

                z = top;
            }

            ArrayList items = new ArrayList();

            IPooledEnumerable eable = map.GetItemsInRange( p, 0 );

            foreach ( Item item in eable )
            {
                if ( item.ItemID >= 0x4000 )
                    continue;

                items.Add( item );

                ItemData id = item.ItemData;

                if ( !id.Surface )
                    continue;

                int top = item.Z + id.CalcHeight;

                if ( top > maxZ || top < z )
                    continue;

                z = top;
            }

            eable.Free();

            if ( z == int.MinValue )
                return false;

            if ( z > maxZ )
                return false;

            m_OpenSlots = (1<<20)-1;

            int surfaceZ = z;

            for ( int i = 0; i < tiles.Length; ++i )
            {
                Tile tile = tiles[i];
                ItemData id = TileData.ItemTable[tile.ID & 0x3FFF];

                int checkZ = tile.Z;
                int checkTop = checkZ + id.CalcHeight;

                if ( checkTop == checkZ && !id.Surface )
                    ++checkTop;

                int zStart = checkZ - z;
                int zEnd = checkTop - z;

                if ( zStart >= 20 || zEnd < 0 )
                    continue;

                if ( zStart < 0 )
                    zStart = 0;

                if ( zEnd > 19 )
                    zEnd = 19;

                int bitCount = zEnd-zStart;

                m_OpenSlots &= ~(((1<<bitCount)-1)<<zStart);
            }

            for ( int i = 0; i < items.Count; ++i )
            {
                Item item = (Item)items[i];
                ItemData id = item.ItemData;

                int checkZ = item.Z;
                int checkTop = checkZ + id.CalcHeight;

                if ( checkTop == checkZ && !id.Surface )
                    ++checkTop;

                int zStart = checkZ - z;
                int zEnd = checkTop - z;

                if ( zStart >= 20 || zEnd < 0 )
                    continue;

                if ( zStart < 0 )
                    zStart = 0;

                if ( zEnd > 19 )
                    zEnd = 19;

                int bitCount = zEnd-zStart;

                m_OpenSlots &= ~(((1<<bitCount)-1)<<zStart);
            }

            int height = ItemData.Height;

            if ( height == 0 )
                ++height;

            if ( height > 30 )
                height = 30;

            int match = (1<<height)-1;
            bool okay = false;

            for ( int i = 0; i < 20; ++i )
            {
                if ( (i+height) > 20 )
                    match >>= 1;

                okay = ((m_OpenSlots>>i)&match) == match;

                if ( okay )
                {
                    z += i;
                    break;
                }
            }

            if ( !okay )
                return false;

            height = ItemData.Height;

            if ( height == 0 )
                ++height;

            if ( landAvg > z && (z + height) > landZ )
                return false;
            else if ( (landFlags & TileFlag.Impassable) != 0 && landAvg > surfaceZ && (z + height) > landZ )
                return false;

            for ( int i = 0; i < tiles.Length; ++i )
            {
                Tile tile = tiles[i];
                ItemData id = TileData.ItemTable[tile.ID & 0x3FFF];

                int checkZ = tile.Z;
                int checkTop = checkZ + id.CalcHeight;

                if ( checkTop > z && (z + height) > checkZ )
                    return false;
                else if ( (id.Surface || id.Impassable) && checkTop > surfaceZ && (z + height) > checkZ )
                    return false;
            }

            for ( int i = 0; i < items.Count; ++i )
            {
                Item item = (Item)items[i];
                ItemData id = item.ItemData;

                if ( (item.Z + id.CalcHeight) > z && (z + height) > item.Z )
                    return false;
            }

            p = new Point3D( x, y, z );

            if ( !from.InLOS( new Point3D( x, y, z + 1 ) ) )
                return false;
            else if ( !from.OnDroppedItemToWorld( this, p ) )
                return false;
            else if ( !OnDroppedToWorld( from, p ) )
                return false;

            int soundID = GetDropSound();

            MoveToWorld( p, from.Map );

            from.SendSound( soundID == -1 ? 0x42 : soundID, GetWorldLocation() );

            return true;
        }
Example #17
0
        public virtual bool StackWith( Mobile from, Item dropped, bool playSound )
        {
            if ( Stackable && dropped.Stackable && dropped.GetType() == GetType() && dropped.ItemID == ItemID && dropped.Hue == Hue && (dropped.Amount + Amount) <= 60000 )
            {
                if ( m_LootType != dropped.m_LootType )
                    m_LootType = LootType.Regular;

                Amount += dropped.Amount;
                dropped.Delete();

                if ( playSound )
                {
                    int soundID = GetDropSound();

                    if ( soundID == -1 )
                        soundID = 0x42;

                    from.SendSound( soundID, GetWorldLocation() );
                }

                return true;
            }

            return false;
        }
Example #18
0
        public override bool OnDragDrop( Mobile from, Item dropped )
        {
            if ( dropped is SmallBOD || dropped is LargeBOD )
            {
                Account acc = from.Account as Account;

                if ( acc == null || acc.Trial )
                {
                    SayTo( from, 1111859 ); // Trial accounts cannot turn in a bulk order.
                    return false;
                }
                else if ( !IsValidBulkOrder( dropped ) || !SupportsBulkOrders( from ) )
                {
                    SayTo( from, 1045130 ); // That order is for some other shopkeeper.
                    return false;
                }
                else if ( ( dropped is SmallBOD && !( (SmallBOD) dropped ).Complete ) || ( dropped is LargeBOD && !( (LargeBOD) dropped ).Complete ) )
                {
                    SayTo( from, 1045131 ); // You have not completed the order yet.
                    return false;
                }

                Item reward;
                int gold, fame;

                if ( dropped is SmallBOD )
                    ( (SmallBOD) dropped ).GetRewards( out reward, out gold, out fame );
                else
                    ( (LargeBOD) dropped ).GetRewards( out reward, out gold, out fame );

                from.SendSound( 0x3D );

                if ( reward != null )
                    from.AddToBackpack( reward );

                Banker.DepositUpTo( from, gold );
                from.SendLocalizedMessage( 1060397, gold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.

                SayTo( from, 1045132 ); // Thank you so much!  Here is a reward for your effort.

                Titles.AwardFame( from, fame, true );

                ClearNextBulkOrder( from );

                dropped.Delete();

                return true;
            }

            return base.OnDragDrop( from, dropped );
        }