예제 #1
0
        public override void OnDoubleClick(Mobile from)
        {
            HouseRegion region = Region.Find(Location, Map) as HouseRegion;

            if (region != null)
            {
                BaseHouse house = region.House;

                if (house.IsOwner(from) || house.IsCoOwner(from))
                {
                    Movable = !Movable;

                    if (Movable)
                    {
                        house.Carpets.Remove(this);
                    }
                    else
                    {
                        house.Carpets.Add(this);
                    }

                    InvalidateProperties();
                }
                else
                {
                    // Only the home owner may lock this down.
                    from.SendLocalizedMessage(1113268);
                }
            }
        }
예제 #2
0
파일: NatureFury.cs 프로젝트: pallop/Servuo
        public void Target(IPoint3D point)
        {
            Point3D p   = new Point3D(point);
            Map     map = this.Caster.Map;

            if (map == null)
            {
                return;
            }

            HouseRegion r = Region.Find(p, map).GetRegion(typeof(HouseRegion)) as HouseRegion;

            if (r != null && r.House != null && !r.House.IsFriend(this.Caster))
            {
                return;
            }

            if (!map.CanSpawnMobile(p.X, p.Y, p.Z))
            {
                this.Caster.SendLocalizedMessage(501942); // That location is blocked.
            }
            else if (SpellHelper.CheckTown(p, this.Caster) && this.CheckSequence())
            {
                TimeSpan duration = TimeSpan.FromSeconds(this.Caster.Skills.Spellweaving.Value / 24 + 25 + this.FocusLevel * 2);

                NatureFury nf = new NatureFury();
                BaseCreature.Summon(nf, false, this.Caster, p, 0x5CB, duration);

                new InternalTimer(nf).Start();
            }

            this.FinishSequence();
        }
예제 #3
0
        public override void OnAfterDelete()
        {
            base.OnAfterDelete();

            if (m_Region != null)
            {
                m_Region.Unregister();
                m_Region = null;
            }

            if (m_Sign != null)
            {
                m_Sign.Delete();
            }

            if (m_Trash != null)
            {
                m_Trash.Delete();
            }

            if (m_Doors != null)
            {
                for (int i = 0; i < m_Doors.Count; ++i)
                {
                    Item item = (Item)m_Doors[i];

                    if (item != null && !item.Deleted)
                    {
                        item.Delete();
                    }
                }

                m_Doors.Clear();
            }

            if (m_Addons != null)
            {
                for (int i = 0; i < m_Addons.Count; i++)
                {
                    Item addon = (Item)m_Addons[i];
                    if (addon is Tent.TentChest && !addon.Deleted && addon.Map != Map.Internal && addon.Location != Point3D.Zero)
                    {
                        for (int j = 0; j < addon.Items.Count; j++)
                        {
                            ((Item)addon.Items[j]).MoveToWorld(addon.Location, addon.Map);
                        }
                    }

                    if (addon != null && !addon.Deleted)
                    {
                        addon.Delete();
                    }
                }

                m_Addons.Clear();
            }
        }
