Than924
Member
- ServUO Version
- Publish Unknown
- Ultima Expansion
- Endless Journey
I'm using Pub 54 and am messing with the Rune Crafting scripts and I would like to change it so that on a failure it removes durability from the item instead of completely destroying it. I have it working exactly how I want, but I'm having a small issue with the syntax for the durability.
I used the original Utility.Random() to determine if the enhancement succeeds or fails, then a second Utility.Random() to determine if the failure reduces durability or completely destroys the item.
Here is a snip of the file, and the line in question is 44. I'm not exactly sure what syntax to use to remove 1 durability.
The script does not compile due to line 44 (I've been messing with the syntax). I used a different syntax to get it to compile (Weapon.HitPoints +=1
and that has Rune Crafting successes and failures and on failures it sometimes destroys the item, sometimes not, but when it doesn't, it doesn't reduce the durability of the item.
I used the original Utility.Random() to determine if the enhancement succeeds or fails, then a second Utility.Random() to determine if the failure reduces durability or completely destroys the item.
Here is a snip of the file, and the line in question is 44. I'm not exactly sure what syntax to use to remove 1 durability.
The script does not compile due to line 44 (I've been messing with the syntax). I used a different syntax to get it to compile (Weapon.HitPoints +=1
C#:
protected override void OnTarget( Mobile from, object targeted )
{
int DestroyChance = Utility.Random( 3 );
int augmentper = Utility.Random( 5 ) + 1;
if ( targeted is Item ) // protects from crash if targeting a Mobile.
{
Item item = (Item) targeted;
if ( !from.InRange( ((Item)targeted).GetWorldLocation(), 3 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else if (( ((Item)targeted).Parent != null ) && ( ((Item)targeted).Parent is Mobile ) )
{
from.SendMessage( "You cannot enhance that in it's current location." );
}
else if ( targeted is BaseWeapon )
{
BaseWeapon Weapon = targeted as BaseWeapon;
{
if ( DestroyChance > 0 ) // Success
{
Weapon.WeaponAttributes.HitFireArea += augmentper;
from.SendMessage( "The Rune enhances your weapon." );
from.PlaySound( 0x1F5 );
m_HitFireAreaRune.Delete();
}
else // Fail
{
int TotalDestroy = Utility.Random(3);
{
if (TotalDestroy > 0) // Damages Equipment
{
from.SendMessage( "You have failed to enhance the weapon!" );
from.SendMessage( "The weapon has been damaged!" );
from.PlaySound( 42 );
Weapon.WeaponDurabilityLevel += 1;
m_HitFireAreaRune.Delete();
}
else //Total Destroy
{
from.SendMessage( "You have failed to enhance the weapon!" );
from.SendMessage( "The weapon is damaged beyond repair!" );
from.PlaySound( 42 );
Weapon.Delete();
m_HitFireAreaRune.Delete();
}
}
}
}
}
else
{
from.SendMessage( "You cannot enhance that." );
}
}
}
}
public override bool DisplayLootType{ get{ return false; } } // ha ha!
public HitFireAreaRune( Serial serial ) : base( serial )
{
}
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();
}