RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Resource icon

[2.x] Lockpickable, Trappable Doors 0.7

No permission to download

Nemikal

Sorceror
Enroq,

This looks like a magnificent system, but to note it contains a lot of custom calls to systems I assume are yours and unreleased, such as rogue perks, scout perks, a DoorKnockEntry, and a TentFlap item.

Most of the rogue calls appear to just differentiate between a sound effect being played.


Code:
if (rge == null || !rge.SafeCracker())
                                from.PlaySound(0x4A);


There is also a single-click override in BaseDoor that calls to a Scout perk...

Code:
        public override void OnAosSingleClick(Mobile from)
        {
            base.OnSingleClick(from);
 
            if (from is Player)
            {
                Scout sct = Perk.GetByType<Scout>((Player)from);
 
                if (sct != null)
                    if (this.HasTrap() && sct.LabelTrappedDoor(this))
                        this.LabelTo(from, "[Trapped]");
            }
 
 
 
        }


BaseDoor also attempts to inherit a "ITrappable" class, which appears to be custom.

Finally, DoorGuillotineTrap makes use of a custom "TimedItem" class.

Commenting all of this out gives a successful compile, however there isn't any tool item to call the custom DefLocksmithing CraftSystem. I made a tool so I could test it out the DefLocksmithing functions, but I end up with a crash whenever I try to apply a lock:

Code:
System.MissingMethodException: No parameterless constructor defined for this object.
 

Enroq

Sorceror
Thank you for calling this to my attention, and please accept my apologies. I'll begin work on a solution.

+ Also, if there are any features you'd like to see in the future, please do not hesitate to suggest them.

++ I'm hoping that crash is simply caused by not having the Itrappable inheritance.
 

Nemikal

Sorceror
Thank you for calling this to my attention, and please accept my apologies. I'll begin work on a solution.

+ Also, if there are any features you'd like to see in the future, please do not hesitate to suggest them.

++ I'm hoping that crash is simply caused by not having the Itrappable inheritance.

I'm not sure if that was the case or not; I had worked out a work-around for it by cutting out the code from DefLocksmith and creating an item for it directly:

Code:
using System;
using Server.Engines.Craft;
using Server.Targeting;
using System.Collections;
using Server;
using Server.Multis;
using Server.Gumps;
using System.Collections.Generic;
using Server.ContextMenus;
 
namespace Server.Items
{
    [Flipable(0x1EB8, 0x1EB9)]
    public class LocksmithTools : Item
    {
        [Constructable]
        public LocksmithTools()
            : base(0x1EB8)
        {
            this.Weight = 1.0;
            this.Name = "Door Lock Installation Kit";
        }
 
        public LocksmithTools(Serial serial)
            : base(serial)
        {
        }
 
        public override void OnDoubleClick(Mobile from)
        {
            from.SendMessage("Select the door you would like to install a lock on.");
            from.Target = new DoorTarget(from, this);
        }
 
        private class DoorTarget : Target
        {
            private BaseDoor doortarget;
            private Mobile crafter;
            private LocksmithTools ltools;
 
            public DoorTarget(Mobile from, LocksmithTools tool)
                : base(-1, false, TargetFlags.None)
            {
                crafter = from;
                ltools = tool;
            }
 
