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!

DoubleClick Equip/Unequip/Swap (DeusX) - not working properly on 2.3

Desttro

Traveler
Hi,
has anyone tried this script on latest 2.3 RunUO from GoogleCode? [RunUO - SVN] DoubleClick Equip/Unequip/Swap (DeusX)
Everything is fine, but swap not working. For example, I have katana in hand and want double click at halberd and I expecting that will swap it, but nothing happened. No message, no action. I have .NET 4 version.

Has anyone tried this?

Thank you!
 

Soteric

Knight
Double clicking on any pole arms is reserved for lumberjacking. How do you expect it to behave when Swap system is installed?
 

Desttro

Traveler
I mean when I double click on item in backpack. For example I will have 2 weapons in backpack katana and LBA and empty hands. I will double click at katana = equip katana. So, now I will double click at LBA in back pack and I expecting that katana will be replaced in hands for LBA - swap.
That same with armor and clothing. I have edited BaseSword, BasePolearm, ....

example:

old:

public override void OnDoubleClick(Mobile from)
{
from.SendLocalizedMessage(1010018); // What do you want to use this item on?

from.Target = new BladedItemTarget(this);
}

new:

public override void OnDoubleClick(Mobile from)
{
if (from.FindItemOnLayer(this.Layer) == this)
{
from.SendLocalizedMessage(1010018); // What do you want to use this item on?

from.Target = new BladedItemTarget(this);
}
else
{
base.OnDoubleClick(from);
}
}

Its here in thread: http://www.runuo.com/community/threads/runuo-any-doubleclick-equip-unequip-swap-deusx.101161/

At image, there is that swap what I described must working, but not.
 

Desttro

Traveler
Here is it
 

Attachments

  • BasePoleArm.cs
    3.8 KB · Views: 3
  • BaseWeapon.cs
    104.6 KB · Views: 3
  • WearableItem.cs
    8.9 KB · Views: 1

Desttro

Traveler
It seems you have to add some console messages to understand what's going on.

Now I don't understand you. What console messages? I don't have any messages in console. You mean that I need enable debug in WearableItem script? Thank you.
 

Soteric

Knight
I mean you have to add "Console.WriteLine("message1/2/3");" lines to OnDoubleClick and EquipTo methods. So you can follow the execution flow and find the problem piece of code. There are too much if/else statements in this code and it's difficult to understand what's going on without console messages.
 

Enroq

Sorceror
Maybe it's just me but I can't even remember the last time you could equip weapons by double clicking them. Or anything for that matter.

Also, I don't even see an OnDoubleClick in your baseweapon. You should also note it passes through BaseMeleeWeapon before reaching baseweapon.

++ You might be able to cast it as a basemeleeweapon and just stick with editing baseweapon.cs
 

Desttro

Traveler
I mean you have to add "Console.WriteLine("message1/2/3");" lines to OnDoubleClick and EquipTo methods. So you can follow the execution flow and find the problem piece of code. There are too much if/else statements in this code and it's difficult to understand what's going on without console messages.

Thank you for your advice, I found solution.

In WeareableItem.cs is this OnDoubleClick code:
Code:
public override void OnDoubleClick(Mobile from)
        {
            if (this.Parent == from && this.Movable)
            {
                // Player dclicked item on their paperdoll so we just put it into their backpack and accompany it with cool message.
                if (from.Backpack.TryDropItem(from, this, true))
                {
                    var typeString = this is BaseWeapon ? "sheated" : this is BaseClothing ? "folded" : "stored";
                    from.SendMessage(this.Hue, "You {0} {1} into your backpack.", typeString, this.Name);
                }
                return;
            }
 
            if (!this.IsAccessibleTo(from) || this.Layer == Layer.Invalid || this.Parent is Corpse || from.Backpack == null || !this.CanEquip(from)
                || !this.Movable)
            {
                // Lets not do something crazy like equipping unequippable/unreachable item
                // Also we don't want corpses to be handled in any way as players could possibly swap their rare item for some junk in there
                return;
            }
 
            if (!from.InRange(GetWorldLocation(), 2))
            {
                from.SendLocalizedMessage(500295); // You are too far away to do that.
                return;
            }
            this.EquipTo(from);
        }

There is problem with this condition:
Code:
            if (!this.IsAccessibleTo(from) || this.Layer == Layer.Invalid || this.Parent is Corpse || from.Backpack == null || !this.CanEquip(from)
                || !this.Movable)
            {
                // Lets not do something crazy like equipping unequippable/unreachable item
                // Also we don't want corpses to be handled in any way as players could possibly swap their rare item for some junk in there
                return;
            }

When I remove condition !this.CanEquip(from) everything is working. But I don't understand this. In Item.cs is definiton of CanEquip:
Code:
public virtual bool CanEquip( Mobile m )
 
        {
 
            return ( m_Layer != Layer.Invalid && m.FindItemOnLayer( m_Layer ) == null );
 
        }
