ExX
Member
I have this custom region I am implementing as part of a quest. However whenever I enter the region the server crashes. This is the region code. It's pretty straight forward. It checks to see if they are a playermobile and if they do not have a custom account tag. (later that account tag makes the region uncursed). What's even more stumping is this same code snippet I have working perfectly on another quest for a teleporter. So I am a tad confused why it crashes when I enter. It also freaked out on compile about a custom npc I had spawned in that area.
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server;
using Server.Mobiles;
using Server.Spells;
using Server.Items;
using Server.Network;
using System.Xml;
using Server.Accounting;
namespace Server.Regions
{
public class CursedGraveyard : BaseRegion
{
public CursedGraveyard( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public void CreateRemains(Mobile m)
{
Ztimer tm = new Ztimer(this, m);
tm.Start();
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override void OnDeath( Mobile m )
{
Account acct = (Account)m.Account;
bool BGYQuestStarter = Convert.ToBoolean(acct.GetTag("BGYQuestComplete"));
if (m is PlayerMobile && (!BGYQuestStarter) )
CreateRemains(m);
}
public override void OnEnter( Mobile m )
{
Account acct = (Account)m.Account;
bool BGYQuestStarter = Convert.ToBoolean(acct.GetTag("BGYQuestComplete"));
if (m is PlayerMobile && (!BGYQuestStarter) )
m.SendMessage("You feel as though you are being watched.");
}
public override void OnExit( Mobile m )
{
}
public override bool OnDecay( Item item )
{
return base.OnDecay( item);
}
private class Ztimer : Timer
{
Mobile plr;
CursedGraveyard m_Region;
private static TimeSpan m_Delay = TimeSpan.FromMinutes( 1 );
public void Initialize()
{
}
public Ztimer(CursedGraveyard rgn, Mobile m) : base(m_Delay )
{
Priority = TimerPriority.OneMinute;
plr= m;
m_Region = rgn;
}
protected override void OnTick()
{
if ((m_Region!=null) && (plr !=null) && !plr.Deleted && (plr.Corpse!=null) && !plr.Corpse.Deleted)
{
Corpse crp = (Corpse) plr.Corpse;
if ((crp.Owner==plr) && m_Region.Contains(crp.Location) && (m_Region.Map==crp.Map))
{
WalkingRemains zomb = new WalkingRemains(crp);
}
}
}
}
}
}
[code]