예제 #4
0
        public void Target(IPoint3D p)
        {
            IPoint3D orig = p;
            Map      map  = Caster.Map;

            SpellHelper.GetSurfaceTop(ref p);

            Point3D to = new Point3D(p);

            if (Server.Misc.WeightOverloading.IsOverloaded(Caster))
            {
                Caster.SendLocalizedMessage(502359, "", 0x22);                   // Thou art too encumbered to move.
            }
            else if (map == null || !map.CanFit(p.X, p.Y, p.Z, 16))
            {
                Caster.SendLocalizedMessage(501942);                   // That location is blocked.
            }
            else if (SpellHelper.CheckMulti(to, map))
            {
                Caster.SendLocalizedMessage(501942);                   // That location is blocked.
            }
            else if (CheckSequence())
            {
                SpellHelper.Turn(Caster, orig);

                Mobile m = Caster;

                Point3D from = m.Location;

                HouseRegion destRgn = Region.Find(to, m.Map) as HouseRegion;
                if (destRgn != null && destRgn.House != null)
                {
                    if ((m.Region == destRgn && destRgn.House is Multis.LargePatioHouse) || (m.Region != destRgn && destRgn.House.IsInside(to, 15)))
                    {
                        Caster.SendLocalizedMessage(501942);                           // That location is blocked.
                        return;
                    }
                }

                m.Location = to;
                m.ProcessDelta();

                Effects.SendLocationParticles(EffectItem.Create(from, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                Effects.SendLocationParticles(EffectItem.Create(to, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);

                m.PlaySound(0x1FE);
            }

            FinishSequence();
        }
예제 #5
0
        public BaseHouse(int multiID, Mobile owner, int MaxLockDown, int MaxSecure) : base(multiID)
        {
            m_BuiltOn    = DateTime.Now;
            m_LastTraded = DateTime.MinValue;

            m_Doors  = new ArrayList();
            m_Addons = new ArrayList();
            m_Region = new HouseRegion(this);

            m_Owner = owner;

            UpdateRegionArea();

            Movable = false;
        }
예제 #6
0
        public virtual void UpdateRegionArea()
        {
            if (m_Region != null)
            {
                m_Region.Unregister();
            }

            if (this.Map != null)
            {
                m_Region = new HouseRegion(this);
                m_Region.Register();
            }
            else
            {
                m_Region = null;
            }
        }
예제 #7
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_Region = new HouseRegion(this);

            switch (version)
            {
            case 0:
            {
                m_KeyValue          = reader.ReadUInt();
                m_Visits            = reader.ReadInt();
                m_Price             = reader.ReadInt();
                m_BuiltOn           = reader.ReadDateTime();
                m_LastTraded        = reader.ReadDateTime();
                m_Public            = reader.ReadBool();
                m_Region.GoLocation = reader.ReadPoint3D();
                if (version < 8)
                {
                    m_Price = DefaultPrice;
                }

                m_Owner = reader.ReadMobile();

                UpdateRegionArea();

                Region.AddRegion(m_Region);

                m_Sign  = reader.ReadItem() as HouseSign;
                m_Trash = reader.ReadItem() as TrashBarrel;

                m_Doors  = reader.ReadItemList();
                m_Addons = reader.ReadItemList();

                if ((Map == null || Map == Map.Internal) && Location == Point3D.Zero)
                {
                    Delete();
                }
                break;
            }
            }
        }
예제 #8
0
        public override void OnDelete()
        {
            BaseHouse        house   = BaseHouse.FindHouseAt((PelopsItem)this);
            Point3D          p       = new Point3D(this.X, this.Y, this.Z);
            Region           r       = Region.Find(p, this.Map);
            PlayerCityRegion cityreg = r as PlayerCityRegion;

            if (r.IsPartOf(typeof(HouseRegion)))
            {
                Point3D     v        = new Point3D(this.X, this.Y, this.Z);
                Region      u        = Region.Find(v, this.Map);
                HouseRegion housereg = u as HouseRegion;
                //house.SetLockdown( this, true );
            }
            else if (r.IsPartOf(typeof(PlayerCityRegion)))
            {
                foreach (Item i in World.Items.Values)
                {
                    if (i is CityManagementStone)
                    {
                        CityManagementStone s     = (CityManagementStone)i;
                        Point3D             q     = new Point3D(s.X, s.Y, s.Z);
                        Region           t        = Region.Find(q, s.Map);
                        PlayerCityRegion stonereg = t as PlayerCityRegion;
                        if (cityreg == stonereg)
                        {
                            ArrayList decore = s.isLockedDown;
                            if (decore == null)
                            {
                                s.isLockedDown = new ArrayList();
                                decore         = s.isLockedDown;
                            }
                            decore.Remove(this);
                            s.CurrentDecore -= 1;
                        }
                    }
                }
            }
            else
            {
                return;
            }
            base.OnDelete();
        }
예제 #9
0
        public virtual void UseGate(Mobile m)
        {
            int         flags       = m.Client == null ? 0 : m.Client.Flags;
            HouseRegion houseRegion = Region.Find(m_Target, m_TargetMap) as HouseRegion;

            if (Factions.Sigil.ExistsOn(m))
            {
                m.SendLocalizedMessage(1061632);                   // You can't do that while carrying the sigil.
            }
            else if (m_TargetMap == Map.Felucca && m is PlayerMobile && ((PlayerMobile)m).Young)
            {
                m.SendLocalizedMessage(1049543);                   // You decide against traveling to Felucca while you are still young.
            }
            else if ((m.Kills >= 5 && m_TargetMap != Map.Felucca) || (houseRegion != null && !houseRegion.House.HasAccess(m)))
            {
                m.SendLocalizedMessage(1019004);                   // You are not allowed to travel there.
            }
            else if (m.Spell != null)
            {
                m.SendLocalizedMessage(1049616);                   // You are too busy to do that at the moment.
            }
            else if (m_TargetMap != null && m_TargetMap != Map.Internal)
            {
                if (TeleportPets)
                {
                    BaseCreature.TeleportPets(m, m_Target, m_TargetMap);
                }

                m.MoveToWorld(m_Target, m_TargetMap);

                if (m.AccessLevel == AccessLevel.Player)
                {
                    m.PlaySound(0x1FE);
                }

                OnGateUsed(m);
            }
            else
            {
                m.SendMessage("This moongate does not seem to go anywhere.");
            }
        }
예제 #10
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }


            // Adam: remove assumption players region is non-null
            HouseRegion hr = from.Region as HouseRegion;

            // wea: are you in a tent? if so, 100% success
            if (from.CheckSkill(SkillName.Camping, 0.0, 100.0) || hr != null && hr.House is Tent)
            {
                Point3D loc;

                if (Parent == null)
                {
                    loc = Location;
                }
                else
                {
                    loc = from.Location;
                }

                Consume();

                // Pla: Don't show message if in non camping zone
                if (!CampHelper.InRestrictedArea(from))
                {
                    from.SendLocalizedMessage(500620); // You feel it would take a few moments to secure your camp.
                }

                new Campfire(from).MoveToWorld(loc, from.Map);
            }
            else
            {
                from.SendLocalizedMessage(501696);                   // You fail to ignite the campfire.
            }
        }