And I think that condition !this.CanEquip(from) is all right, or no?
 

Desttro

Traveler
Maybe it's just me but I can't even remember the last time you could equip weapons by double clicking them. Or anything for that matter.

Also, I don't even see an OnDoubleClick in your baseweapon. You should also note it passes through BaseMeleeWeapon before reaching baseweapon.

++ You might be able to cast it as a basemeleeweapon and just stick with editing baseweapon.cs

I'm creating shard for people, who played on Sphere shard. There was this double click system for equip something. So, I need it :)
 

daat99

Moderator
Staff member
Unlike Enroq I prefer debugging with console lines more than with an IDE.
This is due to the fact that it's easier to dump tons of information to a log file (using the console output) and than figure out the exact flow of the program even when it uses multi-threaded environment without influencing the environment by "breaking" execution in an IDE.

Please keep in mind that most of this isn't really valid for RunUO but adding a console output is a lot easier to most people than to figure out how to use an advanced IDE like Visual Studio (it's easier to explain how to add console outputs as well).

All in all it's always best to know how to use an IDE to debug and then decide for yourself which is better in each situation.

I use them both in my day-job as a software developer and mostly in conjunction with each other.
 

Enroq

Sorceror
Don't listen to daat, there's a reason breakpoints exist - he's just doing one of his "oh don't forget my dick's big too" things.

Furthermore, if you're doing things because they're easier, it's the wrong path.
 

daat99

Moderator
Staff member
I have no idea why you take so much offense from someone else not agreeing with you that you need to be rude about it...

Let's face it, not everybody think alike.
I recognize the value in console outputs and I noted as such.
You can say that you think it's wrong but you can't ever say that it doesn't have ANY advantages... (if you do than you obviously never encountered the situation where it has yet and until you do that doesn't matter much).
 

Enroq

Sorceror
I was thinking about it and that seemed kind of ambiguous. I was being quite serious, it's a far-cry from your usual locking of posts, and I appreciate it.

(I couldn't edit anymore)
 

daat99

Moderator
Staff member
I tend not to lock posts unless they go very off-topic and become inflammatory to the point where people click the "report" button on it.

I did get the impression that you were serious in your initial reply so everything is OK on my side of it.

In order to illustrate why I still value console output very much I'll give you a real life example that I encounter on a daily basis at my work.

We have a server/client architecture which uses multi-threaded operations and keep-alive packets.

If the code flow of the client stops for more than 30 seconds than the keep-alive packets from the server aren't being responded and the server treats the session as disconnected and closes all the sockets and communication must be restarted from the "hello" packet.

This kind of a scenario doesn't allow the developer to use break points in order to debug the execution flow because it usually disrupts the keep-alive process and change the state of the server/client communication.

90% of the time the only way to debug issues which require server/client communications is by using debug outputs (usually by using breakpoints which dumps data to the output window instead of breaking execution).

This is why I always value the usage of console outputs and not always go straight to breakpoints.

I just want to clarify that I do use breakpoints a lot and they are very valuable in most situations.
 

Enroq

Sorceror
I tend not to lock posts unless they go very off-topic and become inflammatory to the point where people click the "report" button on it.

Let's be honest, you close posts when they personally offend you or you're told you're wrong. You locked a post because I told you that you were wrong about the usage of newline. That's called abuse of power, my friend, and that's my point.

Also, I'd like you to visit this website and look through this neural network written by a senior MS developer.
http://www.quaetrix.com/NeuralNetworkDemo.html

Then hit ctrl+f and search "\n"
 

daat99

Moderator
Staff member
I don't recall ever locking a post because someone told me I was wrong.
Maybe the post in question became inflammatory in some manner, I'll have to see the thread to make any meaningful comment on the subject though.

I see from the link you posted that this particular developer likes to use '\n' a lot.
Does that mean this is the best approach?

I encountered a lot of genius level developers when I worked at Intel (and communicated with developers from Microsoft where both our companies had a common interest in specific development project).
Not all of them always did the right thing and they admitted to it more than once.
I use '\n' a lot as well, that doesn't make it the right choice either.

The '\n' character is OS specific and as such is considered a bad practice.
C# provides developers with a cross-OS alternative that is considered the right approach (Environment.NewLine).
That doesn't mean I'm going to always use it, that just means that when I'm not using it than I'm doing something that is NOT considered "best practice".

In either case you (and everybody else) are entitled to your own opinion, even if it goes against mine.
I have no intention of locking threads because people doesn't agree with me.

I will however lock threads where people complain about off-topic and rude posts.

If you want to continue discussing this I prefer to do it in PM.
I would like to let this thread get back on topic just in case Desttro wants more help with his issue.
 
Top