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!

Chop Sleepable Beds Bug.

Lionar

Wanderer
Hello everyone. I'm having some problems with some addons. These are Sleepable Beds, a particular type of beds that let u rest increasing your Sleep value. The problem is that i cannot understand why i cannot Chop this. Here is the code:

Code:
using System;
using Server;
using Server.Multis;
using Server.Mobiles;
 
namespace Server.Items
{
 
    public class SleepableFutonEWBedAddon : SleepableBedsAddon, IChopable, IAddon
{
 
public override BaseAddonDeed Deed
{ get {
return new SleepableFutonEWBedDeed();
} }
 
public override Direction BedDirection{ get { return Direction.East; } }
public override Point3D GetBodyLocation()
{
return new Point3D(this.Location.X+1, this.Location.Y, this.Location.Z+6);
}
 
public SleepableFutonEWBedAddon( Serial serial ) : base( serial )
{
}
 
[Constructable]
public SleepableFutonEWBedAddon( ) : base ()
{
AddComponent( new SleepableBedsPiece(this, 10590), 0, 0, 0 );
}
     
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
}
}
 
public class SleepableFutonEWBedDeed : SleepableBedsDeed
{
public override BaseAddon Addon
{ get {
return new SleepableFutonEWBedAddon();
} }
 
[Constructable]
public SleepableFutonEWBedDeed()
{
Name = "a sleepable futon facing east deed.";
}
 
public SleepableFutonEWBedDeed( Serial serial ) : base ( serial )
{
}
 
public override void Serialize ( GenericWriter writer )
{
base.Serialize ( writer );
writer.Write ( 0 ); // Version
}
 
public override void Deserialize ( GenericReader reader )
{
base.Deserialize ( reader );
int version = reader.ReadInt();
}
}
}

Code:
 using System;
using System.Collections;
using Server;
using Server.Network;
using Server.Mobiles;
using Server.Gumps;
using Server.Multis;
using Server.Targeting;
 
namespace Server.Items
{
 
[PropertyObject]
public class SleepableBedsAddon: BaseAddon, IChopable
{
private bool m_Active = true;
private Mobile m_Player;
private SleeperBedBody m_SleeperBedBody;
private Mobile m_Owner;
 
private int wtry;
 
[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get{ return m_Active; }
set{ m_Active = value; InvalidateProperties(); }
}
 
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Mobile
{
get{ return m_Player; }
set
{ 
 
if( value != null )
m_Active = true;
 
m_Player = value; 
InvalidateProperties();
}
}
 
[CommandProperty( AccessLevel.GameMaster )]
public SleeperBedBody SleeperBody
{
get{ return m_SleeperBedBody; }
set{ m_SleeperBedBody = value; InvalidateProperties(); }
}
 
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; InvalidateProperties(); }
}
 
[CommandProperty( AccessLevel.GameMaster )]
public virtual Direction BedDirection { get { return Direction.East; } }
 
 
[CommandProperty( AccessLevel.GameMaster )]
public virtual Point3D BodyLocation{ get { return GetBodyLocationM(); }
set{
m_BodyLocation = value;
InvalidateProperties();
m_SleeperBedBody.Location = m_BodyLocation;
} }
 
private Point3D m_BodyLocation = Point3D.Zero;
 
public virtual Point3D GetBodyLocationM()
{
return ( m_BodyLocation != Point3D.Zero ? m_BodyLocation : GetBodyLocation());
}
 
public virtual Point3D GetBodyLocation()
{
return new Point3D(this.Location.X, this.Location.Y, this.Location.Z);
}
 
 
[CommandProperty( AccessLevel.GameMaster )]
public virtual Point3D BodyLocationMod{ get { return GetBodyLocationMod(); }
set{
m_BodyLocation = new Point3D( this.Location.X + value.X, this.Location.Y + value.Y, this.Location.Z + value.Z );
InvalidateProperties();
m_SleeperBedBody.Location = m_BodyLocation;
} }
 
public virtual Point3D GetBodyLocationMod()
{
if( m_BodyLocation == Point3D.Zero ) m_BodyLocation = GetBodyLocation();
return new Point3D(m_BodyLocation.X - this.Location.X, m_BodyLocation.Y - this.Location.Y, m_BodyLocation.Z - this.Location.Z);
}
 
 
public SleepableBedsAddon( Serial serial ) : base( serial )
{
}
 
 
public SleepableBedsAddon( )
{
Visible = true;
Name = "Sleepable Beds";
 
}
 
