Announcement

Collapse
No announcement yet.

Errors with Interior Decorator Patch included with Knives' Town Houses

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Errors with Interior Decorator Patch included with Knives' Town Houses

    Greetings,

    I attempted to install the Interior Decorator patch included with Knive's Town Houses (v2.01 ). The Town Houses script itself works fine, but I received the following errors after installing the patch. Any help would be much appreciated. Thanks in advance!

    Code:
    Errors:
     + Items/Misc/InteriorDecorator.cs:
        CS0246: Line 298: The type or namespace name 'Tile' could not be found (are you missing a using directive or an assembly reference?)
        CS0029: Line 298: Cannot implicitly convert type 'Server.StaticTile[]' to 'Tile[]'
        CS0246: Line 304: The type or namespace name 'Tile' could not be found (are you missing a using directive or an assembly reference?)
    Here is my modified InteriorDecorator.cs:

    Code:
    ​​​​
    
    using System;
    using Server;
    using Server.Network;
    using Server.Regions;
    using Server.Multis;
    using Server.Gumps;
    using Server.Targeting;
    
    namespace Server.Items
    {
    public enum DecorateCommand
    {
    None,
    Turn,
    Up,
    Down
    }
    
    public class InteriorDecorator : Item
    {
    private DecorateCommand m_Command;
    
    [CommandProperty( AccessLevel.GameMaster )]
    public DecorateCommand Command{ get{ return m_Command; } set{ m_Command = value; InvalidateProperties(); } }
    
    [Constructable]
    public InteriorDecorator() : base( 0xFC1 )
    {
    Weight = 1.0;
    LootType = LootType.Blessed;
    }
    
    public override int LabelNumber{ get{ return 1041280; } } // an interior decorator
    
    public InteriorDecorator( Serial serial ) : base( serial )
    {
    }
    
    public override void GetProperties( ObjectPropertyList list )
    {
    base.GetProperties( list );
    
    if ( m_Command != DecorateCommand.None )
    list.Add( 1018322 + (int)m_Command ); // Turn/Up/Down
    }
    
    public override void Serialize( GenericWriter writer )
    {
    base.Serialize( writer );
    
    writer.Write( (int) 0 ); // version
    }
    
    public override void Deserialize( GenericReader reader )
    {
    base.Deserialize( reader );
    
    int version = reader.ReadInt();
    }
    
    public override void OnDoubleClick( Mobile from )
    {
    if ( !CheckUse( this, from ) )
    return;
    if ( from.FindGump( typeof( InteriorDecorator.InternalGump ) ) == null )
    from.SendGump( new InternalGump( this ) );
    
    if ( m_Command != DecorateCommand.None )
    from.Target = new InternalTarget( this );
    }
    
    public static bool InHouse( Mobile from )
    {
    BaseHouse house = BaseHouse.FindHouseAt( from );
    
    return ( house != null && house.IsCoOwner( from ) );
    }
    
    public static bool CheckUse( InteriorDecorator tool, Mobile from )
    {
    /*if ( tool.Deleted || !tool.IsChildOf( from.Backpack ) )
    from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
    else*/
    if ( !InHouse( from ) )
    from.SendLocalizedMessage( 502092 ); // You must be in your house to do this.
    else
    return true;
    
    return false;
    }
    
    private class InternalGump : Gump
    {
    private InteriorDecorator m_Decorator;
    
    public InternalGump( InteriorDecorator decorator ) : base( 150, 50 )
    {
    m_Decorator = decorator;
    
    AddBackground( 0, 0, 200, 200, 2600 );
    
    AddButton( 50, 45, ( decorator.Command == DecorateCommand.Turn ? 2154 : 2152 ), 2154, 1, GumpButtonType.Reply, 0 );
    AddHtmlLocalized( 90, 50, 70, 40, 1018323, false, false ); // Turn
    
    AddButton( 50, 95, ( decorator.Command == DecorateCommand.Up ? 2154 : 2152 ), 2154, 2, GumpButtonType.Reply, 0 );
    AddHtmlLocalized( 90, 100, 70, 40, 1018324, false, false ); // Up
    
    AddButton( 50, 145, ( decorator.Command == DecorateCommand.Down ? 2154 : 2152 ), 2154, 3, GumpButtonType.Reply, 0 );
    AddHtmlLocalized( 90, 150, 70, 40, 1018325, false, false ); // Down
    }
    
    public override void OnResponse( NetState sender, RelayInfo info )
    {
    DecorateCommand command = DecorateCommand.None;
    
    switch ( info.ButtonID )
    {
    case 1: command = DecorateCommand.Turn; break;
    case 2: command = DecorateCommand.Up; break;
    case 3: command = DecorateCommand.Down; break;
    }
    
    if ( command != DecorateCommand.None )
    {
    m_Decorator.Command = command;
    sender.Mobile.SendGump( new InternalGump( m_Decorator ) );
    sender.Mobile.Target = new InternalTarget( m_Decorator );
    }
    else
    Target.Cancel( sender.Mobile );
    }
    }
    
    private class InternalTarget : Target
    {
    private InteriorDecorator m_Decorator;
    
    public InternalTarget( InteriorDecorator decorator ) : base( -1, false, TargetFlags.None )
    {
    CheckLOS = false;
    
    m_Decorator = decorator;
    }
    
    protected override void OnTargetNotAccessible( Mobile from, object targeted )
    {
    OnTarget( from, targeted );
    }
    
    protected override void OnTarget( Mobile from, object targeted )
    {
    if ( targeted is Item && InteriorDecorator.CheckUse( m_Decorator, from ) )
    {
    BaseHouse house = BaseHouse.FindHouseAt( from );
    Item item = (Item)targeted;
    bool isDecorableComponent = false;
    
    if ( item is AddonComponent || item is AddonContainerComponent || item is BaseAddonContainer )
    {
    object addon = null;
    int count = 0;
    
    if ( item is AddonComponent )
    {
    AddonComponent component = (AddonComponent) item;
    count = component.Addon.Components.Count;
    addon = component.Addon;
    }
    else if ( item is AddonContainerComponent )
    {
    AddonContainerComponent component = (AddonContainerComponent) item;
    count = component.Addon.Components.Count;
    addon = component.Addon;
    }
    else if ( item is BaseAddonContainer )
    {
    BaseAddonContainer container = (BaseAddonContainer) item;
    count = container.Components.Count;
    addon = container;
    }
    
    if ( count == 1 && Core.SE )
    isDecorableComponent = true;
    
    if ( m_Decorator.Command == DecorateCommand.Turn )
    {
    FlipableAddonAttribute[] attributes = (FlipableAddonAttribute[]) addon.GetType().GetCustomAttributes( typeof( FlipableAddonAttribute ), false );
    
    if ( attributes.Length > 0 )
    isDecorableComponent = true;
    }
    }
    
    if ( house == null || !house.IsCoOwner( from ) )
    {
    from.SendLocalizedMessage( 502092 ); // You must be in your house to do this.
    }
    else if ( item.Parent != null || !house.IsInside( item ) )
    {
    from.SendLocalizedMessage( 1042270 ); // That is not in your house.
    }
    else if ( !house.IsLockedDown( item ) && !house.IsSecure( item ) && !isDecorableComponent )
    {
    if ( item is AddonComponent && m_Decorator.Command == DecorateCommand.Up )
    from.SendLocalizedMessage( 1042274 ); // You cannot raise it up any higher.
    else if ( item is AddonComponent && m_Decorator.Command == DecorateCommand.Down )
    from.SendLocalizedMessage( 1042275 ); // You cannot lower it down any further.
    else
    from.SendLocalizedMessage( 1042271 ); // That is not locked down.
    }
    else if ( item is VendorRentalContract )
    {
    from.SendLocalizedMessage( 1062491 ); // You cannot use the house decorator on that object.
    }
    else if ( item.TotalWeight + item.PileWeight > 100 )
    {
    from.SendLocalizedMessage( 1042272 ); // That is too heavy.
    }
    else
    {
    switch ( m_Decorator.Command )
    {
    case DecorateCommand.Up: Up( item, from ); break;
    case DecorateCommand.Down: Down( item, from ); break;
    case DecorateCommand.Turn: Turn( item, from ); break;
    }
    }
    }
    from.Target = new InternalTarget( m_Decorator );
    }
    protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
    {
    if ( cancelType == TargetCancelType.Canceled )
    from.CloseGump( typeof( InteriorDecorator.InternalGump ) );
    }
    
    private static void Turn( Item item, Mobile from )
    {
    if ( item is AddonComponent || item is AddonContainerComponent || item is BaseAddonContainer )
    {
    object addon = null;
    
    if ( item is AddonComponent )
    addon = ((AddonComponent) item).Addon;
    else if ( item is AddonContainerComponent )
    addon = ((AddonContainerComponent) item).Addon;
    else if ( item is BaseAddonContainer )
    addon = (BaseAddonContainer) item;
    
    FlipableAddonAttribute[] aAttributes = (FlipableAddonAttribute[]) addon.GetType().GetCustomAttributes( typeof( FlipableAddonAttribute ), false );
    
    if ( aAttributes.Length > 0 )
    {
    aAttributes[ 0 ].Flip( from, (Item) addon );
    return;
    }
    }
    
    FlipableAttribute[] attributes = (FlipableAttribute[]) item.GetType().GetCustomAttributes( typeof( FlipableAttribute ), false );
    
    if ( attributes.Length > 0 )
    attributes[ 0 ].Flip( item );
    else
    from.SendLocalizedMessage( 1042273 ); // You cannot turn that.
    }
    
    private static void Up( Item item, Mobile from )
    {
    int floorZ = GetFloorZ( item );
    
    if ( floorZ > int.MinValue && item.Z < (floorZ + 15) ) // Confirmed : no height checks here
    item.Location = new Point3D( item.Location, item.Z + 1 );
    else
    from.SendLocalizedMessage( 1042274 ); // You cannot raise it up any higher.
    }
    
    private static void Down( Item item, Mobile from )
    {
    int floorZ = GetFloorZ( item );
    
    if ( floorZ > int.MinValue && item.Z > GetFloorZ( item ) )
    item.Location = new Point3D( item.Location, item.Z - 1 );
    else
    from.SendLocalizedMessage( 1042275 ); // You cannot lower it down any further.
    }
    
    private static int GetFloorZ( Item item )
    {
    Map map = item.Map;
    
    if ( map == null )
    return int.MinValue;
    
    Tile[] tiles = map.Tiles.GetStaticTiles( item.X, item.Y, true );
    
    int z = int.MinValue;
    
    for ( int i = 0; i < tiles.Length; ++i )
    {
    Tile tile = tiles[i];
    ItemData id = TileData.ItemTable[tile.ID & 0x3FFF];
    
    int top = tile.Z; // Confirmed : no height checks here
    
    if ( id.Surface && !id.Impassable && top > z && top <= item.Z )
    z = top;
    }
    
    if ( z == int.MinValue )
    z = map.Tiles.GetLandTile( item.X, item.Y ).Z;
    
    return z;
    }
    }
    }
    }

  • #2
    I had the townhouse system installed for a few years on UO Evolution. I had the same problem with the interior decorator and a few custom items, crashing the shard because of the player townhouses. I did try this patch also and did not get it to work. We ended up rescripting and removing items.

    Warning: I ended up removing this system completely, even after I had fixed the major issues. It worked with a small population, but became a huge mess when our population reached over 300+players. With that much use from the players, it was apparent the script has many flaws from freezing the shard, missing items, created "broken" spots that would glitch stats etc. Unless you can rescript this, shards should beware before using this script
    UO Evolution "The Game Has Evolved"

    http://www.uoevolution.com
    http://www.uoevolution.com/forum
    http://www.uoevolution.com/wiki

    Comment


    • #3
      Originally posted by UO Evolution View Post
      I had the townhouse system installed for a few years on UO Evolution. I had the same problem with the interior decorator and a few custom items, crashing the shard because of the player townhouses. I did try this patch also and did not get it to work. We ended up rescripting and removing items.

      Warning: I ended up removing this system completely, even after I had fixed the major issues. It worked with a small population, but became a huge mess when our population reached over 300+players. With that much use from the players, it was apparent the script has many flaws from freezing the shard, missing items, created "broken" spots that would glitch stats etc. Unless you can rescript this, shards should beware before using this script

      Ah, thanks for the heads up! I may have to rethink using this. I do not expect to attract over 300 users, but it is possible. I am curious is anyone else has used the script and perhaps found a solution to the various issues.

      Comment


      • #4
        I just installed this 2 days ago. The tile issue is a reference that is now world tile. I posted an updated script that fixed the issue. I haven't tested much with it yet as I have no player base. Let me know what other issues you come across so I can keep an eye out for them.

        Comment


        • #5
          You need to restrict making a townhouse inside a player house.

          Also make sure a gm does not overlap 2 townhouses by accident.

          Several issues were encountered when you try to define multi leveled structures especially with odd shapes.

          Several townhouses became inaccessible to players and we had no explanation, but we had to wipe large areas around the house and the players lost all the items inside the house.

          The shard crashed when using the interior decorator

          If you freeze and unfreeze your shard there are serious issues

          Some areas are too large to define and if you make 2 bounding boxes it causes issues

          Rent collection did not work properly and needs work

          If you ever get a shard crash, it may not be recoverable! We opted to remove the entire system, but was a huge issue. Hundreds of players lost their townhomes and items, it was a complete mess and damaged the playerbase
          Last edited by UO Evolution; 02-09-2017, 01:40 PM.
          UO Evolution "The Game Has Evolved"

          http://www.uoevolution.com
          http://www.uoevolution.com/forum
          http://www.uoevolution.com/wiki

          Comment


          • #6
            Please keep me up to date with any code fixes or additions you make. I would like to recode this system in the future. The idea was great but the errors made this script unusable and destructive to any large shard
            UO Evolution "The Game Has Evolved"

            http://www.uoevolution.com
            http://www.uoevolution.com/forum
            http://www.uoevolution.com/wiki

            Comment


            • #7
              Knive's Town Houses 2.1 - Major Cleaned Up 2014-11-29 by Tresdni

              Knive's Townhouse Script

              I've converted most (99%) of the arrays to use List<>, converted many for each statements to use Linq, among hundreds of other edits to tidy this age old system up.

              Original credit to the original author, I just wanted to archive a cleaner copy.
              Attached Files
              RunUO - Ultima Online Emulator - www.runuo.net

              Comment


              • #8
                Here is the ServUO version of the townhouse system
                Attached Files
                RunUO - Ultima Online Emulator - www.runuo.net

                Comment


                • #9
                  RunUO Script Archive - Townhouse Script
                  http://downloads.runuo.net/index.php...es%20v2.01.zip

                  Townhouse Script 2.0
                  http://www.runuo.net/forum/forum/run...592-townhouses
                  RunUO - Ultima Online Emulator - www.runuo.net

                  Comment


                  • #10
                    Originally posted by admin View Post
                    Knive's Town Houses 2.1 - Major Cleaned Up 2014-11-29 by Tresdni

                    Knive's Townhouse Script

                    I've converted most (99%) of the arrays to use List<>, converted many for each statements to use Linq, among hundreds of other edits to tidy this age old system up.

                    Original credit to the original author, I just wanted to archive a cleaner copy.
                    Many thanks for posting this! Would it be possible to simply replace my existing version of the Townhouse script with this one without requiring setting up the houses again? I have set up quite an extensive amount.

                    Comment


                    • #11
                      No I imagine it will be a mess to remove and the new install would certainly need work. You would also have to set up all your custom work again
                      RunUO - Ultima Online Emulator - www.runuo.net

                      Comment


                      • #12
                        Originally posted by admin View Post
                        No I imagine it will be a mess to remove and the new install would certainly need work. You would also have to set up all your custom work again
                        Thanks! I was just wondering what I was in for before I start.

                        Comment

                        Working...
                        X