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 2.0 RC1] Customizable WeaponAbilities

Karmageddon;784145 said:
Ok Callander did you have to make any mods to any of the original scripts in this package? Or does it work as it is? If you got it working then share what you did to get it working. Also I do not want to patch any muls at this time, so if the flag gumps need mul patching then I am not going to use that.

Yes the gump files need to be patched for the custom abilities to use Icons. Other than that it works as is no other mods.
 

Miller.

Wanderer
If you just want to use the currently available weapon specials, then no mul patching is necessary. The little flag beside the icon turns red when the special is toggled without any patch. If you want to use the custom-created weapon specials, then you'll obviously have to patch to get the newly designed ability icons.

Here's my pic, fresh install up to SVN 301, client 6.0.11.0, using the custom weapon abilities gump. This is with Infect and AI on a broadsword. Note that Infect is toggled, and the flag beside the icon is red.
 

Attachments

  • custom-weapons-client.jpg
    custom-weapons-client.jpg
    154.6 KB · Views: 140

Miller.

Wanderer
Ok, I've found a bug and a couple quirks.

First, and most importantly, if you select a special ability and then de-select it (turn it off), the ability still fires. It seems the only way to turn an ability off, once selected, is to fire it off or to select another ability. (This happened with both the [set1 toggle command that Lord_Greywolf came up with and also with simply clicking the icons on and off)

Second, you can only move the gump by clicking and dragging the flag, not any other part of the gump (the icons, the little strap).

Third, there's no way to rearrange the way the icons on the gump stack. I can anticipate some people wanting to link their special ability icons side-by-side rather than one on top of the other.

(The second and third I assume just deal with the way the gump is set up, and I should probably just fix that to my liking. Just have to learn about gump making. But I included them here for ideas.)
 

Karmageddon

Sorceror
Lord_Greywolf;783932 said:
does it show the little flags, but not the icons, or doesnot show the gump at all?


It shows nothing at all. I have tried the latest files that are posted here and still nothing at all. I even tried patching my client version up one to 6.0.10.0 and still nothing.Still don't understand how you guys got it to work with higher client versions and no mods....
 
The custom abilities will not show an icon if you don't patch the mul files. So in order to see the custom abiilties gumps you will need to patch the mul files. Which are provided by Lord GreyWolf in the other thread. The standard abilities should still show the gump on the screen though.
 
did you also make the changes so the old weapon abilities book is useless?
if you do not do that, then might not be able to get this one to work
 

Karmageddon

Sorceror
Yes I made all the edits that are stated in the first post. In testing on the same server this worked fine for lower client version but not my higher client version. So it is not any problem with the way the scripts are working for lower clients. The problem is for higher clients.
 

Miller.

Wanderer
Miller.;784159 said:
First, and most importantly, if you select a special ability and then de-select it (turn it off), the ability still fires. It seems the only way to turn an ability off, once selected, is to fire it off or to select another ability. (This happened with both the [set1 toggle command that Lord_Greywolf came up with and also with simply clicking the icons on and off)

I can't seem to find a solution to this problem, but the script seems to be missing a check to find out if an ability is set, then on re-toggle it gets cleared (turn the ability OFF before it is actually used). I've narrowed it down to the "SetServerSideAbility" and "SetAbilities" sections of CustomWeaponAbilities.cs but I have no idea how to implement the check. Anyone able to help me out with this?
 

Miller.

Wanderer
Miller.;784159 said:
First, and most importantly, if you select a special ability and then de-select it (turn it off), the ability still fires. It seems the only way to turn an ability off, once selected, is to fire it off or to select another ability. (This happened with both the [set1 toggle command that Lord_Greywolf came up with and also with simply clicking the icons on and off)

Does anyone else even have this problem? Basically what happens is that I set my primary special ability, and then decide not to use it. So I toggle it off. But the special ability still executes even though I had toggled it off.

Here's where I'm looking so far:
CustomWeaponAbilities.cs
Code:
		public static bool ServerSideSetAbility(Mobile from, int index)
		{
			if ( index == 0 )
				[COLOR="Red"]WeaponAbility.ClearCurrentAbility( from );[/COLOR]
			else if ( index >= 1 && index < WeaponAbility.Abilities.Length )
			{
				if(WeaponAbility.SetCurrentAbility( from, WeaponAbility.Abilities[index] ))
					return true;
			}
			return false;
		}
Am I even on the right track to fix this issue?
 

Miller.

Wanderer
Alright, I figured it out. In

CustomWeaponAbilitiesGump.cs
Code:
public override void OnResponse( NetState sender, RelayInfo info )
		{
			int idx = info.ButtonID;
			if(idx==0) sender.Mobile.CloseGump(typeof(CustomWeaponAbilitiesGump));
			if(idx==1)
			{
				if(PrimaryState==9781)
				{
					if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Primary))
					{
						PrimaryState=9780;
						SecondaryState=9781;
						ThirdState=9781;
						ForthState=9781;
						FifthState=9781;
					}
				}
				[COLOR="Red"]else PrimaryState=9781;[/COLOR]
				sender.Mobile.CloseGump(typeof(CustomWeaponAbilitiesGump));
				sender.Mobile.SendGump(new CustomWeaponAbilitiesGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));
			}
...

That needs to be changed to:

else
{
PrimaryState=9781;
WeaponAbility.ClearCurrentAbility( sender.Mobile );
}




This edit needs to be repeated for as many levels of special attacks that you have. This clears the special ability if it has previously been toggled.
 

Miller.

Wanderer
Hey no prob. I figured the low response to the problem meant that I should dive in and keep crackin' until I figured it out. I've benefited from the bugfixes of so many others, it's about time I did some more contributing. ;)
 

Gargouille

Sorceror
Hi, I'm coming long after the battle ^^

Thanks Miller for the fix.

But then, both mobile.CloseGump and SendGump methods must be inserted in the first block :

Code:
if(idx==1)
{
      if(PrimaryState==9781)
	{
		if(CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile,Primary))
		{
			PrimaryState=9780;
			SecondaryState=9781;
			ThirdState=9781;
			ForthState=9781;
			FifthState=9781;
		}
		[COLOR="Lime"]sender.Mobile.CloseGump(typeof(CustomWeaponAbilitiesGump));
		sender.Mobile.SendGump(new CustomWeaponAbilitiesGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, ForthState, FifthState));[/COLOR]
	}
	else
	{
		PrimaryState=9781;
		WeaponAbility.ClearCurrentAbility( sender.Mobile );
	}
}