public void DoubleClick( Mobile from )
{ 
PlayerMobile pl = from as PlayerMobile;
if ( pl ==null)
return;
if ( !from.CanSee( this ) )
from.SendLocalizedMessage( 500237 ); 
 
if (!pl.InRange( GetWorldLocation(), 1 ))
{
 
from.SendLocalizedMessage( 500446 ); 
}
else if (!m_Active)
{
                pl.SendMessage("Stai già dormendo da qualche parte.");
}
else if (pl.Mounted)
{
pl.SendMessage("Dovresti scendere dalla tua cavalcatura prima di dormire.");
}
 
else if (pl.Sleep >= 30 && pl.AccessLevel == AccessLevel.Player )
{
pl.SendMessage("Ti senti Riposato");
}
else if (pl.Combatant != null && pl.AccessLevel == AccessLevel.Player )
{
pl.SendMessage("Non puoi dormire se sei in combattimento!!");
}
 
else if ( !BedAcces( pl ) )
{
pl.SendMessage("Non è il tuo letto!!");
}
 
else
{
 
if( m_Player == null )
{
wtry=0;
m_Player = pl;
pl.Hidden = true;
pl.CantWalk = true;
pl.Squelched = true;
NewSleepBody(pl);
m_SleeperBedBody.Direction=BedDirection;
m_SleeperBedBody.MoveToWorld( BodyLocation, this.Map );
}
 
else 
{
if(m_Player==pl)
{
Wake(true);
}
else
{
switch (wtry)
{
case 0:
pl.LocalOverheadMessage( MessageType.Regular, 0x33, true, " Shhh, non svegliarlo. Ha davvero bisogno di riposare!!" );
wtry=wtry+1;
break;
case 1: 
pl.LocalOverheadMessage( MessageType.Regular, 0x33, true, " Non dovresti infastidire qualcuno che dorme. Potrebbero accadere brutte cose." );
wtry=wtry+1;
break;
 
default:
pl.LocalOverheadMessage( MessageType.Regular, 0x33, true, " Eri stato avvertito!! Adesso lascialo in pace." );
pl.FixedParticles( 0x3709, 10, 30, 5052, EffectLayer.Head );
pl.PlaySound( 0x208 );
pl.Hits-=40;
break;
}
}
}
}
}
 
 
public virtual bool BedAcces( PlayerMobile pl )
{
return true;
}
 
public virtual void NewSleepBody( PlayerMobile pl )
{
 
m_SleeperBedBody = new SleeperBedBody( pl, false, this );
 
}
 
public void ClearBad( )
{
 
m_SleeperBedBody = null;
if(m_Player==null) return;
m_Player = null;
}
 
public void Wake( bool plwake )
{
if( m_SleeperBedBody != null )
{
m_SleeperBedBody.Wake(true);
}
}
 
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
 
string tmp = String.Format( "{0}: {1}", this.Name, ( m_Player != null ? m_Player.Name : "unassigned" ) );
list.Add( tmp );
 
if ( m_Active )
list.Add( 1060742 ); 
else
list.Add( 1060743 ); 
}
 
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); 
 
writer.Write( (Item)m_SleeperBedBody );
writer.Write( (Mobile)m_Player );
writer.Write( m_Active );
 
writer.Write( (Mobile)m_Owner );
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
 
m_SleeperBedBody = (SleeperBedBody)reader.ReadItem();
m_Player = reader.ReadMobile();
m_Active = reader.ReadBool();
 
m_Owner = reader.ReadMobile();
 
}
}
 
public class SleepableBedsPiece : AddonComponent
{
 
private SleepableBedsAddon m_Bed;
[CommandProperty( AccessLevel.GameMaster )]
public SleepableBedsAddon Bed { get{ return m_Bed; } set { } }
 
public SleepableBedsPiece( SleepableBedsAddon bed, int itemid ) : base( itemid )
{
m_Bed = bed;
}
 
public override void OnDoubleClick( Mobile from ) 
{ 
if ( m_Bed != null)
m_Bed.DoubleClick(from);
else
base.OnDoubleClick(from);
}
 
public override void GetProperties( ObjectPropertyList list )
{
if ( m_Bed != null)
m_Bed.GetProperties(list);
else
base.GetProperties(list);
}
 
public SleepableBedsPiece( Serial serial ) : base( serial )
{
}
 
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); 
writer.Write( (Item)m_Bed );
 
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
m_Bed = (SleepableBedsAddon)reader.ReadItem();
 
}
 
}
 
