public class MobileDeleteTime : Timer
{
private Item mob;
public MobileDeleteTime(Item m)
: base(TimeSpan.FromSeconds(300))//////aqui el numero de segundos
{
mob = m;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
if (mob == null || mob.Deleted)
{
Stop();
return;
}
mob.Delete();
}
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
public override bool OnBeforeDeath()
{
// spawn the item
World.Broadcast( 2512, true, "Nexgar has been defeated ! ! ! ..." );
Item item = (Item)Activator.CreateInstance(typeof(Moongate));
Moongate moon = (Moongate)item;
moon.TargetMap = Map.Felucca; //or map
moon.Target = new Point3D(5947, 1459, 10); // Set map X,Y,Z location here
moon.Hue = 1691;
//moon.name = "Entrance";
// Map map = Map.Trammel;
Point3D pnt = GetSpawnLocation();
moon.MoveToWorld(pnt, this.Map);
Timer m_timer = new MobileDeleteTime(item);
m_timer.Start();
return base.OnBeforeDeath();
}
//from champspawn.cs
public Point3D GetSpawnLocation()
{
int m_SpawnRange = 2;
Map map = Map;
if (map == null)
return Location;
// Try 20 times to find a spawnable location.
for (int i = 0; i < 20; i++)
{
int x = Location.X + (Utility.Random((m_SpawnRange * 2) + 1) - m_SpawnRange);
int y = Location.Y + (Utility.Random((m_SpawnRange * 2) + 1) - m_SpawnRange);
int z = Map.GetAverageZ(x, y);
if (Map.CanSpawnMobile(new Point2D(x, y), z))
return new Point3D(x, y, z);
}
return Location;
}