This is a bulletin board that finds escorts by proximity from the board, my problem is it doesn't determine which map the mobile is on. It will show trammel escorts on felucca boards but not show any on trammel boards. What can I change to have escort.trammel appear on board.trammel and escort.felucca appear on board.felucca?

Code:
 #region BBS Quests
        public static BulletinBoard FindClosestBB(Mobile m, out double distance)
        {
            BulletinBoard closest = null;
            distance = double.MaxValue;
            double tempdist = 0;
 
            foreach (Item item in World.Items.Values)
            {
                if (item is BulletinBoard)
                {
                    tempdist = m.GetDistanceToSqrt(item.Location);
                    if (tempdist < distance)
                    {
                        closest = item as BulletinBoard;
                        distance = tempdist;
                    }
                }
            }
 
            return closest;
 
Last edited:
foreach (Item item in World.Items.Values)
{
if (item is BulletinBoard)

i think this could be where you need this:

foreach (Item item in World.Items.Values)
{
if (item is BulletinBoard && item.Map == m.Map)
 
foreach (Item item in World.Items.Values)
{
if (item is BulletinBoard)

i think this could be where you need this:

foreach (Item item in World.Items.Values)
{
if (item is BulletinBoard && item.Map == m.Map)


Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Items.EscortMessage..ctor(Mobile m)
at Server.Mobiles.BaseEscortable.OnLocationChange(Point3D oldLocation)
at Server.Mobile.MoveToWorld(Point3D newLocation, Map map) in j:\Virtus Imperium v1.3.5\Server\Mobile.cs:line 9760
at Server.Multis.BaseCamp.AddMobile(Mobile m, Int32 wanderRange, Int32 xOffset, Int32 yOffset, Int32 zOffset)
at Server.Multis.HumanBrigandCamp.AddComponents()
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 BBS Quests
public class PrisonerMessage : BulletinMessage
{
private BaseCamp m_Camp;
public BaseCamp Camp { get { return m_Camp; } }
public PrisonerMessage(BaseCamp c, BaseEscortable escort)
: base(c.Prisoner, null, "", null)
{
m_Camp = c;
switch (Utility.Random(13))
{
case 0: Subject = "A kidnapping!"; break;
case 1: Subject = "Help!"; break;
case 2: Subject = "Help us, please!"; break;
case 3: Subject = "Adventurers needed!"; break;
case 4: Subject = "Seeking assistance"; break;
case 5: Subject = "In need of aid"; break;
case 6: Subject = "Canst thou help us?"; break;
case 7: Subject = "Shall any save our friend?"; break;
case 8: Subject = "A friend was kidnapped!"; break;
case 9: Subject = "Heroes wanted!"; break;
case 10: Subject = "Can any assist us?"; break;
case 11: Subject = "Kidnapped!"; break;
case 12: Subject = "Taken prisoner"; break;
}
double distance;
BulletinBoard board = FindClosestBB(c.Prisoner, out distance);
List<String> myLines = new List<String>();
string[] subtext1 = { "foul", "vile", "evil", "dark", "cruel", "vicious", "scoundrelly", "dastardly", "cowardly", "craven", "foul and monstrous", "monstrous", "hideous", "terrible", "cruel, evil", "truly vile", "vicious and cunning", "" };
string camp;
switch (c.Camp)
{
default:
case CampType.Default: camp = ""; break;
//case CampType.EvilMage: camp = "evil mages"; break;
//case CampType.GoodMage: camp = "mages"; break;
case CampType.Lizardman: camp = "lizardmen"; break;
case CampType.Orc: camp = "orcs"; break;
case CampType.Ratman: camp = "ratmen"; break;
case CampType.Brigand: camp = "brigands"; break;
//case CampType.Gypsy: camp = "gypsys"; break;
//case CampType.Warlord: camp = "a warlord"; break;
}
myLines.Add(String.Format("Help us please! {0} hath", escort.Name));
myLines.Add(String.Format("been kidnapped by "));
myLines.Add(String.Format("{0} {1}!", subtext1[Utility.Random(subtext1.Length)], camp));
myLines.Add(String.Format("We believe that {0} is held at", escort.Female ? "she" : "he"));
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if (Sextant.Format(c.Location, c.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
{
myLines.Add(String.Format("{0}o {1}'{2}, {3}o {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W"));
}
/*myLines.Add(String.Format("{0}"));
myLines.Add(String.Format("{0}."));
myLines.Add(String.Format("{0}"));*/
Lines = myLines.ToArray();
if (board != null)
board.AddItem(this);
else
Delete();
}
public PrisonerMessage(Serial serial)
: base(serial)
{
}
 
oops.
Code:
public class EscortMessage : BulletinMessage
{
private Mobile m_Mobile;
public Mobile Escort { get { return m_Mobile; } }
public EscortMessage(Mobile m)
: base(m, null, "", null)
{
m_Mobile = m;
BaseEscortable escort = m as BaseEscortable;
String subtext = "";
switch (m.GetType().Name)
{
case "EscortableHealer1": subtext = "Greetings! I am a poor healer who seeks a worthy escort. I can offer some small pay to any doughty warrior able to assist me. It is imperative that I reach my destination, or innocents may perish!"; break;
case "Peasant": subtext = "'Tis a terrible thing to be a parent with an ungrateful child! Yet such is my situation. Because of the poor behavior and lack of character of this offspring of mine, I am obliged to foster them away from home. So now I am in need of an able escort of good character who might serve as role model, and who can ensure that my child reaches their destination safely. I shall let my child post their whereabouts so that thou mayst meet with them and arrange terms." + "---"; break;
case "BrideGroom": subtext = "I am so happy! I am to be married, and my life will finally be complete! Alas, I am no warrior, and the wedding is not to take place here. I am in need of an escort, for the roads are treacherous and my future spouse would be sad indeed to hear that an ettin ate me before the wedding."; break;
case "EscortableMage": subtext = "Wizard seeks escort to a conference."; break;
case "Merchant": subtext = "Reputable merchant seeks able warriors to serve as mercantile escort. Pay is scale; we prefer to hire experienced mercenaries."; break;
case "Messenger": subtext = "I am one of Lord British's couriers, and I seek an able warrior to escort me safely, as the message I carry is of utmost importance to the realm!"; break;
case "Noble": subtext = "'Tis a bit of a problem to admit it, but our normally trustworthy household guard seem to have broken his leg! If thou art able with a weapon, we are pleased to take applications for his replacement, to serve as guard and escort on our forthcoming journey."; break;
default:
case "SeekerOfAdventure": subtext = "I've always wished for adventure! Now I can have it at last! My weaponsmaster in school always said I was a dab hand with a blade, and I am afire with the love of adventure! Plus I have money. So if you are willing to hire on as my bodyguard and join me as we seek the deepest depths of the Abyss, and as we conquer dragons with the rapid flick of our sharp swords, disregarding all danger and ignorant of fear, seek me out! Cowards need not apply!"; break;
}
switch (Utility.Random(9))
{
case 0: Subject = "Escort needed"; break;
case 1: Subject = "Guard needed"; break;
case 2: Subject = "I need an escort!"; break;
case 3: Subject = "Traveling companion?"; break;
case 4: Subject = "Seeking companion"; break;
case 5: Subject = "Now hiring"; break;
case 6: Subject = "Hiring a guard"; break;
case 7: Subject = "Hiring an escort"; break;
case 8: Subject = "Seeking escort"; break;
}
double distance;
BulletinBoard board = FindClosestBB(m, out distance);
String direction;
if (m.GetDirectionTo(board) == Direction.North)
direction = "South";//North
else if (m.GetDirectionTo(board) == Direction.South)
direction = "North";//South
else if (m.GetDirectionTo(board) == Direction.East)
direction = "West";//East
else if (m.GetDirectionTo(board) == Direction.West)
direction = "East";//West
else if (m.GetDirectionTo(board) == Direction.Up)
direction = "Southeast";//Northwest
else if (m.GetDirectionTo(board) == Direction.Left)
direction = "Northeast";//Southwest
else if (m.GetDirectionTo(board) == Direction.Right)
direction = "Southwest";//Northeast
else if (m.GetDirectionTo(board) == Direction.Down)
direction = "Northwest";//Southeast
else
direction = "in some direction.";
String line = String.Format("{0} I can be found {1} {2} of here. When thou dost find me, look at me close to accept the task of taking me to {3}. {4}", subtext, (distance < 50 ? "a fair distance" : "a long way"), direction, escort.Destination, escort.Name);
Lines = MakeLines(line);
board.AddItem(this);
}
public EscortMessage(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
writer.Write(m_Mobile);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 0:
m_Mobile = reader.ReadMobile();
break;
}
}
}
#endregion
 
Back