So I'm not going to claim to be an expert scripter at all. In fact total newb.
I found this script and have been playing with it in my quest to learn C# and the ServUO world. I can get it to work however for some reason the shield always has double the luck of any of the other three items.
Makes no sense to me. Hoping someone can help.
Or explain what/why it is acting the way that it is.
Thanks in advance!
Current script:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server;
namespace Server.Items
{
public class LuckTarget : Target
{
private LuckDeed m_Deed;
public LuckTarget( LuckDeed deed ) : base( 1, false, TargetFlags.None )
{
m_Deed = deed;
}
protected override void OnTarget( Mobile from, object target )
{
if ( target is BaseWeapon || target is BaseShield || target is BaseArmor ) //*| target is BaseJewel |//*
//Note: weapon, basearmor, basejewel get 50 luck, shield is getting 100.
{
int augment = + 50;
int augmentper = + 50;
Item item = (Item)target;
if (item is BaseWeapon)
{
if ( ((BaseWeapon)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
else
{
if( item.RootParent != from ) from.SendMessage( "You can not put luck on that there!" );
else
{
((BaseWeapon)item).Attributes.Luck += augmentper;
from.SendMessage( "You magically add luck to your item...." );
m_Deed.Delete();
}
}
}
if (item is BaseShield)//gets 100 luck
{
if ( ((BaseShield)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
else
{
if( item.RootParent != from ) from.SendMessage( "You cannot put luck on that there!" );
else
{
((BaseShield)item).Attributes.Luck += augmentper;
from.SendMessage( "You magically add luck to your item...." );
m_Deed.Delete();
}
}
}
if (item is BaseArmor) //gets 50 luck
{
if ( ((BaseArmor)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
else
{
if( item.RootParent != from ) from.SendMessage( "You cannot put luck on that there!" );
else
{
((BaseArmor)item).Attributes.Luck += augmentper;
from.SendMessage( "You magically add luck to your item...." );
m_Deed.Delete();
}
}
}
//if (item is BaseJewel) //Gets 50 luck
//{
// if ( ((BaseJewel)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
// else
// {
// if( item.RootParent != from ) from.SendMessage( "You cannot put luck on that there!" );
// else
// {
// ((BaseJewel)item).Attributes.Luck += augmentper;
// from.SendMessage( "You magically add luck to your item...." );
// m_Deed.Delete();
// }
// }
//}
}
else from.SendMessage( "You can not put luck on that" );
}
}
public class LuckDeed : Item
{
[Constructable]
public LuckDeed() : base( 0x14F0 )
{
Name = "+100 Luck Increase deed";
Hue = 1260; //100 luck deed use 1260, for 300+ use 1259
Weight = 1.0;
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
list.Add( "<BASEFONT COLOR=#FFC300>\u0022Armor, Weapon and Shields\u0022<BASEFONT COLOR=#FFC300>" );
}
public LuckDeed(Serial serial) : base(serial){}
public override void Serialize( GenericWriter writer ) {base.Serialize( writer ); writer.Write( (int) 0 );}
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt();}
public override bool DisplayLootType{ get{ return false; } }
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) ) from.SendLocalizedMessage( 1042001 );
else
{
from.SendMessage("What item would you like to add luck to?" );
from.Target = new LuckTarget( this );
}
}
}
}
I found this script and have been playing with it in my quest to learn C# and the ServUO world. I can get it to work however for some reason the shield always has double the luck of any of the other three items.
Makes no sense to me. Hoping someone can help.
Or explain what/why it is acting the way that it is.
Thanks in advance!
Current script:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server;
namespace Server.Items
{
public class LuckTarget : Target
{
private LuckDeed m_Deed;
public LuckTarget( LuckDeed deed ) : base( 1, false, TargetFlags.None )
{
m_Deed = deed;
}
protected override void OnTarget( Mobile from, object target )
{
if ( target is BaseWeapon || target is BaseShield || target is BaseArmor ) //*| target is BaseJewel |//*
//Note: weapon, basearmor, basejewel get 50 luck, shield is getting 100.
{
int augment = + 50;
int augmentper = + 50;
Item item = (Item)target;
if (item is BaseWeapon)
{
if ( ((BaseWeapon)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
else
{
if( item.RootParent != from ) from.SendMessage( "You can not put luck on that there!" );
else
{
((BaseWeapon)item).Attributes.Luck += augmentper;
from.SendMessage( "You magically add luck to your item...." );
m_Deed.Delete();
}
}
}
if (item is BaseShield)//gets 100 luck
{
if ( ((BaseShield)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
else
{
if( item.RootParent != from ) from.SendMessage( "You cannot put luck on that there!" );
else
{
((BaseShield)item).Attributes.Luck += augmentper;
from.SendMessage( "You magically add luck to your item...." );
m_Deed.Delete();
}
}
}
if (item is BaseArmor) //gets 50 luck
{
if ( ((BaseArmor)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
else
{
if( item.RootParent != from ) from.SendMessage( "You cannot put luck on that there!" );
else
{
((BaseArmor)item).Attributes.Luck += augmentper;
from.SendMessage( "You magically add luck to your item...." );
m_Deed.Delete();
}
}
}
//if (item is BaseJewel) //Gets 50 luck
//{
// if ( ((BaseJewel)item).Attributes.Luck >= 200 ) from.SendMessage( "That already has luck!");
// else
// {
// if( item.RootParent != from ) from.SendMessage( "You cannot put luck on that there!" );
// else
// {
// ((BaseJewel)item).Attributes.Luck += augmentper;
// from.SendMessage( "You magically add luck to your item...." );
// m_Deed.Delete();
// }
// }
//}
}
else from.SendMessage( "You can not put luck on that" );
}
}
public class LuckDeed : Item
{
[Constructable]
public LuckDeed() : base( 0x14F0 )
{
Name = "+100 Luck Increase deed";
Hue = 1260; //100 luck deed use 1260, for 300+ use 1259
Weight = 1.0;
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
list.Add( "<BASEFONT COLOR=#FFC300>\u0022Armor, Weapon and Shields\u0022<BASEFONT COLOR=#FFC300>" );
}
public LuckDeed(Serial serial) : base(serial){}
public override void Serialize( GenericWriter writer ) {base.Serialize( writer ); writer.Write( (int) 0 );}
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt();}
public override bool DisplayLootType{ get{ return false; } }
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) ) from.SendLocalizedMessage( 1042001 );
else
{
from.SendMessage("What item would you like to add luck to?" );
from.Target = new LuckTarget( this );
}
}
}
}