I will edit released files tomorrow ;o)
 

Miller.

Wanderer
Gargouille;783384 said:
Thanks LordGreyWolf, I merge your file in initial post.

And Miller, yes, it's possible to give a value to the abilities during the craft, randomly or not. Abilities are not more "static like members" but really instances ones...

I'm creating a deed so that, upon use, the player can select a new PrimaryAbility for their weapon (the one that's currently equipped). For testing purposes, in the DoubleClick I inserted this line:

weapon.PrimaryAbility = WeaponAbility.CrushingBlow;

But I get this error:
CS0200: Line 49: Property or indexer 'Server.Items.BaseWeapon.PrimaryAbility' cannot be assigned to -- it is read only

How exactly do I change a weapon's primary ability after it has been created?
 
can't with out doing some rewtiting in base weapons, it can only be set by an override in its script currently

you would have to make the property viirtual, and put in get/sets for it also and then serialize/deserialize then also so it can stick and not revert back

then in all the weapon scripts - in all the places where it says override of the weapon abilities, you would have to change them to be in the constructor part and assign them in there
 

Miller.

Wanderer
Ok, help me out here with a little more detail. In my BaseWeapon.cs I have these lines at 99 & 100:
Code:
		public virtual WeaponAbility PrimaryAbility{ get{ return null; } }
		public virtual WeaponAbility SecondaryAbility{ get{ return null; } }