예제 #11
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove)
        {
            int Count = 0;

            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar)
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar
            }
            if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E))
            {
                return(HousePlacementResult.InvalidCastleKeep);
            }

            NoHousingRegion noHousingRegion = (NoHousingRegion)Region.Find(center, map).GetRegion(typeof(NoHousingRegion));

            if (noHousingRegion != null)
            {
                return(HousePlacementResult.BadRegion);
            }

            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);                   // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            List <Item>   items   = new List <Item>();
            List <Mobile> mobiles = new List <Mobile>();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            List <Point2D> yard = new List <Point2D>(), borders = new List <Point2D>();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             */

            HouseRegion HousingRegion = Region.Find(center, map) as HouseRegion;

            //if (HousingRegion != null)
            //return HousePlacementResult.Valid;

            for (int x = 0; x < mcl.Width; ++x)
            {
                for (int y = 0; y < mcl.Height; ++y)
                {
                    int tileX = start.X + x;
                    int tileY = start.Y + y;

                    StaticTile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;                         // There are no tiles here, continue checking somewhere else
                    }
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    Region reg = Region.Find(testPoint, map);

                    if (!reg.AllowHousing(from, testPoint))                         // Cannot place houses in dungeons, towns, treasure map areas etc
                    {
                        if (reg.IsPartOf(typeof(TempNoHousingRegion)))
                        {
                            return(HousePlacementResult.BadRegionTemp);
                        }

                        if (reg.IsPartOf(typeof(TreasureRegion)))
                        {
                            return(HousePlacementResult.BadRegionHidden);
                        }

                        return(HousePlacementResult.BadRegion);
                    }

                    LandTile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int      landID   = landTile.ID & TileData.MaxLandValue;

                    StaticTile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

                    Sector sector = map.GetSector(tileX, tileY);

                    items.Clear();

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

                        if (item.Visible && item.X == tileX && item.Y == tileY)
                        {
                            items.Add(item);
                        }
                    }

                    mobiles.Clear();

                    for (int i = 0; i < sector.Mobiles.Count; ++i)
                    {
                        Mobile m = sector.Mobiles[i];

                        if (m.X == tileX && m.Y == tileY)
                        {
                            mobiles.Add(m);
                        }
                    }

                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    for (int i = 0; i < addTiles.Length; ++i)
                    {
                        StaticTile addTile = addTiles[i];

                        if (addTile.ID == 0x1)                           // Nodraw
                        {
                            continue;
                        }

                        TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags;

                        bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                        bool hasSurface   = false;

                        if (isFoundation)
                        {
                            hasFoundation = true;
                        }

                        int addTileZ   = center.Z + addTile.Z;
                        int addTileTop = addTileZ + addTile.Height;

                        if ((addTileFlags & TileFlag.Surface) != 0)
                        {
                            addTileTop += 16;
                        }

                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            //    from.SendAsciiMessage("1");
                            return(HousePlacementResult.BadLand); // Broke rule #2
                        }

                        if (isFoundation && ((TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                        {
                            hasSurface = true;
                        }

                        //tower placement
                        BaseHouse house = BaseHouse.FindHouseAt(from);
                        if (house != null && house.Z + from.Z == house.Z + 66)
                        {
                            hasSurface = true;
                        }

                        for (int j = 0; j < oldTiles.Length; ++j)
                        {
                            StaticTile oldTile = oldTiles[j];
                            ItemData   id      = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue];

                            if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                            {
                                return(HousePlacementResult.BadStatic);                                // Broke rule #2
                            }

                            /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z )
                             *      hasSurface = true;*/
                        }

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

                            if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                            {
                                if (item.Movable)
                                {
                                    toMove.Add(item);
                                }
                                else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                {
                                    //from.SendAsciiMessage("3");
                                    return(HousePlacementResult.BadItem); // Broke rule #2
                                }
                            }

                            /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z )
                             * {
                             *      hasSurface = true;
                             * }*/
                        }

                        if (isFoundation && !hasSurface)
                        {
                            //from.SendAsciiMessage("4");
                            return(HousePlacementResult.NoSurface); // Broke rule #4
                        }

                        for (int j = 0; j < mobiles.Count; ++j)
                        {
                            Mobile m = mobiles[j];

                            if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                            {
                                toMove.Add(m);
                            }
                        }
                    }

                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1])
                        {
                            ++Count;
                        }
                    }

                    if (Count > 5)
                    {
                        //from.SendAsciiMessage("5");
                        return(HousePlacementResult.BadLand); // Broke rule #5
                    }

                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    StaticTile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool         shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        StaticTile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset - 1, tileY + yOffset - 1);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                }
            }

            /*for (int i = 0; i < yard.Count; ++i)
             *          {
             *                  Point2D yardPoint = (Point2D)yard[i];
             *
             *                  IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );
             *
             *                  foreach ( StaticTile[] tile in eable )
             *                  {
             *                          for ( int j = 0; j < tile.Length; ++j )
             *                          {
             *                                  if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 )
             *                                  {
             *                                          eable.Free();
             *              from.SendAsciiMessage("6");
             *                                          return HousePlacementResult.BadStatic; // Broke rule #3
             *                                  }
             *                          }
             *                  }
             *
             *                  eable.Free();
             *          }*/

            return(HousePlacementResult.Valid);

            /*if ( blockedLand || blockedStatic || blockedItem )
             * {
             *      from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
             * }
             * else if ( !foundationHasSurface )
             * {
             *      from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
             * }
             * else
             * {
             *      BaseHouse house = GetHouse( from );
             *      house.MoveToWorld( center, from.Map );
             *      this.Delete();
             *
             *      for ( int i = 0; i < toMove.Count; ++i )
             *      {
             *              object o = toMove[i];
             *
             *              if ( o is Mobile )
             *                      ((Mobile)o).Location = house.BanLocation;
             *              else if ( o is Item )
             *                      ((Item)o).Location = house.BanLocation;
             *      }
             * }*/
        }
