Esempio n. 1
0
        public override bool CheckNonlocalDrop(Mobile from, Item item, Item target)
        {
            if (!base.CheckNonlocalDrop(from, item, target))
                return false;

            if (from.AccessLevel >= AccessLevel.GameMaster)
                return true;

            Container pack = this.Backpack;
            if (from == this && this.HasTrade && (target == pack || target.IsChildOf(pack)))
            {
                BounceInfo bounce = item.GetBounce();

                if (bounce != null && bounce.m_Parent is Item)
                {
                    Item parent = (Item)bounce.m_Parent;

                    if (parent == pack || parent.IsChildOf(pack))
                        return true;
                }

                SendLocalizedMessage(1004041); // You can't do that while you have a trade pending.
                return false;
            }

            return true;
        }
Esempio n. 2
0
        public override bool OnDroppedItemToWorld(Item item, Point3D location)
        {
            if (!base.OnDroppedItemToWorld(item, location))
                return false;

            BounceInfo bi = item.GetBounce();

            if (bi != null)
            {
                Type type = item.GetType();

                if (type.IsDefined(typeof(FurnitureAttribute), true) || type.IsDefined(typeof(DynamicFlipingAttribute), true))
                {
                    object[] objs = type.GetCustomAttributes(typeof(FlipableAttribute), true);

                    if (objs != null && objs.Length > 0)
                    {
                        FlipableAttribute fp = objs[0] as FlipableAttribute;

                        if (fp != null)
                        {
                            int[] itemIDs = fp.ItemIDs;

                            Point3D oldWorldLoc = bi.m_WorldLoc;
                            Point3D newWorldLoc = location;

                            if (oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y)
                            {
                                Direction dir = GetDirection4(oldWorldLoc, newWorldLoc);

                                if (itemIDs.Length == 2)
                                {
                                    switch (dir)
                                    {
                                        case Direction.North:
                                        case Direction.South: item.ItemID = itemIDs[0]; break;
                                        case Direction.East:
                                        case Direction.West: item.ItemID = itemIDs[1]; break;
                                    }
                                }
                                else if (itemIDs.Length == 4)
                                {
                                    switch (dir)
                                    {
                                        case Direction.South: item.ItemID = itemIDs[0]; break;
                                        case Direction.East: item.ItemID = itemIDs[1]; break;
                                        case Direction.North: item.ItemID = itemIDs[2]; break;
                                        case Direction.West: item.ItemID = itemIDs[3]; break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return true;
        }
		public override void OnSubItemRemoved( Item item )
		{
			base.OnSubItemRemoved( item );

			if ( item.GetBounce() == null )
				RemoveVendorItem( item );
		}
Esempio n. 4
0
        public override bool CheckEquip(Item item)
        {
            if (!base.CheckEquip(item))
                return false;

            #region Factions
            FactionItem factionItem = FactionItem.Find(item);

            if (factionItem != null)
            {
                Faction faction = Faction.Find(this);

                if (faction == null)
                {
                    SendLocalizedMessage(1010371); // You cannot equip a faction item!
                    return false;
                }
                else if (faction != factionItem.Faction)
                {
                    SendLocalizedMessage(1010372); // You cannot equip an opposing faction's item!
                    return false;
                }
                else
                {
                    int maxWearables = FactionItem.GetMaxWearables(this);

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

                        if (item != equiped && FactionItem.Find(equiped) != null)
                        {
                            if (--maxWearables == 0)
                            {
                                SendLocalizedMessage(1010373); // You do not have enough rank to equip more faction items!
                                return false;
                            }
                        }
                    }
                }
            }
            #endregion

            if (this.AccessLevel < AccessLevel.GameMaster && item.Layer != Layer.Mount && this.HasTrade)
            {
                BounceInfo bounce = item.GetBounce();

                if (bounce != null)
                {
                    if (bounce.m_Parent is Item)
                    {
                        Item parent = (Item)bounce.m_Parent;

                        if (parent == this.Backpack || parent.IsChildOf(this.Backpack))
                            return true;
                    }
                    else if (bounce.m_Parent == this)
                    {
                        return true;
                    }
                }

                SendLocalizedMessage(1004042); // You can only equip what you are already carrying while you have a trade pending.
                return false;
            }

            return true;
        }
Esempio n. 5
0
        public override void OnItemRemoved( Item item )
        {
            base.OnItemRemoved( item );

            if ( item.GetBounce() == null && this.TotalItems == 0 )
                Delete();
        }
Esempio n. 6
0
		public override bool OnDroppedItemToWorld( Item item, Point3D location )
		{
			if ( !base.OnDroppedItemToWorld( item, location ) )
				return false;

            //plasma, 03/12/07
            //Check here to see if we are trying to drop on an adjacent location
            //to a TillerMan, and if so prevent the drop.
            else if (!BaseBoat.DropFitResult(location, Map, Z))
                return false;

			BounceInfo bi = item.GetBounce();

			if ( bi != null )
			{
				Type type = item.GetType();

                if (type.IsDefined(typeof(FurnitureAttribute), true) || type.IsDefined(typeof(DynamicFlipingAttribute), true))
                {
                    object[] objs = type.GetCustomAttributes(typeof(FlipableAttribute), true);

                    if (objs != null && objs.Length > 0)
                    {
                        FlipableAttribute fp = objs[0] as FlipableAttribute;

                        if (fp != null)
                        {
                            int[] itemIDs = fp.ItemIDs;

                            Point3D oldWorldLoc = bi.m_WorldLoc;
                            Point3D newWorldLoc = location;

                            if (oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y)
                            {
                                Direction dir = GetDirection4(oldWorldLoc, newWorldLoc);

                                if (itemIDs.Length == 2)
                                {
                                    switch (dir)
                                    {
                                        case Direction.North:
                                        case Direction.South: item.ItemID = itemIDs[0]; break;
                                        case Direction.East:
                                        case Direction.West: item.ItemID = itemIDs[1]; break;
                                    }
                                }
                                else if (itemIDs.Length == 4)
                                {
                                    switch (dir)
                                    {
                                        case Direction.South: item.ItemID = itemIDs[0]; break;
                                        case Direction.East: item.ItemID = itemIDs[1]; break;
                                        case Direction.North: item.ItemID = itemIDs[2]; break;
                                        case Direction.West: item.ItemID = itemIDs[3]; break;
                                    }
                                }
                            }
                        }
                    }
                }
                
			}

			return true;
		}
Esempio n. 7
0
        public override bool CheckNonlocalDrop( Mobile from, Item item, Item target )
        {
            if( this != null && from != null && item != null && from is PlayerMobile )
            {
                PlayerMobile pm = from as PlayerMobile;

                if( pm != this && pm.AccessLevel < AccessLevel.GameMaster && !pm.Hidden && pm.Feats.GetFeatLevel(FeatList.PlantEvidence) > 0 && pm.Alive && this.Alive && pm.InLOS( this ) && pm.InRange( this.Location, 1 ) && pm.CanSee( this ) )
                {
                    if( Utility.RandomMinMax( 1, 100 ) < ( pm.Feats.GetFeatLevel(FeatList.PlantEvidence) * 33 ) )
                        return true;

                    else
                    {
                        string notice = String.Format( "You notice {0} trying to drop something in {1}'s backpack.", pm.Name, this.Name );

                        IPooledEnumerable eable = this.Map.GetClientsInRange( this.Location, 8 );

                        foreach ( NetState ns in eable )
                        {
                            if ( ns != pm.NetState )
                                ns.Mobile.SendMessage( notice );
                        }

                        eable.Free();
                    }
                }
            }

            if ( !base.CheckNonlocalDrop( from, item, target ) )
                return false;

            if ( from.AccessLevel >= AccessLevel.GameMaster )
                return true;

            Container pack = this.Backpack;
            if ( from == this && this.HasTrade && ( target == pack || target.IsChildOf( pack ) ) )
            {
                BounceInfo bounce = item.GetBounce();

                if ( bounce != null && bounce.m_Parent is Item )
                {
                    Item parent = (Item) bounce.m_Parent;

                    if ( parent == pack || parent.IsChildOf( pack ) )
                        return true;
                }

                SendLocalizedMessage( 1004041 ); // You can't do that while you have a trade pending.
                return false;
            }

            return true;
        }
Esempio n. 8
0
        public override bool CheckEquip( Item item )
        {
            if( item == null || item.Deleted )
                return false;

            if( Forging || Reforging )
            {
                SendMessage( "You cannot equip anything while forging or reforging your character." );
                return false;
            }

            if( Claws != null && item is BaseWeapon )
            {
                SendMessage( "You need to remove your claws before equipping a weapon." );
                return false;
            }

            if ( !base.CheckEquip( item ) )
                return false;

            if ( item.Layer == Layer.FirstValid || item.Layer == Layer.TwoHanded )
            {
                Corpse corpse = this.Backpack.FindItemByType( typeof( Corpse ) ) as Corpse;

                if ( corpse != null && corpse.Owner != this )
                {
                    this.SendMessage( 60, "You cannot equip this, because you are carrying someone." );
                    return false;
                }
            }

            if (HealthAttachment.HasHealthAttachment(this))
            {
                if (HealthAttachment.GetHA(this).HasInjury(Injury.BrokenRightArm))
                {
                    if (item.Layer == Layer.FirstValid || item.Layer == Layer.OneHanded || (item.Layer == Layer.TwoHanded && item is BaseWeapon))
                        return false;
                }

                if (HealthAttachment.GetHA(this).HasInjury(Injury.BrokenLeftArm))
                {
                    if (item.Layer == Layer.TwoHanded)
                        return false;
                }
            }

            #region Factions
            FactionItem factionItem = FactionItem.Find( item );

            if ( factionItem != null )
            {
                Faction faction = Faction.Find( this );

                if ( faction == null )
                {
                    SendLocalizedMessage( 1010371 ); // You cannot equip a faction item!
                    return false;
                }
                else if ( faction != factionItem.Faction )
                {
                    SendLocalizedMessage( 1010372 ); // You cannot equip an opposing faction's item!
                    return false;
                }
                else
                {
                    int maxWearables = FactionItem.GetMaxWearables( this );

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

                        if ( item != equiped && FactionItem.Find( equiped ) != null )
                        {
                            if ( --maxWearables == 0 )
                            {
                                SendLocalizedMessage( 1010373 ); // You do not have enough rank to equip more faction items!
                                return false;
                            }
                        }
                    }
                }
            }
            #endregion

            if ( this.AccessLevel < AccessLevel.GameMaster && item.Layer != Layer.Mount && this.HasTrade )
            {
                BounceInfo bounce = item.GetBounce();

                if ( bounce != null )
                {
                    if ( bounce.m_Parent is Item )
                    {
                        Item parent = (Item) bounce.m_Parent;

                        if ( parent == this.Backpack || parent.IsChildOf( this.Backpack ) )
                            return true;
                    }
                    else if ( bounce.m_Parent == this )
                    {
                        return true;
                    }
                }

                SendLocalizedMessage( 1004042 ); // You can only equip what you are already carrying while you have a trade pending.
                return false;
            }

            return true;
        }
Esempio n. 9
0
		public override bool OnDroppedItemToWorld(Item item, Point3D location)
		{
			if (!base.OnDroppedItemToWorld(item, location))
			{
				return false;
			}

			if (Core.AOS)
			{
				IPooledEnumerable mobiles = Map.GetMobilesInRange(location, 0);

				foreach (Mobile m in mobiles)
				{
					if (m.Z >= location.Z && m.Z < location.Z + 16)
					{
						mobiles.Free();
						return false;
					}
				}

				mobiles.Free();
			}

			BounceInfo bi = item.GetBounce();

			if (bi != null)
			{
				Type type = item.GetType();

				if (type.IsDefined(typeof(FurnitureAttribute), true) || type.IsDefined(typeof(DynamicFlipingAttribute), true))
				{
					var objs = type.GetCustomAttributes(typeof(FlipableAttribute), true);

					if (objs != null && objs.Length > 0)
					{
						FlipableAttribute fp = objs[0] as FlipableAttribute;

						if (fp != null)
						{
							var itemIDs = fp.ItemIDs;

							Point3D oldWorldLoc = bi.m_WorldLoc;
							Point3D newWorldLoc = location;

							if (oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y)
							{
								Direction dir = GetDirection4(oldWorldLoc, newWorldLoc);

								if (itemIDs.Length == 2)
								{
									switch (dir)
									{
										case Direction.North:
										case Direction.South:
											item.ItemID = itemIDs[0];
											break;
										case Direction.East:
										case Direction.West:
											item.ItemID = itemIDs[1];
											break;
									}
								}
								else if (itemIDs.Length == 4)
								{
									switch (dir)
									{
										case Direction.South:
											item.ItemID = itemIDs[0];
											break;
										case Direction.East:
											item.ItemID = itemIDs[1];
											break;
										case Direction.North:
											item.ItemID = itemIDs[2];
											break;
										case Direction.West:
											item.ItemID = itemIDs[3];
											break;
									}
								}
							}
						}
					}
				}
			}

			return true;
		}