This is also in the virtual region, so it appears that the properties are indeed virtual. (Unless I misunderstand something)
So it appears I need to put something like this:
Code:
		[CommandProperty( AccessLevel.GameMaster )]
		public WeaponAbility PrimaryAbility
		{
			get{ return m_Primary; }
			set{ m_Primary = value; InvalidateProperties(); }
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public WeaponAbility SecondaryAbility
		{
			get{ return m_Secondary; }
			set{ m_Secondary = value; InvalidateProperties(); }
		}
in the Getters & Setters region, and then add a flag to the serialization as follows:
Code:
			SetSaveFlag( ref flags, SaveFlag.Primary,			m_Primary != WeaponAbility.None );
			SetSaveFlag( ref flags, SaveFlag.Secondary,			m_Secondary != WeaponAbility.None );
and
Code:
			if ( GetSaveFlag( flags, SaveFlag.Primary ) )
				writer.Write( (int)m_Primary );
			if ( GetSaveFlag( flags, SaveFlag.Secondary ) )
				writer.Write( (int)m_Secondary );
and then in the Save Flags enum:
Code:
			Primary					= 0x????????,
			Secondary				= 0x????????,
(I have no idea what the enumerations are for or what they do - need help with this)

and then in the deserialization, in case 5:
Code:
					if ( GetSaveFlag( flags, SaveFlag.Primary ) )
						m_Primary = (WeaponAbility)reader.ReadInt();

					if ( GetSaveFlag( flags, SaveFlag.Secondary ) )
						m_Secondary = (WeaponAbility)reader.ReadInt();

THEN, in each weapon script, make sure that the overrides are in the constructor region so that the abilities are saved with each individual item.

Does this sound good or am I overlooking something?
 
look about right

but you need to change the overrides in the weapon scripts to just setting them in the constructor (an override makes it so it can not be changed)
i.e. (this is not accurate, just approx)
remove override
name = what ever
primaryability = weaponability.thisability
 

Miller.

Wanderer
I've been commenting out the overrides in each weapon script, and then adding something like this to each constructor:

WeaponAbility PrimaryAbility = WeaponAbility.InfectiousStrike;

I've got to change every weapon before I can get the thing to compile. I tried just removing the weps to get a quick barometer reading on if it's going to work or not, but so many other scripts are dependant on them (the wep scripts) that it's just easier to go ahead and modify them. I'll get it completed later on tonight, hopefully, and post back whether it works or not. If so, it's going to be sweet! Players able to change weapon abilities on each weapon = complete battle customization.
 

Miller.

Wanderer
Alright, I've got all the weapons changed. All the SE weps, and all the ML weps too. Now I'm getting this error:
Errors:
+ Items/Weapons/BaseWeapon.cs:
CS0030: Line 2534: Cannot convert type 'Server.Items.WeaponAbility' to 'int'

CS0030: Line 2536: Cannot convert type 'Server.Items.WeaponAbility' to 'int'

CS0030: Line 2751: Cannot convert type 'int' to 'Server.Items.WeaponAbility'

CS0030: Line 2754: Cannot convert type 'int' to 'Server.Items.WeaponAbility'


Here's the code it's referencing:
Lines 2533-2536
Code:
            if (GetSaveFlag(flags, SaveFlag.Primary))
                writer.Write((int)m_Primary);
            if (GetSaveFlag(flags, SaveFlag.Secondary))
                writer.Write((int)m_Secondary);
and lines 2750-2754
Code:
                    if (GetSaveFlag(flags, SaveFlag.Primary))
                        m_Primary = (WeaponAbility)reader.ReadInt();

                    if (GetSaveFlag(flags, SaveFlag.Secondary))
                        m_Secondary = (WeaponAbility)reader.ReadInt();

Know what's going on here?
 
Top