RedBeard
Member
Everything seems to work except for the use delay.
Code:
using System;
using Server;
using Server.Mobiles;
using Server.Misc;
using Server.Network;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
namespace Server.Items
{
public class WrongBedrollW1 : Item
{
public override int LabelNumber { get { return 1022645; } }// bedroll
private static readonly TimeSpan UseDelay = TimeSpan.FromSeconds(30.0);
private DateTime m_LastClicked;
public DateTime LastClicked { get { return m_LastClicked; } set { m_LastClicked = value; } }
[Constructable]
public WrongBedrollW1()
: base(0xA56)
{
this.Movable = false;
}
public WrongBedrollW1(Serial serial)
: base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 1))
{
from.SendLocalizedMessage(500446); // That is too far away.
return;
}
if (DateTime.Now < m_LastClicked + TimeSpan.FromSeconds(30.0))
{
from.SendLocalizedMessage(500119); // You must wait to perform another action.
return;
}
else if (from is PlayerMobile)
{
PlayerMobile player = (PlayerMobile)from;
MysteriousTunnelWest mtw = new MysteriousTunnelWest();
if (Utility.RandomDouble() < 0.2)
{
mtw.MoveToWorld(Location, Map);
from.SendMessage(89, "As you move the bedroll it crumbles into pieces and reveals a mysterious tunnel.");
LastClicked = DateTime.Now;
Delete();
return;
}
else
from.SendMessage(89, "As you move the bedroll it crumbles into pieces but you find nothing.");
LastClicked = DateTime.Now;
Delete();
return;
}
}
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();
}
}