
I hope Coli puts it in, I could really use it on this server.

Code: Select all
using System;
using Server;
using Server.Targeting;
namespace Server.Items //Namespace
{
public class HueWand : Item //Class name and parent class
{
[Constructable] //Constructor tag
public HueWand()
: base(0x14F6) // naming the constructor and defining the graphic base
{
Weight = 1.0;
Hue = 1480;
Name = "a hue detector";
}
public HueWand(Serial serial)
: base(serial) //constructor for serializing
{
}
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 void OnDoubleClick(Mobile from) //handles double click events and brings character with it
{
if (IsChildOf(from.Backpack) || from.InRange(this, 2) && from.CanSee(this)) //if in backpack or within range and can see
{
from.Target = new HueWandTarget(this);
from.SendMessage("What item would you like to get the hue of?");
}
else
{
from.SendLocalizedMessage(500446); // That is too far away.
}
}
}
public class HueWandTarget : Target
{
private HueWand m_Wand; //creating the modular variable for the Wand being used
public HueWandTarget(HueWand wand) //sets wand to the wand being used (set when it is called)
: base(15, false, TargetFlags.None) //no idea on this yet
{
m_Wand = wand;
}
protected override void OnTarget(Mobile from, object target)
{
if (target is Item) //remember conditions are always in parens
{
Item item = (Item)target;
string hue = System.String.Concat("The item's hue is ",item.Hue.ToString(),".");
from.SendMessage(hue);
return;
}
else if (target is Mobile)
{
Mobile mobile = (Mobile)target;
string hue = System.String.Concat("The item's hue is ", mobile.Hue.ToString(), ".");
from.SendMessage(hue);
return;
}
else
{
from.SendMessage("You cannot get the hue of that.");
return;
}
}
}
}