예제 #12
0
        public static bool CanPlace(Mobile m, Point3D p, out BaseHouse house, bool message = true)
        {
            house = null;

            if (m == null || p == Point3D.Zero)
            {
                return(false);
            }

            HouseRegion r = m.Region.GetRegion <HouseRegion>();

            if (r == null || r.House == null || r.House.Deleted || r.House.Map == null || r.House.Map == Map.Internal)
            {
                if (message)
                {
                    m.SendMessage(0x22, "You must be inside a house to build a cellar.");
                }

                return(false);
            }

            house = r.House;

            if (house.Addons.OfType <CellarAddon>().Any())
            {
                if (message)
                {
                    m.SendMessage(0x22, "There is already a cellar in this house.");
                }

                return(false);
            }

            if (!house.Region.Contains(p))
            {
                if (message)
                {
                    m.SendMessage(0x22, "You may only build a cellar inside a house.");
                }

                return(false);
            }

            // 10z allows for the ground floor tile height, house foundation surface tops are typically z + 7
            if (Math.Abs(house.Z - p.Z) > 10)
            {
                if (message)
                {
                    m.SendMessage(0x22, "You may only build a cellar on the first floor of a house.");
                }

                return(false);
            }

            if (m.AccessLevel >= AccessLevel.GameMaster)
            {
                return(true);
            }

            if (!house.IsOwner(m))
            {
                if (message)
                {
                    m.SendMessage(0x22, "Only the house owner may build a cellar.");
                }

                return(false);
            }

            if (!house.Map.CanFit(p.X, p.Y, p.Z, 20, true, false, true))
            {
                if (message)
                {
                    m.SendMessage(0x22, "The cellar can't be built here because something is blocking the location.");
                }

                return(false);
            }

            return(true);
        }
