if (m_Quester is BaseEscort)
{
BaseEscort escort = (BaseEscort)m_Quester;
if (escort.SetControlMaster(m_Owner))
{
escort.Quest = this;
escort.LastSeenEscorter = DateTime.UtcNow;
escort.StartFollow();
escort.AddHash(Owner);
string region = escort.GetDestination();
if (!string.IsNullOrEmpty(region))
escort.Say(1042806, region); // Lead on! Payment will be made when we arrive at ~1_DESTINATION~!
else
escort.Say(1042806, "destination"); // Lead on! Payment will be made when we arrive at ~1_DESTINATION~!
m_Owner.LastEscortTime = DateTime.UtcNow;
}
}
// tick tack
StartTimer();
}
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
{
base.AddCustomContextEntries(from, list);
if (from.Alive && from is PlayerMobile && TalkNumber > 0 && CanTalkTo((PlayerMobile)from))
list.Add(new TalkEntry(this));
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m.Alive && m is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)m;
int range = GetAutoTalkRange(pm);
if (m.Alive && range >= 0 && InRange(m, range) && !InRange(oldLocation, range) && CanTalkTo(pm))
OnTalk(pm, false);
}
}
around line 54, after the above snippetpublic override void OnTalk(PlayerMobile player)
{
if (AcceptEscorter(player))
base.OnTalk(player);
}
public override void Advertise()
{
Say("Pardon me citizen, but I am looking for a companion to assist thee.");
}
public override void Advertise()
{
switch (Utility.Random(5))
{
case 0: Say("Pardon me citizen, but I am looking for a companion to assist thee."); break;
case 1: Say("I'm lost can you help me?"); break;
case 2: Say("Might thou be willing to accompany me on a journey?"); break;
case 3: Say("Hello adventurer I'm hiring an escort, would thou be interested.)"; break;
case 4: Say("Hail friend, I am seeking fellowship for a small expedition, would'st though care to join me?"; break;
}
}
Thanks for your reply, I've referred to your suggestions and received only one error. Could it be something I'm leaving out? Or something that is missing in BaseEscortable.cs? I probably should've mentioned in the original post; I'm using Pub 57.3 with UOR expansion. BaseEscort.cs is not being used but BaseEscortable.cs is.Try something like this, which will be triggered when player is in range.
BaseEscort.cs
around line 54, after the above snippet
add something like this:
or randomize what they say:
I removed the changes, for now, to keep the server running.post your baseescortable file
[CorpseName("a human's corpse")]
public class XYZ : BaseCreature
{
private DateTime recoverDelay;
private static bool m_Talked;
string[] Escortsay = new string[] // things to say while greeting
{
"Pardon me citizen, but I am looking for a companion to assist thee.",
"I'm lost can you help me?",
"Might thou be willing to accompany me on a journey?",
"Hello adventurer I'm hiring an escort, would thou be interested.",
"Hail friend, I am seeking fellowship for a small expedition, would'st though care to join me?"
};
[Constructable]
{
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m_Talked == false)
{
if (m.InRange(this, 4))
{
m_Talked = true;
SayRandom(Escortsay, this);
this.Move(GetDirectionTo(m.Location));
SpamTimer t = new SpamTimer();
t.Start();
}
}
}
private class SpamTimer : Timer
{
public SpamTimer()
: base(TimeSpan.FromSeconds(30))
{
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
m_Talked = false;
}
}
private static void SayRandom(string[] say, Mobile m)
{
m.Say(say[Utility.Random(say.Length)]);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
are these changes all going in the BaseEscortable?Baseescortable not tied to the new quest system I believe is the problem...
Can try this instead: (based on movement, range= 4 tiles, and a 30 second spam timer)
[section 1] Add this:
[section 2] Add this:
Hell yeah. Thanks again for all the help.Two sections of code to add. First after the public class {}
Second before serialization
Good point. You could add the code directly to the NPCs instead of BaseEscortable. This would also allow more customization on what one NPC class would say from the next, which is more realistic since prisoners would plea for help.Hell yeah. Thanks again for all the help.
View attachment 21853
Questions I have about this system are the 30-second spam timer. This 30 seconds also affects other BaseEscortables. Is there a way to make that timer only affect the one who just spoke? How do I make it so the speech is only triggered by players and not critters/ghosts/hidden players?
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m.Alive && !m.Hidden && m is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)m;
string[] EscortSays = new string[]
{
"Pardon me citizen, but I am looking for a companion to assist thee.",
"I'm lost can you help me?",
"Might thou be willing to accompany me on a journey?",
"Hello adventurer I'm hiring an escort, would thou be interested?",
"Hail friend, I am seeking fellowship for a small expedition, wouldn't though care to join me?"
};
static List<int> CooldownList = new List<int> {};
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (m.Alive && !m.Hidden && m is PlayerMobile)
{
var pm = (PlayerMobile)m;
if (pm != null)
{
if (m.InRange(this, 4))
{
if (!CooldownList.Contains(Serial))
{
SayRandom(EscortSays, this);
this.Move(GetDirectionTo(m.Location));
CooldownList.Add(Serial);
SpamTimer t = new SpamTimer(Serial);
t.Start();
}
}
}
}
}
private class SpamTimer : Timer
{
public int Serial;
public SpamTimer(int serial)
: base(TimeSpan.FromSeconds(30))
{
Serial = serial;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
CooldownList.RemoveAll(x => x == Serial);
}
}
private static void SayRandom(string[] say, Mobile m)
{
m.Say(say[Utility.Random(say.Length)]);
}
Hell yeah. Thanks again for all the help.
View attachment 21853
Questions I have about this system are the 30-second spam timer. This 30 seconds also affects other BaseEscortables. Is there a way to make that timer only affect the one who just spoke? How do I make it so the speech is only triggered by players and not critters/ghosts/hidden players?
We use essential cookies to make this site work, and optional cookies to enhance your experience.