public abstract class SleepableBedsDeed : BaseAddonDeed
{
private bool m_Used;
[CommandProperty( AccessLevel.GameMaster )]
public bool Used
{
get{ return m_Used; }
set{ m_Used = value; InvalidateProperties(); }
}
 
public SleepableBedsAddon GetBed( Mobile owner )
{
SleepableBedsAddon bed = Addon as SleepableBedsAddon;
if ( bed == null ) return null;
bed.Owner = owner;
return bed;
}
 
public SleepableBedsDeed()
{
}
 
public SleepableBedsDeed( Serial serial ) : base ( serial )
{
}
 
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042001 ); 
if ( m_Used )
from.SendMessage("E' già in uso!");
else
{
from.SendMessage("Dove vuoi piazzare il letto?");
m_Used = true;
from.Target = new BadPlacementTarget( this );
}
}
 
public class BadPlacementTarget : Target
{
private SleepableBedsDeed m_Deed;
 
public BadPlacementTarget( SleepableBedsDeed deed ) : base( -1, true, TargetFlags.None )
{
m_Deed = deed;
CheckLOS = false;
}
 
protected override void OnTarget( Mobile from, object o )
{
IPoint3D ip = o as IPoint3D;
m_Deed.Used =false;
 
if ( ip != null )
{
if ( ip is Item )
ip = ((Item)ip).GetWorldTop();
 
Point3D p = new Point3D( ip );
 
m_Deed.OnPlacement( from, p );
}
}
 
protected override void OnTargetFinish( Mobile from )
{
m_Deed.Used = false;
}
}
 
public void OnPlacement( Mobile from, Point3D p )
{
if ( Deleted )
return;
 
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it
}
else
{
//
SleepableBedsAddon bed = Addon as SleepableBedsAddon;
if ( bed == null )
from.SendMessage("Messaggio Prova 1");
else
{
bed.Owner = from;
bed.MoveToWorld( new Point3D( p ), from.Map );
Delete();
}
}
}
 
public override void Serialize ( GenericWriter writer )
{
base.Serialize ( writer );
writer.WriteEncodedInt( 0 ); 
}
 
public override void Deserialize ( GenericReader reader )
{
base.Deserialize ( reader );
int version = reader.ReadEncodedInt();
}
}
}

I Wanted that this "Futon" could be Chopped everywhere. Runuo still give me no Errors but on chop nothing happens. Any suggests? Thanks
 

Hammerhand

Knight
Your best bet would be to compare those with other addon scripts & check for differences. The Sleepable beds came out quite a while ago if I remember correctly. No addons in RunUO currently have the IChopable segment in the coding as it is handled by the BaseAddon.cs itself, nor are there any that I know of that have the IAddon segment.
 

pooka01

Sorceror
Did not find why it refuses, but hammerhand is right, there could be version problems, what runuo version do you use and which one must be the addon?
also why public void DoubleClick( Mobile from ), shouldn't it be public void OnDoubleClick( Mobile from )?
 

Lionar

Wanderer
The addon is for 2.0 , and my version of runuo is 2.0 . Also i tryied to add the sinlg OnChop method on the Futon but still nothing happens. The IAddon was a desperate try to solve this problem XD
 

Lionar

Wanderer
Code:
using System;
using System.Collections;
using Server;
using Server.Network;
using Server.Mobiles;
using Server.Gumps;
using Server.Multis;
using Server.Targeting;
 
namespace Server.Items
{
 
[PropertyObject]
public class SleepableBedsAddon: BaseAddon, IChopable
{
private bool m_Active = true;
private Mobile m_Player;
private SleeperBedBody m_SleeperBedBody;
private Mobile m_Owner;
 
private int wtry;
 
[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get{ return m_Active; }
set{ m_Active = value; InvalidateProperties(); }
}
 
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Mobile
{
get{ return m_Player; }
set
{
if( value != null )
m_Active = true;
 
m_Player = value; 
InvalidateProperties();
}
}
 
[CommandProperty( AccessLevel.GameMaster )]
public SleeperBedBody SleeperBody
{
get{ return m_SleeperBedBody; }
set{ m_SleeperBedBody = value; InvalidateProperties(); }
}
 
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; InvalidateProperties(); }
}
 
[CommandProperty( AccessLevel.GameMaster )]
public virtual Direction BedDirection { get { return Direction.East; } }
 