예제 #13
0
        public virtual void UpdateRegion()
        {
            if ( m_Region != null )
                m_Region.Unregister();

            if ( this.Map != null )
            {
                m_Region = new HouseRegion( this );
                m_Region.Register();
            }
            else
            {
                m_Region = null;
            }
        }
예제 #14
0
        public override void OnAfterDelete()
        {
            base.OnAfterDelete();

            if ( m_Owner != null )
            {
                ArrayList list = (ArrayList) m_Table[m_Owner];

                if ( list == null )
                {
                    m_Table[m_Owner] = list = new ArrayList();
                }

                list.Remove( this );
            }

            if ( m_Region != null )
            {
                m_Region.Unregister();
                m_Region = null;
            }

            if ( m_Sign != null )
            {
                m_Sign.Delete();
            }

            if ( m_Trash != null )
            {
                m_Trash.Delete();
            }

            if ( m_Doors != null )
            {
                for ( int i = 0; i < m_Doors.Count; ++i )
                {
                    Item item = (Item) m_Doors[i];

                    if ( item != null )
                    {
                        item.Delete();
                    }
                }

                m_Doors.Clear();
            }

            if ( m_LockDowns != null )
            {
                for ( int i = 0; i < m_LockDowns.Count; ++i )
                {
                    Item item = (Item) m_LockDowns[i];

                    if ( item != null )
                    {
                        item.IsLockedDown = false;
                        item.IsSecure = false;
                        item.Movable = true;
                        item.SetLastMoved();
                    }
                }

                m_LockDowns.Clear();
            }

            if ( VendorRentalContracts != null )
            {
                for ( int i = 0; i < VendorRentalContracts.Count; ++i )
                {
                    Item item = (Item) VendorRentalContracts[i];

                    if ( item != null )
                    {
                        item.IsLockedDown = false;
                        item.IsSecure = false;
                        item.Movable = true;
                        item.SetLastMoved();
                    }
                }

                VendorRentalContracts.Clear();
            }

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

                    if ( info.Item is StrongBox )
                    {
                        info.Item.Destroy();
                    }
                    else
                    {
                        info.Item.IsLockedDown = false;
                        info.Item.IsSecure = false;
                        info.Item.Movable = true;
                        info.Item.SetLastMoved();
                    }
                }

                m_Secures.Clear();
            }

            if ( m_Addons != null )
            {
                for ( int i = 0; i < m_Addons.Count; ++i )
                {
                    Item item = (Item) m_Addons[i];

                    if ( item != null && !item.Deleted )
                    {
                        Item deed = null;

                        if ( item is BaseAddon ) // special case for BaseAddon, should use Redeed() method
                            deed = ( (BaseAddon) item ).Redeed();
                        else if ( item is IAddon )
                            deed = ( (IAddon) item ).Deed;

                        if ( deed != null )
                            deed.MoveToWorld( item.Location, item.Map );

                        item.Delete();
                    }
                }

                m_Addons.Clear();
            }

            if ( m_Addons != null )
            {
                for ( int i = 0; i < m_Addons.Count; ++i )
                {
                    Item item = (Item) m_Addons[i];

                    if ( item != null )
                    {
                        item.Movable = true;
                        item.SetLastMoved();
                        item.InvalidateProperties();
                    }
                }

                m_Addons.Clear();
            }

            if ( m_Carpets != null )
            {
                for ( int i = 0; i < m_Carpets.Count; ++i )
                {
                    Item carpet = (Item) m_Carpets[i];

                    if ( carpet != null )
                    {
                        carpet.Movable = true;
                        carpet.SetLastMoved();
                        carpet.InvalidateProperties();
                    }
                }
            }

            ArrayList inventories = new ArrayList( VendorInventories );

            foreach ( VendorInventory inventory in inventories )
            {
                inventory.Delete();
            }

            if ( MovingCrate != null )
            {
                MovingCrate.Delete();
            }

            KillVendors();

            m_AllHouses.Remove( this );
        }
