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!

[RunUO - ANY] DoubleClick Equip/Unequip/Swap (DeusX)

Xeevis

Sorceror
[RunUO - SVN] DoubleClick Equip/Unequip/Swap (DeusX)

Doubleclick Equip/Unequip/Swap by Xeevis (DeusX) -- 2.01
I was thinking how to reduce hassle players face when it comes to management of equipment. Tedious tasks like to remove equipment from paperdoll, put it right into bag, then equip new one its a pain especially for new players. This system solves just that as it handles everything on simple doubleclick like all other modern games these days.

Tested against SVN (710) with .NET Framework (2.0/4.0)

Features
  • 100% Working - No matter what combinations of equip you have, you always swap the right ones
  • Works From Anywhere - Equip from backpack, sub-container, locker, bank, ground anywhere where player has normal access to
  • Easy Integration - Change just 4 words and its already working for you.
  • Operation Feedback - Messages will tell player what he equipped/unequipped and what he swapped for what (even 3 way if shield is present!). These messages also retain hue of item being equipped for easier readability.
  • Smart Placement - When swapping items from container the equipped item will drop on the very same location as the one that swapped for it. No more hand moving if player has carefully placed equipment in bags.
  • Safe Use - Won't equip items which are far (2 tiles by default), cannot be moved (locked containers, other player backpacks etc) or don't specify layer. Also no swapping from corpses to prevent accidental swaps.
Installation

  1. Download file corresponding to .NET Framework version your RunUO is using (its my personal survey .NET 2.0 will work for everyone :p)
  2. Put CS file WearableItem.cs anywhere into your scripts folder (I suggest Scripts/Items)
  3. In BaseArmor.cs, BaseWeapon.cs, BaseJewel.cs, BaseClothing.cs change inheritance from Item to WearableItem
Example BaseArmor.cs change
public abstract class BaseArmor : Item, IScissorable, IFactionItem, ICraftable, IWearableDurability, ISetItem
to
public abstract class BaseArmor : WearableItem, IScissorable, IFactionItem, ICraftable, IWearableDurability, ISetItem

Do it in all 4 files, procedure is identical to example above.

4. Now its working!

Optionals: There are several distro edits you can make to enhance this system, this includes modifying of OnDoubleClick event for items which already implement their own but can still benefit from this system. These are mainly BaseSword, BaseKnife, BasePolearm and BaseAxe, but also miscs like GM suits (read Optionals.txt how to edit these)

Screenshot


Last Word
Please note that although safe to use, this system was tested only locally in all scenarios I could possibly think of. If you find any problem, please write in this topic, otherwise I'll be happy for any positive feedback.

Known Issues
Double-clicking items with translucent hue will cause client to crash, this is client related bug. If someone can give me all the translucent hue numbers I can add in handle for them to not work with this system.

Update 2.00
  • Script rewrote from scratch (renamed file and class to WearableItem instead of BaseWearable)
  • Cleaner code (updated to .NET 4.0, added comments, removed redundancies, removed duplicates, restyled code to match StyleCop guidelines)
  • Better performance
  • Better handling of items, no loner swaps items to ground, conflict will simply drop to backpack
  • Smart messages to give this system a slight RP touch
  • Added function WearableItem.EquipTo(Mobile) which allows you to easily equip any wearable item to any mobile and script will take care of swapping conflicts (by default for NPCs swapping will remove conflicting items, while for players it will drop them into their backpack ... this behavior is overrideable by passing optional parameter)
Update 2.01 <Critical update>
  • Fixed range check (can now equip only from 2 tiles)
  • If player doesn't meet stat requirement then conflicting item won't be unequipped (also will tell same message as with dragging)
  • Doubleclicking won't work if dclicked or conflicting item is not movable (to prevent unequipping of GM-locked gear on players etc)
