Gargouille
Sorceror
[RunUO 2.0 RC1] Customizable WeaponAbilities
WeaponAbilities are client-side. The client get abilities regarding to ItemID, whatever you try to do in the scripts.
What I propose to you is to cut off communication between server and client, regarding WeaponAbilities, and so replace it with a server-side system.
Cut off communication server-client:
In ScriptsItemsWeaponsAbilitiesWeaponAbility.cs find and delete (or comment) the Initialize method :
Then the EventSink_SetAbility will not be call no more, you can comment it too (or leave it just unuse):
Add a new WeaponAbility system:
Just add these files in your scripts directory :
Then in ScriptsItemsWeaponsAbilitiesWeaponAbility.cs, find the ClearCurrentAbility method and modify it like this :
Allow it in game :
You can lauch the gump via a command, a macro or whatever you want.
Here' s a way to automaticaly launch the gump when equiping a weapon :
In ScriptsItemsWeaponsBaseWeapon.cs, find the OnEquip method, and insert this new line just before the ending return true; :
Now find the OnRemove method and insert this line at the bottom of the method ( but just before the coma that ends the if ( parent is Mobile ) ) :
Some bad things with it (no refreshing for example) were fix by Lord GreyWolf, by using a command lauching gump : attached file SpecialAttacksCommand.cs
And for using macro, use another file by LordGreyWolf : SpecialAttackCommands.cs.
Just change the declaration in the wanted weapon script :
With CustomWeaponAbilities.cs and CustomWeaponAbilitiesGump.cs as it is release at that time, you can go up till five abilities... Look in scripts, that is not hard to make 6, 7... where do we stop
( Thanks Lord GreyWolf for the help )
You just have, in order to use them, to declare in ScriptsItemsWeaponsBaseWeapon.cs the additional Abilities :
And then overriding them in your weapons, if you need or want to.
If you do not, the Ability keeps null value, there's no problem.
You can give 5 abilities to a weapon, and just 2 to another...
Just don't assign a value for example to the ForthAbility without having assign one else to the ThirdAbility...
And now, you got to make these two modifications in ScriptsItemsWeaponsAbilitiesWeaponAbility.cs,
in the IsWeaponAbility method :
and in the GetRequiredSkill method :
NOTE : the additionaly abilities required 120, 140 and 160 % skill, if you want to change this, you got to do it both in WeaponAbility/GetRequiredSkill and CustomWeaponAbilities/HasAbilities...
NOTE : you can also easily change requirement, in order to allow a third (or else) ability to a race, a class, another skill than weapon.DefSkill...
For example :in a weapon, you can declare an Ability like that :
And then serialize it, and set or not a value to the WeaponAbility as you want, when crafted, regarding to crafter skill level, or many maners... Then a weaponability can be for a weapon and not for all weapons of that type...
In ScriptsItemsWeaponsAbilitiesWeaponAbility.cs find the
and increase the length, regarding how many abilities you want to add...
Then add your new abilities at the end of the list.
Then, find that kind of lines :
and add yours, with the good index.
Then, what about the icons for new abilities ?
First you can merge your .mul with new icons, and place them just behind abilities ones...
But you can also insert this line in ScriptsItemsWeaponsAbilitiesWeaponAbility.cs:
You can now define what existing gump you want for that ability, just modify it in your NewAbility script.
And to make in works with the gump, just replace Icons int value definitions in CustomAbilitiesGump.cs, like this :
You now just have to script yours.
... or use LordGreyWolf ones here : http://www.runuo.com/forums/custom-script-releases/93773-new-weapon-abilities.html
Will be edited as soon as an error occurs
All occurences of "Fourth" were "Forth", as shown by Miller when releasing his Changeable Weapon Abilities...
It is now fixed, but if you want to use Lord GreyWolf's new Weapon Abilities, you will need to fix it too.
This is more a HowTo rather than a ready to use system, but it will let you :
- Create a weapon with abilities you wanted
- Create weapons with more than two abilities
- Create new abilities
WeaponAbilities are client-side. The client get abilities regarding to ItemID, whatever you try to do in the scripts.
What I propose to you is to cut off communication between server and client, regarding WeaponAbilities, and so replace it with a server-side system.
Cut off communication server-client:
In ScriptsItemsWeaponsAbilitiesWeaponAbility.cs find and delete (or comment) the Initialize method :
Code:
/*public static void Initialize()
{
EventSink.SetAbility += new SetAbilityEventHandler( EventSink_SetAbility );
}*/
Code:
/*private static void EventSink_SetAbility( SetAbilityEventArgs e )
{
int index = e.Index;
if ( index == 0 )
ClearCurrentAbility( e.Mobile );
else if ( index >= 1 && index < m_Abilities.Length )
SetCurrentAbility( e.Mobile, m_Abilities[index] );
}*/
Add a new WeaponAbility system:
Just add these files in your scripts directory :
- CustomWeaponAbilities.cs
- CustomWeaponAbilitiesGump.cs
Then in ScriptsItemsWeaponsAbilitiesWeaponAbility.cs, find the ClearCurrentAbility method and modify it like this :
Code:
public static void ClearCurrentAbility( Mobile m )
{
m_Table.Remove( m );
//NEW
CustomWeaponAbilities.Check(m);
return;
//NEW
if ( Core.AOS && m.NetState != null )
m.Send( ClearWeaponAbility.Instance );
}
Allow it in game :
You can lauch the gump via a command, a macro or whatever you want.
Here' s a way to automaticaly launch the gump when equiping a weapon :
In ScriptsItemsWeaponsBaseWeapon.cs, find the OnEquip method, and insert this new line just before the ending return true; :
Code:
public override bool OnEquip( Mobile from )
{
[ int strBonus = ... ]
CustomWeaponAbilities.Check(this,from);//NEW
return true;
}
Now find the OnRemove method and insert this line at the bottom of the method ( but just before the coma that ends the if ( parent is Mobile ) ) :
Code:
public override void OnRemoved( object parent )
{
if ( parent is Mobile )
{
[...]
CustomWeaponAbilities.Check(m);//NEW
}
}
Some bad things with it (no refreshing for example) were fix by Lord GreyWolf, by using a command lauching gump : attached file SpecialAttacksCommand.cs
And for using macro, use another file by LordGreyWolf : SpecialAttackCommands.cs.
ONCE ALL THAT THINGS ARE DONE YOU WILL BE ABLE TO CHOOSE WHATEVER ABILITY YOU WANT FOR A WEAPON !
Just change the declaration in the wanted weapon script :
Code:
public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.CrushingBlow; } }
public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.ArmorIgnore; } }
BUT YOU CAN ALSO ADD ADDITIONALY ABILITIES !
With CustomWeaponAbilities.cs and CustomWeaponAbilitiesGump.cs as it is release at that time, you can go up till five abilities... Look in scripts, that is not hard to make 6, 7... where do we stop
( Thanks Lord GreyWolf for the help )
You just have, in order to use them, to declare in ScriptsItemsWeaponsBaseWeapon.cs the additional Abilities :
Code:
public virtual WeaponAbility ThirdAbility{ get{ return null; } }//NEW
public virtual WeaponAbility ForthAbility{ get{ return null; } }//NEW
public virtual WeaponAbility FifthAbility{ get{ return null; } }//NEW
Code:
public override WeaponAbility ThirdAbility{ get{ return WeaponAbility.NewOne; } }//NEW
public virtual WeaponAbility ForthAbility{ get{ return WeaponAbility.BleedAttack; } }//NEW
public virtual WeaponAbility FifthAbility{ get{ return WeaponAbility.DoubleShot; } }//NEW
You can give 5 abilities to a weapon, and just 2 to another...
Just don't assign a value for example to the ForthAbility without having assign one else to the ThirdAbility...
And now, you got to make these two modifications in ScriptsItemsWeaponsAbilitiesWeaponAbility.cs,
in the IsWeaponAbility method :
Code:
public static bool IsWeaponAbility( Mobile m, WeaponAbility a )
{
if ( a == null )
return true;
if ( !m.Player )
return true;
BaseWeapon weapon = m.Weapon as BaseWeapon;
return ( weapon != null && (weapon.PrimaryAbility == a || weapon.SecondaryAbility == a || weapon.ThirdAbility == a || weapon.ForthAbility == a || weapon.FifthAbility == a) );//NEW
}
Code:
public virtual double GetRequiredSkill( Mobile from )
{
BaseWeapon weapon = from.Weapon as BaseWeapon;
if ( weapon != null && weapon.PrimaryAbility == this )
return 70.0;
else if ( weapon != null && weapon.SecondaryAbility == this )
return 90.0;
else if ( weapon != null && weapon.ThirdAbility == this )//NEW
return 120.0;
else if ( weapon != null && weapon.ThirdAbility == this )//NEW
return 140.0;
else if ( weapon != null && weapon.ThirdAbility == this )//NEW
return 160.0;
return 200.0;
}
NOTE : the additionaly abilities required 120, 140 and 160 % skill, if you want to change this, you got to do it both in WeaponAbility/GetRequiredSkill and CustomWeaponAbilities/HasAbilities...
NOTE : you can also easily change requirement, in order to allow a third (or else) ability to a race, a class, another skill than weapon.DefSkill...
For example :in a weapon, you can declare an Ability like that :
Code:
public override WeaponAbility ThirdAbility{ get{ return PrivateNonStaticAbility; } }//NEW
private WeaponAbility m_PrivateNonStaticAbility;
public WeaponAbility PrivateNonStaticAbility
{
get { return m_PrivateNonStaticAbility;}
set { m_PrivateNonStaticAbility = value;}
}
AND NOW, WHAT ABOUT CREATING NEW ABILITIES ??
In ScriptsItemsWeaponsAbilitiesWeaponAbility.cs find the
Code:
private static WeaponAbility[] m_Abilities = new WeaponAbility[30]
Then add your new abilities at the end of the list.
Then, find that kind of lines :
Code:
public static readonly WeaponAbility ArmorIgnore = m_Abilities[ 1];
Then, what about the icons for new abilities ?
First you can merge your .mul with new icons, and place them just behind abilities ones...
But you can also insert this line in ScriptsItemsWeaponsAbilitiesWeaponAbility.cs:
Code:
public virtual int CustomGump{ get{ return 0xDB;}}//NEW
And to make in works with the gump, just replace Icons int value definitions in CustomAbilitiesGump.cs, like this :
Code:
private int PrimaryIcon {get{return Primary<30?0x51FF+Primary:WeaponAbility.Abilities[Primary].CustomGump;}}
private int SecondaryIcon {get{return Secondary<30?0x51FF+Secondary:WeaponAbility.Abilities[Secondary].CustomGump;}}
private int ThirdIcon {get{return Third<30?0x51FF+Third:WeaponAbility.Abilities[Third].CustomGump;}}
private int ForthIcon {get{return Forth<30?0x51FF+Forth:WeaponAbility.Abilities[Forth].CustomGump;}}
private int FifthIcon {get{return Fifth<30?0x51FF+Fifth:WeaponAbility.Abilities[Fifth].CustomGump;}}
You now just have to script yours.
... or use LordGreyWolf ones here : http://www.runuo.com/forums/custom-script-releases/93773-new-weapon-abilities.html
Will be edited as soon as an error occurs
All occurences of "Fourth" were "Forth", as shown by Miller when releasing his Changeable Weapon Abilities...
It is now fixed, but if you want to use Lord GreyWolf's new Weapon Abilities, you will need to fix it too.