ModernUO/Scripts/Engines/Plants/Seed.cs
daedalus c98aa748b6 - Kasa of the Raj-in is now blessable with a Clothing Bless Deed
(http://www.uodemise.com/discussion/showthread.php?t=134491)

- People who use Hiding skill will be put in peace mode
(http://www.uodemise.com/discussion/showthread.php?t=133532)

- Various fixes about plantgrowing:
--> Seeds no longer have range or LOS checks.
--> When clicking on the water button on the plant gump it attempts to find water in your backpack first and if it doesn't it will give you a target instead.
--> Changed some old SVN messages that were using strings to use cliloc data instead.
(http://www.uodemise.com/discussion/showthread.php?t=119004)

- Player vendors will say the name of the buyer
(http://www.uodemise.com/discussion/showthread.php?t=118363)

- Books in bookshelves are now accessible to be read. They can't be taken away unless by using Stealing Skill
(http://www.uodemise.com/discussion/showthread.php?t=120213)

- Paragon metal chests now are turnable by using the Interior Decorator
(http://www.uodemise.com/discussion/showthread.php?t=133863)

- Runebooks can't be picked up if opened
(http://www.uodemise.com/discussion/showthread.php?t=133723)

- Runebook default location now is displayed as a red dot
(http://www.uodemise.com/discussion/showthread.php?t=133914)
2009-12-24 12:10:50 +00:00

202 lines
No EOL
5.2 KiB
C#

using System;
using Server;
using Server.Targeting;
namespace Server.Engines.Plants
{
public class Seed : Item
{
private PlantType m_PlantType;
private PlantHue m_PlantHue;
private bool m_ShowType;
[CommandProperty( AccessLevel.GameMaster )]
public PlantType PlantType
{
get { return m_PlantType; }
set
{
m_PlantType = value;
InvalidateProperties();
}
}
[CommandProperty( AccessLevel.GameMaster )]
public PlantHue PlantHue
{
get { return m_PlantHue; }
set
{
m_PlantHue = value;
Hue = PlantHueInfo.GetInfo( value ).Hue;
InvalidateProperties();
}
}
[CommandProperty( AccessLevel.GameMaster )]
public bool ShowType
{
get { return m_ShowType; }
set
{
m_ShowType = value;
InvalidateProperties();
}
}
public override int LabelNumber{ get { return 1060810; } } // seed
public static Seed RandomBonsaiSeed()
{
return RandomBonsaiSeed( 0.5 );
}
public static Seed RandomBonsaiSeed( double increaseRatio )
{
return new Seed( PlantTypeInfo.RandomBonsai( increaseRatio ), PlantHue.Plain, false );
}
public static Seed RandomPeculiarSeed( int group )
{
switch ( group )
{
case 1: return new Seed ( PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain, false );
case 2: return new Seed ( PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain, false );
case 3: return new Seed ( PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain, false );
default: return new Seed ( PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain, false );
}
}
[Constructable]
public Seed() : this( PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration(), false )
{
}
[Constructable]
public Seed( PlantType plantType, PlantHue plantHue, bool showType ) : base( 0xDCF )
{
Weight = 1.0;
m_PlantType = plantType;
m_PlantHue = plantHue;
m_ShowType = showType;
Hue = PlantHueInfo.GetInfo( plantHue ).Hue;
}
public Seed( Serial serial ) : base( serial )
{
}
public override bool ForceShowProperties{ get{ return ObjectPropertyList.Enabled; } }
public override void AddNameProperty( ObjectPropertyList list )
{
PlantHueInfo hueInfo = PlantHueInfo.GetInfo( m_PlantHue );
int title = PlantTypeInfo.GetBonsaiTitle( m_PlantType );
if ( title == 0 ) // Not a bonsai
title = hueInfo.Name;
if ( m_ShowType )
{
PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo( m_PlantType );
list.Add( hueInfo.IsBright() ? 1061918 : 1061917, String.Concat( "#", title.ToString(), "\t#", typeInfo.Name.ToString() ) ); // [bright] ~1_COLOR~ ~2_TYPE~ seed
}
else
{
list.Add( hueInfo.IsBright() ? 1060839 : 1060838, String.Concat( "#", title.ToString() ) ); // [bright] ~1_val~ seed
}
}
public override void OnSingleClick ( Mobile from )
{
PlantHueInfo hueInfo = PlantHueInfo.GetInfo( m_PlantHue );
if ( m_ShowType )
{
PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo( m_PlantType );
LabelTo( from, hueInfo.IsBright() ? 1061918 : 1061917, String.Concat( "#", hueInfo.Name.ToString(), "\t#", typeInfo.Name.ToString() ) ); // [bright] ~1_COLOR~ ~2_TYPE~ seed
}
else
{
LabelTo( from, hueInfo.IsBright() ? 1060839 : 1060838, String.Concat( "#", hueInfo.Name.ToString() ) ); // [bright] ~1_val~ seed
}
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
from.Target = new InternalTarget( this );
LabelTo( from, 1061916 ); // Choose a bowl of dirt to plant this seed in.
}
private class InternalTarget : Target
{
private Seed m_Seed;
public InternalTarget( Seed seed ) : base( -1, false, TargetFlags.None )
{
m_Seed = seed;
CheckLOS = false;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Seed.Deleted )
return;
if ( !m_Seed.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
if ( targeted is PlantItem )
{
PlantItem plant = (PlantItem)targeted;
plant.PlantSeed( from, m_Seed );
}
else if ( targeted is Item )
{
((Item)targeted).LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
}
else
{
from.SendLocalizedMessage( 1061919 ); // You must use a seed on a bowl of dirt!
}
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (int) m_PlantType );
writer.Write( (int) m_PlantHue );
writer.Write( (bool) m_ShowType );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_PlantType = (PlantType)reader.ReadInt();
m_PlantHue = (PlantHue)reader.ReadInt();
m_ShowType = reader.ReadBool();
if ( Weight != 1.0 )
Weight = 1.0;
}
}
}