예제 #15
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                from.SendLocalizedMessage(503248);                  //Your godly powers allow you to place this vendor whereever you wish.

                Mobile v = new PlayerVendor(from, BaseHouse.FindHouseAt(from));
                v.Direction = from.Direction & Direction.Mask;
                v.MoveToWorld(from.Location, from.Map);

                v.SayTo(from, 503246);                   // Ah! it feels good to be working again.

                this.Delete();
            }
            else
            {
                //find the house there at
                BaseHouse house = BaseHouse.FindHouseAt(from);

                // wea: allow placement within tents
                if (house == null)
                {
                    if (from.Region != null)
                    {
                        // is there a tent belonging to the person's account here though?
                        if (from.Region is HouseRegion)
                        {
                            HouseRegion hr = (HouseRegion)from.Region;

                            if ((hr.House is Tent || hr.House is SiegeTent) && hr.House.Owner.Account == from.Account)
                            {
                                house = ((HouseRegion)from.Region).House;
                            }
                        }
                    }
                }

                if (house == null)
                {
                    from.SendLocalizedMessage(503240);                      //Vendors can only be placed in houses.
                }
                else if (!house.IsFriend(from))
                {
                    from.SendLocalizedMessage(503242);                       //You must ask the owner of this house to make you a friend in order to place this vendor here,
                }
                else if (!house.Public)
                {
                    from.SendLocalizedMessage(503241);                      //You cannot place this vendor.  Make sure the building is public and you have not reached your vendor limit.
                }
                else if (!house.CanPlaceNewVendor())
                {
                    from.SendLocalizedMessage(503241);                       // You cannot place this vendor or barkeep.  Make sure the house is public or a shop and has sufficient storage available.
                }
                //else if (house.FindTownshipNPC() != null)
                else if (house.CanPlacePlayerVendorInThisTownshipHouse() == false)
                {
                    from.SendMessage("You cannot place a vendor in a house with the township NPCs present.");
                }
                else
                {
                    Mobile v = new PlayerVendor(from, house);
                    v.Direction = from.Direction & Direction.Mask;
                    v.MoveToWorld(from.Location, from.Map);

                    v.SayTo(from, 503246);                     // Ah! it feels good to be working again.

                    this.Delete();
                }
            }
        }