            protected override void OnTarget(Mobile from, object targeted)
            {
 
                if (targeted is BaseDoor)
                {
                    BaseDoor door = targeted as BaseDoor;
 
                        if (door is BaseHouseDoor)
                        {
                            BaseHouse house = ((BaseHouseDoor)door).FindHouse();
 
                            if (house != null)
                            {
                                if (!house.IsFriend(from))
                                {
                                    from.SendMessage("You are not a friend of this house, and thus cannot install locks upon it's doors.");
                                    return;
 
                                }
                            }
                        }
 
                        if (door.RequiredSkill > (int)(from.Skills.Engineering.Value))
                        {
                          from.SendMessage("You lack the skill required to set up a lock on that door.");
                          return;
                        }
 
                        if (from.Map != door.Map || !from.InRange(door.GetWorldLocation(), 1))
                        {
                          from.SendMessage("You are too far away to install that lock!");
                          return;
                        }
 
                        if (!door.IsAccessibleTo(from))
                        {
                          from.SendMessage("You cannot access that door at this time.");
                          return;
                        }
 
                        if (door.HasLock)
                        {
                          from.SendMessage("That door already has a lock!");
                          return;
                        }
 
                        if (!door.IsLockable)
                          {
                          from.SendMessage("You cannot install a lock on that door!");
                          return;
                        }
 
 
                        else if (!door.Locked)
                        {
                            int level = (int)(from.Skills.Engineering.Value);
                            uint KeyValue;
 
                            Key key = new Key(KeyType.Iron, Key.RandomValue());
 
                            KeyValue = key.KeyValue;
                            from.AddToBackpack(key);
 
                            from.PlaySound(0x3A4);
                            from.SendMessage("You successfully install the lock. A key for the lock has been placed into your backpack.");
 
                            door.HasLock = true;
                            door.RequiredSkill = level - 20;
                            door.MaxLockLevel = level;
                            door.LockLevel = level - 10;
                            door.KeyValue = KeyValue;
                            door.Locked = true;
 
                            if (door.Link != null)
                            {
 
                                door.Link.HasLock = true;
                                door.Link.RequiredSkill = level - 20;
                                door.Link.MaxLockLevel = level;
                                door.Link.LockLevel = level - 10;
                                door.Link.KeyValue = KeyValue;
                                door.Locked = true;
                            }
 
                            ltools.Consume();
                        }
 
 
 
 
 
                }
                else
                {
                    from.SendMessage("You cannot install a door lock on that.");
                    return;
                }
            }
 
            protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
            {
                from.SendMessage("You decide against installing a lock at this time...");
                return;
            }
 
        }
 
        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();
        }
    }
}

The system works great from my testing, very great design my friend! I also found that, while the system works well on applying the properties on HouseDoors, I had to remove this override (in HouseDoor) for the HouseDoor to actually register the fact it uses locks:

Code:
        public override bool UseLocks()
        {
            BaseHouse house = FindHouse();
 
            return ( house == null || !house.IsAosRules );
        }

All in all, a very solid and interesting release. I'm eager to test out the DefLocksmithing again now that you've fixed it; I hadn't ever considered using craft menus like that. Very creative. Thanks for the contribution.
 

Nemikal

Sorceror
Ah, seems I forgot my own custom calls there too - thought I got them all. Substitute Tinkering for Engineering :)
 

Nemikal

Sorceror
Was that the reason you had to comment out UseLocks?

No, sir. I commented out UseLocks because it appeared that when applying your method I took from the original DefLockpicking, even though the BaseHouseDoor was properly set up (with all it's necessary props, keyvalue, etc.) after the successful lock installation, it appeared that "public override bool UseLocks()" forced the door to ignore the fact it could be locked and not accessed. I'm assuming because HouseDoors post-AOS were bestowed the ability to set Access Levels on them (evident from !house.IsAosRules).

Without knowing what ruleset you're using (or anyone else for that matter), it's hard to say that this should be an included or recommended edit - unless SecuritySettings and Access Levels have been disabled for House Doors, locks are useless, and incidentally, the use of your lock installation system on House Doors. I assumed that since you took the trouble in adding in HouseDoors that this behavior wasn't intended and/or anticipated, since it completely overrides all the hard work it took to get that lock installed onto that door. I myself have disabled the "securing" via Access Levels of House Doors (line 123 I think? Comment out : SetSecureLevelEntry.AddTo(from, this, list);). On this same note, the system you've created gives a very viable option to removing Access Levels/Security Settings on house doors and replacing it with the player-based functionality of installing locks on doors.

I use a very heavily modified RunUO release to suit a very niche RP-enforced community, so this may not be something everyone desires for their shard, but I found it was a logical thing to do for my purposes.

None the less, stellar work. This is really good stuff, Enroq.
 

Enroq

Sorceror
Another oversight on my part. I forgot to mention that AOS housing had to be disabled.

+ 0.6 will include AOS functionality.

Oh, and of course, thanks.

++ So, I guess I should explain that what you commented out was put there to disable the whole using the locks if it was AOS housing, because it causes it to be rendered pointless anyway, and may cause some conflicts.
 
Top