Planned for future releases
  • Add sample EquipTo demonstration command [EquipTo that allows GM to select item and then mobile for which item is to be equipped. (When target item is container then it will dress mobile into everything inside, command will fail if container has 2 and more items that share same layer)
 

Attachments

  • Optionals.txt
    7.2 KB · Views: 168
  • WearableItem.NET2.cs
    9 KB · Views: 121
  • WearableItem.NET4.cs
    8.9 KB · Views: 129

Iomega0318

Sorceror
Wow.. awesome!
Thank you so much for this!

I have a limited version I set up for the same thing but items with their own OnDoubleClick method would not work..
I never really looked into it lol, but this just answered it for me and expanded it even more!
 

Fixxxer

Sorceror
thank you a lot, I was just looking through my old sever the other day looking for one i had like this.
 

chaoscreator

Wanderer
First off thank you awsome script.Made it feel like a little more of a modern MMO now.:D
Am having one problem tho BaseWearable doesnt seem to work on my suits (Optional).
Oh and not to sure how to set up the polearm and axe base edit (Optional2).There are already alot of if's in it and not sure exactly where to place the lines needed.:confused:
 

Midkemian

Sorceror
Very useful script!!

Awesome, thanks!

@chaoscreator -- It wasn't working for my LordBritishSuit and I discovered it was because the suit is set to movable=false (though my admin can move it just fine). I set it to movable=true in the props and it worked just fine after that.
 

Midkemian

Sorceror
@chaoscreator -- here is how I set up my OnDoubleClick methods for basepolarm and baseaxe:

basepolarm.cs:
Code:
public override void OnDoubleClick( Mobile from )
		{
			if ( from.FindItemOnLayer(this.Layer) == this )
			{
				if ( HarvestSystem == null )
					return;
					HarvestSystem.BeginHarvesting( from, this );
			}
			else
				base.OnDoubleClick( from );
		}

baseaxe.cs:
Code:
public override void OnDoubleClick( Mobile from )
		{
			if ( from.FindItemOnLayer(this.Layer) == this )
			{
				if ( HarvestSystem == null || Deleted )
					return;

				Point3D loc = this.GetWorldLocation();			

				if ( !from.InLOS( loc ) || !from.InRange( loc, 2 ) )
				{
					from.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 1019045 ); // I can't reach that
					return;
				}
				else if ( !this.IsAccessibleTo( from ) )
				{
					this.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 1061637 ); // You are not allowed to access this.
					return;
				}
			
				if ( !(this.HarvestSystem is Mining) )
					from.SendLocalizedMessage( 1010018 ); // What do you want to use this item on?
			
				HarvestSystem.BeginHarvesting( from, this );
			}
			else
				base.OnDoubleClick( from );
		}

I hope this helps!
 

Idrio

Sorceror
BasePoleArm :


Code:
public override void OnDoubleClick( Mobile from )
		{
			if ( HarvestSystem == null )
				return;

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

                HarvestSystem.BeginHarvesting(from, this);
            }
            else
                base.OnDoubleClick(from);
        }



baseaxe.cs:

Code:
		public override void OnDoubleClick( Mobile from )
		{
			if ( HarvestSystem == null || Deleted )
				return;

			Point3D loc = this.GetWorldLocation();

			if ( !from.InLOS( loc ) || !from.InRange( loc, 2 ) )
			{
				from.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 1019045 ); // I can't reach that
				return;
			}
			else if ( !this.IsAccessibleTo( from ) )
			{
				this.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 1061637 ); // You are not allowed to access this.
				return;
			}
			if (from.FindItemOnLayer(this.Layer) == this)
                                                          {
			if ( !(this.HarvestSystem is Mining) )
		                      from.SendLocalizedMessage( 1010018 ); // What do you want to use this item on?

			HarvestSystem.BeginHarvesting( from, this );
            }
            else
                base.OnDoubleClick(from);
        }
 

Xeevis

Sorceror
I see script reached 100 downloads thats good news :). Suggested code for first optional will work, however if you disable HarvestSystem on particular weapons (like if some magic axe shoudln't cut trees) then doubleclicking while equipped will do nothing. Its better if it could be unequipped for that you have to join expression like

BasePoleArm.cs
Code:
public override void OnDoubleClick( Mobile from )
{
	if ( from.FindItemOnLayer(this.Layer) == this && HarvestSystem != null )
		HarvestSystem.BeginHarvesting( from, this );
	else
		base.OnDoubleClick( from );
}
 

Xeevis

Sorceror
Ok folks I did complete rewrite of this system, read whats new in first post, not that it was broken but I'll need to do some outstanding edits in the future for my personal needs and while I was at it I did some enhancing here and there, hopefully i didn't break it all together :D.
 
I got an error with this part and in script it has a red error sqiggle So I removed this one part and seeing now if it compiles without errors.

bool? deleteConflictOverride = null
 

Xeevis

Sorceror
I haven't been to RunUO for a while sorry. I'm pretty sure i covered all these in optionals, take a look there, its attached to the first post. Can't remember what archetype are hammers, but pickaxe is BaseAxe and thats covered in 4th step in optionals.
 
Top