コード例 #1
0
        public override TimeSpan GetLogoutDelay(Mobile m)
        {
            if (m_House.IsFriend(m) && m_House.IsInside(m))
            {
                for (int i = 0; i < m.Aggressed.Count; ++i)
                {
                    AggressorInfo info = (AggressorInfo)m.Aggressed[i];

                    if (info.Defender.Player && (DateTime.Now - info.LastCombatTime) < CombatHeatDelay)
                    {
                        return(base.GetLogoutDelay(m));
                    }
                }

                return(TimeSpan.Zero);
            }
            else
            {
                try
                {
                    Mobile tsnpc = m_House.FindTownshipNPC();
                    if (tsnpc != null && tsnpc is TSInnKeeper)
                    {
                        if (m_House.IsInside(m))
                        {
                            TownshipRegion tr = TownshipRegion.GetTownshipAt(m);
                            if (tr != null)
                            {
                                if (tr.TStone != null && !tr.TStone.IsEnemy(m as PlayerMobile))
                                {
                                    for (int i = 0; i < m.Aggressed.Count; ++i)
                                    {
                                        AggressorInfo info = (AggressorInfo)m.Aggressed[i];

                                        if (info.Defender.Player && (DateTime.Now - info.LastCombatTime) < CombatHeatDelay)
                                        {
                                            return(base.GetLogoutDelay(m));
                                        }
                                    }

                                    return(TimeSpan.Zero);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Server.Commands.LogHelper.LogException(e);
                }
            }

            return(base.GetLogoutDelay(m));
        }
コード例 #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!m_Contract.IsUsableBy(from, false, true, true, true))
                {
                    return;
                }

                IPoint3D location = targeted as IPoint3D;

                if (location == null)
                {
                    return;
                }

                Point3D pLocation = new Point3D(location);
                Map     map       = from.Map;

                BaseHouse house = BaseHouse.FindHouseAt(pLocation, map, 0);

                if (house == null || !house.IsOwner(from))
                {
                    from.SendLocalizedMessage(1062338);                       // The location being rented out must be inside of your house.
                }
                else if (BaseHouse.FindHouseAt(from) != house)
                {
                    from.SendLocalizedMessage(1062339);                       // You must be located inside of the house in which you are trying to place the contract.
                }

                else if (!house.Public)
                {
                    from.SendLocalizedMessage(1062335);                       // Rental contracts can only be placed in public houses.
                }
                else if (house.FindTownshipNPC() != null)
                {
                    from.SendMessage("Rental contracts cannot be used in houses containing a Township NPC.");
                }
                else if (!map.CanFit(pLocation, 16, CanFitFlags.requireSurface))
                {
                    from.SendLocalizedMessage(1062486);                       // A vendor cannot exist at that location.  Please try again.
                }
                else
                {
                    m_Contract.MoveToWorld(pLocation, map);

                    if (!house.LockDown(from, m_Contract))
                    {
                        from.AddToBackpack(m_Contract);
                    }
                }
            }
コード例 #3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (Offeree != null)
            {
                from.SendLocalizedMessage(1062343);                   // That item is currently in use.
            }
            else if (!IsLockedDown)
            {
                if (!IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062334);                       // This item must be in your backpack to be used.
                    return;
                }

                BaseHouse house = BaseHouse.FindHouseAt(from);

                if (house == null || !house.IsOwner(from))
                {
                    from.SendLocalizedMessage(1062333);                       // You must be standing inside of a house that you own to make use of this contract.
                }

                else if (!house.Public)
                {
                    from.SendLocalizedMessage(1062335);                       // Rental contracts can only be placed in public houses.
                }

                else if (house.FindTownshipNPC() != null)
                {
                    from.SendMessage("Rental contracts cannot be used in houses containing a Township NPC.");
                }

                else
                {
                    from.SendLocalizedMessage(1062337);                     // Target the exact location you wish to rent out.
                    from.Target = new RentTarget(this);
                }
            }
            else if (IsLandlord(from))
            {
                if (from.InRange(this, 5))
                {
                    from.CloseGump(typeof(VendorRentalContractGump));
                    from.SendGump(new VendorRentalContractGump(this, from));
                }
                else
                {
                    from.SendLocalizedMessage(501853);                       // Target is too far away.
                }
            }
        }
コード例 #4
0
        public override TimeSpan GetLogoutDelay(Mobile m)
        {
            // prefer house region settings if we are a housing region
            if (m_Controller.IsHouseRegion == true)
            {
                BaseHouse house = BaseHouse.FindHouseAt(m);
                if (house != null)
                {
                    if (house.IsFriend(m) && house.IsInside(m))
                    {
                        for (int i = 0; i < m.Aggressed.Count; ++i)
                        {
                            AggressorInfo info = (AggressorInfo)m.Aggressed[i];

                            if (info.Defender.Player && (DateTime.Now - info.LastCombatTime) < CombatHeatDelay)
                            {
                                return(base.GetLogoutDelay(m));
                            }
                        }

                        return(TimeSpan.Zero);
                    }
                    else
                    {
                        try
                        {
                            Mobile tsnpc = house.FindTownshipNPC();
                            if (tsnpc != null && tsnpc is TSInnKeeper)
                            {
                                if (house.IsInside(m))
                                {
                                    TownshipRegion tr = TownshipRegion.GetTownshipAt(m);
                                    if (tr != null)
                                    {
                                        if (tr.TStone != null && !tr.TStone.IsEnemy(m as PlayerMobile))
                                        {
                                            for (int i = 0; i < m.Aggressed.Count; ++i)
                                            {
                                                AggressorInfo info = (AggressorInfo)m.Aggressed[i];

                                                if (info.Defender.Player && (DateTime.Now - info.LastCombatTime) < CombatHeatDelay)
                                                {
                                                    return(base.GetLogoutDelay(m));
                                                }
                                            }

                                            return(TimeSpan.Zero);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Scripts.Commands.LogHelper.LogException(e);
                        }
                    }

                    return(base.GetLogoutDelay(m));
                }
            }

            // if we are not a house (or there is no house at this location), use region controller settings
            if (m.Aggressors.Count == 0 && m.Aggressed.Count == 0 && IsInInn(m.Location))
            {
                return(m_Controller.InnLogoutDelay);
            }
            else
            {
                return(m_Controller.PlayerLogoutDelay);
            }
        }
コード例 #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_House.Deleted)
            {
                return;
            }

            Mobile from = sender.Mobile;

            bool isOwner   = m_House.IsOwner(from);
            bool isCoOwner = isOwner || m_House.IsCoOwner(from);
            bool isFriend  = isCoOwner || m_House.IsFriend(from);

            if (!isFriend || !from.Alive)
            {
                return;
            }

            Item sign = m_House.Sign;

            if (sign == null || from.Map != sign.Map || !from.InRange(sign.GetWorldLocation(), 18))
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 1:                     // Rename sign
            {
                from.Prompt = new RenamePrompt(m_House);
                from.SendLocalizedMessage(501302);                           // What dost thou wish the sign to say?

                break;
            }

            case 2:                     // List of co-owners
            {
                from.CloseGump(typeof(HouseGump));
                from.CloseGump(typeof(HouseListGump));
                from.CloseGump(typeof(HouseRemoveGump));
                from.SendGump(new HouseListGump(1011275, m_House.CoOwners, m_House));

                break;
            }

            case 3:                     // Add co-owner
            {
                if (isOwner)
                {
                    from.SendLocalizedMessage(501328);                               // Target the person you wish to name a co-owner of your household.
                    from.Target = new CoOwnerTarget(true, m_House);
                }
                else
                {
                    from.SendLocalizedMessage(501327);                               // Only the house owner may add Co-owners.
                }

                break;
            }

            case 4:                     // Remove co-owner
            {
                if (isOwner)
                {
                    from.CloseGump(typeof(HouseGump));
                    from.CloseGump(typeof(HouseListGump));
                    from.CloseGump(typeof(HouseRemoveGump));
                    from.SendGump(new HouseRemoveGump(1011274, m_House.CoOwners, m_House));
                }
                else
                {
                    from.SendLocalizedMessage(501329);                               // Only the house owner may remove co-owners.
                }

                break;
            }

            case 5:                     // Clear co-owners
            {
                if (isOwner)
                {
                    if (m_House.CoOwners != null)
                    {
                        m_House.CoOwners.Clear();
                    }

                    from.SendLocalizedMessage(501333);                               // All co-owners have been removed from this house.
                }
                else
                {
                    from.SendLocalizedMessage(501330);                               // Only the house owner may remove co-owners.
                }

                break;
            }

            case 6:                     // List friends
            {
                from.CloseGump(typeof(HouseGump));
                from.CloseGump(typeof(HouseListGump));
                from.CloseGump(typeof(HouseRemoveGump));
                from.SendGump(new HouseListGump(1011273, m_House.Friends, m_House));

                break;
            }

            case 7:                     // Add friend
            {
                if (isCoOwner)
                {
                    from.SendLocalizedMessage(501317);                               // Target the person you wish to name a friend of your household.
                    from.Target = new HouseFriendTarget(true, m_House);
                }
                else
                {
                    from.SendLocalizedMessage(501316);                               // Only the house owner may add friends.
                }

                break;
            }

            case 8:                     // Remove friend
            {
                if (isCoOwner)
                {
                    from.CloseGump(typeof(HouseGump));
                    from.CloseGump(typeof(HouseListGump));
                    from.CloseGump(typeof(HouseRemoveGump));
                    from.SendGump(new HouseRemoveGump(1011272, m_House.Friends, m_House));
                }
                else
                {
                    from.SendLocalizedMessage(501318);                               // Only the house owner may remove friends.
                }

                break;
            }

            case 9:                     // Clear friends
            {
                if (isCoOwner)
                {
                    if (m_House.Friends != null)
                    {
                        m_House.Friends.Clear();
                    }

                    from.SendLocalizedMessage(501332);                               // All friends have been removed from this house.
                }
                else
                {
                    from.SendLocalizedMessage(501319);                               // Only the house owner may remove friends.
                }

                break;
            }

            case 10:                               // Ban
            {
                from.SendLocalizedMessage(501325); // Target the individual to ban from this house.
                from.Target = new HouseBanTarget(true, m_House);

                break;
            }

            case 11:                               // Eject
            {
                from.SendLocalizedMessage(501326); // Target the individual to eject from this house.
                from.Target = new HouseKickTarget(m_House);

                break;
            }

            case 12:                     // List bans
            {
                from.CloseGump(typeof(HouseGump));
                from.CloseGump(typeof(HouseListGump));
                from.CloseGump(typeof(HouseRemoveGump));
                from.SendGump(new HouseListGump(1011271, m_House.Bans, m_House));

                break;
            }

            case 13:                     // Remove ban
            {
                from.CloseGump(typeof(HouseGump));
                from.CloseGump(typeof(HouseListGump));
                from.CloseGump(typeof(HouseRemoveGump));
                from.SendGump(new HouseRemoveGump(1011269, m_House.Bans, m_House));

                break;
            }

            case 14:                     // Transfer ownership
            {
                if (isOwner)
                {
                    from.SendLocalizedMessage(501309);                               // Target the person to whom you wish to give this house.
                    from.Target = new HouseOwnerTarget(m_House);
                }
                else
                {
                    from.SendLocalizedMessage(501310);                               // Only the house owner may do this.
                }

                break;
            }

            case 15:                     // Demolish house
            {
                if (isOwner)
                {
                    if (m_House.FindGuildstone() != null)
                    {
                        from.SendLocalizedMessage(501389);                                   // You cannot redeed a house with a guildstone inside.
                    }
                    else
                    {
                        from.CloseGump(typeof(HouseDemolishGump));
                        from.SendGump(new HouseDemolishGump(from, m_House));
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501320);                               // Only the house owner may do this.
                }

                break;
            }

            case 16:                     // Change locks
            {
                //if ( m_House.Public )
                //{
                //from.SendLocalizedMessage( 501669 );// Public houses are always unlocked.
                //}
                //else
                {
                    if (isOwner)
                    {
                        m_House.RemoveKeys(from);
                        m_House.ChangeLocks(from);

                        from.SendLocalizedMessage(501306);                                   // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack.
                    }
                    else
                    {
                        from.SendLocalizedMessage(501303);                                   // Only the house owner may change the house locks.
                    }
                }

                break;
            }

            case 17:                     // Declare public/private
            {
                if (isOwner)
                {
                    if (m_House.Public && m_House.FindPlayerVendor() != null)
                    {
                        from.SendLocalizedMessage(501887);                                   // You have vendors working out of this building. It cannot be declared private until there are no vendors in place.
                        break;
                    }

                    if (m_House.Public && m_House.FindTownshipNPC() != null)
                    {
                        from.SendMessage("You have a township npc in this building.  It cannot be declared private.");
                        break;
                    }

                    /*if ( !m_House.Public && m_House.LockBoxCount > 0 )
                     * {
                     *      from.SendMessage( "You have LockBoxes in this building. It cannot be made public until they are removed." );
                     *      break;
                     * }*/

                    m_House.Public = !m_House.Public;

                    if (!m_House.Public)
                    {
                        m_House.RemoveKeys(from);
                        m_House.ChangeLocks(from);
                        from.SendLocalizedMessage(501888);     // This house is now private.
                        from.SendLocalizedMessage(501306);     // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack.
                    }
                    else
                    {
                        //m_House.RemoveKeys( from );
                        //m_House.RemoveLocks();
                        from.SendLocalizedMessage(501886);                                  //This house is now public. Friends of the house my now have vendors working out of this building.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501307);                               // Only the house owner may do this.
                }

                break;
            }

            case 18:                     // Change type
            {
                if (isOwner)
                {
                    if (m_House.Public && info.Switches.Length > 0)
                    {
                        int index = info.Switches[0] - 1;

                        if (index >= 0 && index < 53)
                        {
                            m_House.ChangeSignType(2980 + (index * 2));
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501307);                               // Only the house owner may do this.
                }

                break;
            }
            }
        }