[CommandProperty( AccessLevel.GameMaster )]
public virtual Point3D BodyLocation{ get { return GetBodyLocationM(); }
set{
m_BodyLocation = value;
InvalidateProperties();
m_SleeperBedBody.Location = m_BodyLocation;
} }
 
private Point3D m_BodyLocation = Point3D.Zero;
 
public virtual Point3D GetBodyLocationM()
{
return ( m_BodyLocation != Point3D.Zero ? m_BodyLocation : GetBodyLocation());
}
 
public virtual Point3D GetBodyLocation()
{
return new Point3D(this.Location.X, this.Location.Y, this.Location.Z);
}
 
 
[CommandProperty( AccessLevel.GameMaster )]
public virtual Point3D BodyLocationMod{ get { return GetBodyLocationMod(); }
set{
m_BodyLocation = new Point3D( this.Location.X + value.X, this.Location.Y + value.Y, this.Location.Z + value.Z );
InvalidateProperties();
m_SleeperBedBody.Location = m_BodyLocation;
} }
 
public virtual Point3D GetBodyLocationMod()
{
if( m_BodyLocation == Point3D.Zero ) m_BodyLocation = GetBodyLocation();
return new Point3D(m_BodyLocation.X - this.Location.X, m_BodyLocation.Y - this.Location.Y, m_BodyLocation.Z - this.Location.Z);
}
 
 
public SleepableBedsAddon( Serial serial ) : base( serial )
{
}
 
 
public SleepableBedsAddon( )
{
Visible = true;
Name = "Sleepable Beds";
 
}
        public virtual void OnChop(Mobile from)
        {
           
 
            if (from.Hits >= 0 )
            {
                Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
                from.SendLocalizedMessage(500461); // You destroy the item.
 
                int hue = 0;
 
                
 
                Delete();
 
               
 
                BaseAddonDeed deed = Deed;
 
                if (deed != null)
                {
                    if (RetainDeedHue)
                        deed.Hue = hue;
 
                    from.AddToBackpack(deed);
                }
            }
        }
public void DoubleClick( Mobile from )
{ 
PlayerMobile pl = from as PlayerMobile;
if ( pl ==null)
return;
if ( !from.CanSee( this ) )
from.SendLocalizedMessage( 500237 ); 
 
if (!pl.InRange( GetWorldLocation(), 1 ))
{
 
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
else if (!m_Active)
{
                pl.SendMessage("Stai già dormendo da qualche parte.");
}
else if (pl.Mounted)
{
pl.SendMessage("Dovresti scendere dalla tua cavalcatura prima di dormire.");
}
 
else if (pl.Sleep >= 30 && pl.AccessLevel == AccessLevel.Player )
{
pl.SendMessage("Ti senti Riposato");
}
else if (pl.Combatant != null && pl.AccessLevel == AccessLevel.Player )
{
pl.SendMessage("Non puoi dormire se sei in combattimento!!");
}
 
else if ( !BedAcces( pl ) )
{
pl.SendMessage("Non è il tuo letto!!");
}
 
else
{
 
if( m_Player == null )
{
wtry=0;
m_Player = pl;
pl.Hidden = true;
pl.CantWalk = true;
pl.Squelched = true;
NewSleepBody(pl);
m_SleeperBedBody.Direction=BedDirection;
m_SleeperBedBody.MoveToWorld( BodyLocation, this.Map );
}
 
else 
{
if(m_Player==pl)
{
Wake(true);
}
else
{
switch (wtry)
{
case 0:
pl.LocalOverheadMessage( MessageType.Regular, 0x33, true, " Shhh, non svegliarlo. Ha davvero bisogno di riposare!!" );
wtry=wtry+1;
break;
case 1: 
pl.LocalOverheadMessage( MessageType.Regular, 0x33, true, " Non dovresti infastidire qualcuno che dorme. Potrebbero accadere brutte cose." );
wtry=wtry+1;
break;
case 2:
default:
pl.LocalOverheadMessage( MessageType.Regular, 0x33, true, " Eri stato avvertito!! Adesso lascialo in pace." );
pl.FixedParticles( 0x3709, 10, 30, 5052, EffectLayer.Head );
pl.PlaySound( 0x208 );
pl.Hits-=40;
break;
}
}
}
}
}
 
 
public virtual bool BedAcces( PlayerMobile pl )
{
return true;
}
 
public virtual void NewSleepBody( PlayerMobile pl )
{
 
m_SleeperBedBody = new SleeperBedBody( pl, false, this );
 
}
 
public void ClearBad( )
{
 
m_SleeperBedBody = null;
if(m_Player==null) return;
m_Player = null;
}
 
public void Wake( bool plwake )
{
if( m_SleeperBedBody != null )
{
m_SleeperBedBody.Wake(true);
}
}
 
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
 
string tmp = String.Format( "{0}: {1}", this.Name, ( m_Player != null ? m_Player.Name : "unassigned" ) );
list.Add( tmp );
 
if ( m_Active )
list.Add( 1060742 ); // active
else
list.Add( 1060743 ); // inactive
}
 
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); 
 
