[Issues] Server Crash
My issues are when outside the region (Cemetary Region)
when player dies or if player suddenly changes to owner using the access level stone
I would also prefer //==Haunt current Target==// section not be subject to the return;
ie: he will still haunt you in the region as well

[Goal]
if pm dies, can't be found, or when mobs hitpoints drop to certain level it should teleport back to within
the region.

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Mobiles.GrimReaper.OnThink()
at Server.Mobiles.BaseAI.AITimer.OnTick()
at Server.Timer.Slice() in j:\Virtus Imperium v1.3.5\Server\Timer.cs:line 386
at Server.Core.Main(String[] args) in j:\Virtus Imperium v1.3.5\Server\Main.cs:line 621

Code:
#region OnThink
public override void OnThink()
{
if (init == false)
Start();
base.OnThink();
Mobile m = Combatant;
if (this.Region.IsPartOf(typeof(Regions.CemetaryRegion)) || (m.AccessLevel >= AccessLevel.Counselor))
{
return;
}
//==At approx. 33% Health or no combatant return home==//
if (this.Hits <= (this.HitsMax / 3) || (m == null) || m.Deleted || !m.Alive || !Alive || m.IsDeadBondedPet || !this.CanSee(m) || !this.InLOS(m) || (m.AccessLevel >= AccessLevel.Counselor))
{
Map = m.Map;
Location = this.InitialPos;
Effects.PlaySound(this.Location, this.Map, 0x1FE);
//this.Hits += 1000; //gets instant 1000 health replenished
}
//==Haunt current Target==//
if (m.AccessLevel == AccessLevel.Player && !this.InRange(m, 8) || !m.Deleted || m.Alive || this.InLOS(m) || this.CanSee(m))//|| !this.Region.IsPartOf(typeof(Regions.TownRegion)))
{
Map = m.Map;
Location = m.Location;
Combatant = m;
//Effects.PlaySound(this.Location, this.Map, 0x1FE);
}
}
#endregion
 
Well my guess is that m.AccessLevel is crashing since you do not have a null check for m befor you try to access it.
 
ok here is what I have now. It wont crash if player dies out of the region but it crashes if the mob wonders out of the region and doesnt find a combatant

Code:
#region OnThink

public override void OnThink()

{

if (init == false)

Start();

base.OnThink();

Mobile m = Combatant;

if (this.Region.IsPartOf(typeof(Regions.CemetaryRegion)))

{

return;

}

if (this.Hits <= (this.HitsMax / 3) || (m == null) || m.Deleted || !m.Alive || !Alive || m.IsDeadBondedPet) //@ approx. 33% health or no combatant return home

{

Map = m.Map;

Location = this.InitialPos;

Combatant = m;

Effects.PlaySound(this.Location, this.Map, 0x1FE);

// this.Hits += 1000; //gets instant 1000 health replenished

}

else if (!this.InRange(m, 8) || !this.InLOS(m) || !this.CanSee(m)) //Teleport to Combatant if range exceeds 8 tiles or Out of Sight

{

Map = m.Map;

Location = m.Location;

Combatant = m;

Effects.PlaySound(this.Location, this.Map, 0x1FE);

}

}

#endregion
 
I can just assume but the issue could potentially be this
Code:
if (... (m == null) ...) 
{
	Map = m.Map;
	...
 
Back