writer.Write( (Item)m_SleeperBedBody );
writer.Write( (Mobile)m_Player );
writer.Write( m_Active );
 
writer.Write( (Mobile)m_Owner );
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
 
m_SleeperBedBody = (SleeperBedBody)reader.ReadItem();
m_Player = reader.ReadMobile();
m_Active = reader.ReadBool();
 
m_Owner = reader.ReadMobile();
 
}
}
 
public class SleepableBedsPiece : AddonComponent
{
 
private SleepableBedsAddon m_Bed;
[CommandProperty( AccessLevel.GameMaster )]
public SleepableBedsAddon Bed { get{ return m_Bed; } set { } }
 
public SleepableBedsPiece( SleepableBedsAddon bed, int itemid ) : base( itemid )
{
m_Bed = bed;
}
 
public override void OnDoubleClick( Mobile from ) 
{ 
if ( m_Bed != null)
m_Bed.DoubleClick(from);
else
base.OnDoubleClick(from);
}
 
public override void GetProperties( ObjectPropertyList list )
{
if ( m_Bed != null)
m_Bed.GetProperties(list);
else
base.GetProperties(list);
}
 
public SleepableBedsPiece( Serial serial ) : base( serial )
{
}
 
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
writer.Write( (Item)m_Bed );
 
}
 
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
m_Bed = (SleepableBedsAddon)reader.ReadItem();
 
}
 
}
 
public abstract class SleepableBedsDeed : BaseAddonDeed
{
private bool m_Used;
[CommandProperty( AccessLevel.GameMaster )]
public bool Used
{
get{ return m_Used; }
set{ m_Used = value; InvalidateProperties(); }
}
 
public SleepableBedsAddon GetBed( Mobile owner )
{
SleepableBedsAddon bed = Addon as SleepableBedsAddon;
if ( bed == null ) return null;
bed.Owner = owner;
return bed;
}
 
public SleepableBedsDeed()
{
}
 
public SleepableBedsDeed( Serial serial ) : base ( serial )
{
}
 
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
if ( m_Used )
from.SendMessage("E' già in uso!");
else
{
from.SendMessage("Dove vuoi piazzare il letto?");
m_Used = true;
from.Target = new BadPlacementTarget( this );
}
}
 
public class BadPlacementTarget : Target
{
private SleepableBedsDeed m_Deed;
 
public BadPlacementTarget( SleepableBedsDeed deed ) : base( -1, true, TargetFlags.None )
{
m_Deed = deed;
CheckLOS = false;
}
 
protected override void OnTarget( Mobile from, object o )
{
IPoint3D ip = o as IPoint3D;
m_Deed.Used =false;
 
if ( ip != null )
{
if ( ip is Item )
ip = ((Item)ip).GetWorldTop();
 
Point3D p = new Point3D( ip );
 
m_Deed.OnPlacement( from, p );
}
}
 
protected override void OnTargetFinish( Mobile from )
{
m_Deed.Used = false;
}
}
 
public void OnPlacement( Mobile from, Point3D p )
{
if ( Deleted )
return;
 
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it
}
else
{
 
SleepableBedsAddon bed = Addon as SleepableBedsAddon;
if ( bed == null )
from.SendMessage("Messaggio Prova 1");
else
{
bed.Owner = from;
bed.MoveToWorld( new Point3D( p ), from.Map );
Delete();
}
}
}
 
public override void Serialize ( GenericWriter writer )
{
base.Serialize ( writer );
writer.WriteEncodedInt( 0 ); // Version
}
 
public override void Deserialize ( GenericReader reader )
{
base.Deserialize ( reader );
int version = reader.ReadEncodedInt();
}
}
}



This is what i did, i added the chop method, no errors but still nothing happens while chopping. Damn :/
 

pooka01

Sorceror
don't seem needed to add the ichopable...
Code:
using System;
using Server;
using Server.Network;
namespace Server.Items
{
 public class DartBoard : AddonComponent
 {
  public override bool NeedsWall{ get{ return true; } }
  public override Point3D WallPosition{ get{ return this.East ? new Point3D( -1, 0, 0 ) : new Point3D( 0, -1, 0 ); } }
  public bool East{ get{ return this.ItemID == 0x1E2F; } }
  [Constructable]
  public DartBoard() : this( true )
  {
  }
  [Constructable]
  public DartBoard( bool east ) : base( east ? 0x1E2F : 0x1E2E )
  {
  }
  public DartBoard( Serial serial ) : base( serial )
  {
  }
  public override void OnDoubleClick( Mobile from )
  {
   Direction dir;
   if ( from.Location != this.Location )
    dir = from.GetDirectionTo( this );
   else if ( this.East )
    dir = Direction.West;
   else
    dir = Direction.North;
   from.Direction = dir;
   bool canThrow = true;
   if ( !from.InRange( this, 4 ) || !from.InLOS( this ) )
    canThrow = false;
   else if ( this.East )
    canThrow = ( dir == Direction.Left || dir == Direction.West || dir == Direction.Up );
   else
    canThrow = ( dir == Direction.Up || dir == Direction.North || dir == Direction.Right );
   if ( canThrow )
    Throw( from );
   else
    from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
  }
  public void Throw( Mobile from )
  {
   BaseKnife knife = from.Weapon as BaseKnife;
   if ( knife == null )
   {
    from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500751 ); // Try holding a knife...
    return;
   }
   from.Animate( from.Mounted ? 26 : 9, 7, 1, true, false, 0 );
   from.MovingEffect( this, knife.ItemID, 7, 1, false, false );
   from.PlaySound( 0x238 );
   double rand = Utility.RandomDouble();
   int message;
   if ( rand < 0.05 )
    message = 500752; // BULLSEYE! 50 Points!
   else if ( rand < 0.20 )
    message = 500753; // Just missed the center! 20 points.
   else if ( rand < 0.45 )
    message = 500754; // 10 point shot.
   else if ( rand < 0.70 )
    message = 500755; // 5 pointer.
   else if ( rand < 0.85 )
    message = 500756; // 1 point.  Bad throw.
   else
    message = 500757; // Missed.
   PublicOverheadMessage( MessageType.Regular, 0x3B2, message );
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.WriteEncodedInt( 0 ); // version
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadEncodedInt();
  }
 }
 public class DartBoardEastAddon : BaseAddon
 {
  public override BaseAddonDeed Deed{ get{ return new DartBoardEastDeed(); } }
  public DartBoardEastAddon()
  {
   AddComponent( new DartBoard( true ), 0, 0, 0 );
  }
  public DartBoardEastAddon( Serial serial ) : base( serial )
  {
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.WriteEncodedInt( 0 ); // version
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadEncodedInt();
  }
 }
 public class DartBoardEastDeed : BaseAddonDeed
 {
  public override BaseAddon Addon{ get{ return new DartBoardEastAddon(); } }
  public override int LabelNumber{ get{ return 1044326; } } // dartboard (east)
  [Constructable]
  public DartBoardEastDeed()
  {
  }
  public DartBoardEastDeed( Serial serial ) : base( serial )
  {
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.WriteEncodedInt( 0 ); // version
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadEncodedInt();
  }
 }
 public class DartBoardSouthAddon : BaseAddon
 {
  public override BaseAddonDeed Deed{ get{ return new DartBoardSouthDeed(); } }
  public DartBoardSouthAddon()
  {
   AddComponent( new DartBoard( false ), 0, 0, 0 );
  }
  public DartBoardSouthAddon( Serial serial ) : base( serial )
  {
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.WriteEncodedInt( 0 ); // version
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadEncodedInt();
  }
 }
 public class DartBoardSouthDeed : BaseAddonDeed
 {
  public override BaseAddon Addon{ get{ return new DartBoardSouthAddon(); } }
  public override int LabelNumber{ get{ return 1044325; } } // dartboard (south)
  [Constructable]
  public DartBoardSouthDeed()
  {
  }
  public DartBoardSouthDeed( Serial serial ) : base( serial )
  {
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.WriteEncodedInt( 0 ); // version
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadEncodedInt();
  }
 }
}
 
Top