Go Back   RunUO - Ultima Online Emulation > RunUO > Server Support on Windows

Server Support on Windows Get (and give) support on general questions related to the RunUO server itself.

Reply
 
Thread Tools Display Modes
Old 09-23-2003, 05:52 PM   #1 (permalink)
 
Join Date: Feb 2003
Location: Toronto, Ontario
Age: 20
Posts: 98
Send a message via AIM to Aidsteen Send a message via MSN to Aidsteen Send a message via Yahoo to Aidsteen
Default Nobles

I have a question about nobles. I play on a shard with a custom map, and I've agreed to set up the nobles for them. Now, the mobles won't allow people to transport them. I've changed their scripts, and I'm wondering how I set their destination points. Any help would be nice
Aidsteen is offline   Reply With Quote
Old 09-24-2003, 12:37 AM   #2 (permalink)
 
Join Date: Feb 2003
Location: Toronto, Ontario
Age: 20
Posts: 98
Send a message via AIM to Aidsteen Send a message via MSN to Aidsteen Send a message via Yahoo to Aidsteen
Default

bumperz
Aidsteen is offline   Reply With Quote
Old 09-24-2003, 12:54 AM   #3 (permalink)
Moderate
 
David's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 6,598
Default

Please don't bump your posts. Certianly not within a day. Instead try providing additional detail. We have a lot of helpful people here, if you do not get an answer it is usually because of a vauge or ambiguious question.

Since you are editing scripts, it may be better asked in Script Support anyway.... possibly post what you belive to be the offending scripts.
__________________
David Forum Moderator
The RunUO.com Forum Moderator Team

Forum Rules and Guidelines
RunUO Forum Search Engine
Download RunUO 2.0 RC2
David is offline   Reply With Quote
Old 09-24-2003, 09:35 AM   #4 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Post the code, and highlight what your confused about.

I assure you, YOU will do this yourself, somebody will just help guide you.
Phantom is offline   Reply With Quote
Old 09-24-2003, 10:16 AM   #5 (permalink)
 
Join Date: Feb 2003
Location: Toronto, Ontario
Age: 20
Posts: 98
Send a message via AIM to Aidsteen Send a message via MSN to Aidsteen Send a message via Yahoo to Aidsteen
Default

No no no, you have it wrong. I've edited the scripts just fine. I'm just not sure how you add destination points. And David, sorry about that, but it was already halfway down the 2nd page for me.
Aidsteen is offline   Reply With Quote
Old 09-24-2003, 12:42 PM   #6 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

If you want help, we need to see the code.
Phantom is offline   Reply With Quote
Old 09-24-2003, 09:18 PM   #7 (permalink)
 
Join Date: Feb 2003
Location: Toronto, Ontario
Age: 20
Posts: 98
Send a message via AIM to Aidsteen Send a message via MSN to Aidsteen Send a message via Yahoo to Aidsteen
Default

well, ok

BaseEscortable.cs
[code:1]using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Network;
using Server.ContextMenus;
using EDI = Server.Mobiles.EscortDestinationInfo;

namespace Server.Mobiles
{
public class BaseEscortable : BaseCreature
{
private EDI m_Destination;
private string m_DestinationString;

private DateTime m_DeleteTime;
private Timer m_DeleteTimer;

public override bool Commandable{ get{ return false; } } // Our master cannot boss us around!

[CommandProperty( AccessLevel.GameMaster )]
public string Destination
{
get{ return m_Destination == null ? null : m_Destination.Name; }
set{ m_DestinationString = value; m_Destination = EDI.Find( value ); }
}

private static string[] m_TownNames = new string[]
{
"Minas Tirith", "Peligar", "Lonely Mountain",
"Lake Town", "Dol Amroth", "Rivendell",
"Grey Havens", "Bree", "Iron Hills",
"Edoras", "Dunharrow", "Lothlorien"
};

[Constructable]
public BaseEscortable() : base( AIType.AI_Melee, FightMode.Agressor, 22, 1, 0.2, 1.0 )
{
InitBody();
InitOutfit();
}

public virtual void InitBody()
{
SetStr( 90, 100 );
SetDex( 90, 100 );
SetInt( 15, 25 );

Hue = Utility.RandomSkinHue();

if ( Female = Utility.RandomBool() )
{
Body = 401;
Name = NameList.RandomName( "female" );
}
else
{
Body = 400;
Name = NameList.RandomName( "male" );
}
}

public virtual void InitOutfit()
{
AddItem( new FancyShirt( Utility.RandomNeutralHue() ) );
AddItem( new ShortPants( Utility.RandomNeutralHue() ) );
AddItem( new Boots( Utility.RandomNeutralHue() ) );

switch ( Utility.Random( 4 ) )
{
case 0: AddItem( new ShortHair( Utility.RandomHairHue() ) ); break;
case 1: AddItem( new TwoPigTails( Utility.RandomHairHue() ) ); break;
case 2: AddItem( new ReceedingHair( Utility.RandomHairHue() ) ); break;
case 3: AddItem( new KrisnaHair( Utility.RandomHairHue() ) ); break;
}

PackGold( 200, 250 );
}

public virtual bool SayDestinationTo( Mobile m )
{
EDI dest = GetDestination();

if ( dest == null || !m.Alive )
return false;

Mobile escorter = GetEscorter();

if ( escorter == null )
{
Say( "I am looking to go to {0}, will you take me?", dest.Name );
return true;
}
else if ( escorter == m )
{
Say( "Lead on! Payment will be made when we arrive in {0}.", dest.Name );
return true;
}

return false;
}

private static Hashtable m_EscortTable = new Hashtable();

public static Hashtable EscortTable
{
get{ return m_EscortTable; }
}

private static TimeSpan m_EscortDelay = TimeSpan.FromMinutes( 5.0 );

public virtual bool AcceptEscorter( Mobile m )
{
EDI dest = GetDestination();

if ( dest == null )
return false;

Mobile escorter = GetEscorter();

if ( escorter != null || !m.Alive )
return false;

BaseEscortable escortable = (BaseEscortable)m_EscortTable[m];

if ( escortable != null && !escortable.Deleted && escortable.GetEscorter() == m )
{
Say( "I see you already have an escort." );
return false;
}
else if ( m is PlayerMobile && (((PlayerMobile)m).LastEscortTime + m_EscortDelay) >= DateTime.Now )
{
m.SendMessage( "You must wait before you can accept another escort." );
return false;
}
else if ( SetControlMaster( m ) )
{
m_LastSeenEscorter = DateTime.Now;

if ( m is PlayerMobile )
((PlayerMobile)m).LastEscortTime = DateTime.Now;

Say( "Lead on! Payment will be made when we arrive in {0}.", dest.Name );
m_EscortTable[m] = this;
StartFollow();
return true;
}

return false;
}

public override bool HandlesOnSpeech( Mobile from )
{
if ( from.InRange( this.Location, 3 ) )
return true;

return base.HandlesOnSpeech( from );
}

public override void OnSpeech( SpeechEventArgs e )
{
base.OnSpeech( e );

EDI dest = GetDestination();

if ( dest != null && !e.Handled && e.Mobile.InRange( this.Location, 3 ) )
{
if ( e.HasKeyword( 0x1D ) ) // *destination*
e.Handled = SayDestinationTo( e.Mobile );
else if ( e.HasKeyword( 0x1E ) ) // *i will take thee*
e.Handled = AcceptEscorter( e.Mobile );
}
}

public override void OnAfterDelete()
{
if ( m_DeleteTimer != null )
m_DeleteTimer.Stop();

m_DeleteTimer = null;

base.OnAfterDelete();
}

public override void OnThink()
{
base.OnThink();
CheckAtDestination();
}

protected override bool OnMove( Direction d )
{
if ( !base.OnMove( d ) )
return false;

CheckAtDestination();

return true;
}

public virtual void StartFollow()
{
StartFollow( GetEscorter() );
}

public virtual void StartFollow( Mobile escorter )
{
if ( escorter == null )
return;

ActiveSpeed = 0.1;
PassiveSpeed = 0.2;

ControlOrder = OrderType.Follow;
ControlTarget = escorter;

CurrentSpeed = 0.1;
}

public virtual void StopFollow()
{
ActiveSpeed = 0.2;
PassiveSpeed = 1.0;

ControlOrder = OrderType.None;
ControlTarget = null;

CurrentSpeed = 1.0;
}

private DateTime m_LastSeenEscorter;

public virtual Mobile GetEscorter()
{
if ( !Controled )
return null;

Mobile master = ControlMaster;

if ( master == null )
return null;

if ( master.Deleted || master.Map != this.Map || !master.InRange( Location, 30 ) || !master.Alive )
{
StopFollow();

TimeSpan lastSeenDelay = DateTime.Now - m_LastSeenEscorter;

if ( lastSeenDelay >= TimeSpan.FromMinutes( 2.0 ) )
{
Say( 1005653 ); // Hmmm. I seem to have lost my master.
SetControlMaster( null );
m_EscortTable.Remove( master );

Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), new TimerCallback( Delete ) );
return null;
}
else
{
ControlOrder = OrderType.Stay;
return master;
}
}

if ( ControlOrder != OrderType.Follow )
StartFollow( master );

m_LastSeenEscorter = DateTime.Now;
return master;
}

public virtual void BeginDelete()
{
if ( m_DeleteTimer != null )
m_DeleteTimer.Stop();

m_DeleteTime = DateTime.Now + TimeSpan.FromSeconds( 30.0 );

m_DeleteTimer = new DeleteTimer( this, m_DeleteTime - DateTime.Now );
m_DeleteTimer.Start();
}

public virtual bool CheckAtDestination()
{
EDI dest = GetDestination();

if ( dest == null )
return false;

Mobile escorter = GetEscorter();

if ( escorter == null )
return false;

if ( dest.Contains( Location ) )
{
Say( 1042809, escorter.Name ); // We have arrived! I thank thee, ~1_PLAYER_NAME~! I have no further need of thy services. Here is thy pay.

// not going anywhere
m_Destination = null;
m_DestinationString = null;

Container cont = escorter.Backpack;

if ( cont == null )
cont = escorter.BankBox;

Gold gold = new Gold( 500, 1000 );

if ( cont == null || !cont.TryDropItem( escorter, gold, false ) )
gold.MoveToWorld( escorter.Location, escorter.Map );

StopFollow();
SetControlMaster( null );
m_EscortTable.Remove( escorter );
BeginDelete();

return true;
}

return false;
}

public BaseEscortable( Serial serial ) : base( serial )
{
}

public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

writer.Write( (int) 0 ); // version

EDI dest = GetDestination();

writer.Write( dest != null );

if ( dest != null )
writer.Write( dest.Name );

writer.Write( m_DeleteTimer != null );

if ( m_DeleteTimer != null )
writer.WriteDeltaTime( m_DeleteTime );
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );

int version = reader.ReadInt();

if ( reader.ReadBool() )
m_DestinationString = reader.ReadString(); // NOTE: We cannot EDI.Find here, regions have not yet been loaded :-(

if ( reader.ReadBool() )
{
m_DeleteTime = reader.ReadDeltaTime();
m_DeleteTimer = new DeleteTimer( this, m_DeleteTime - DateTime.Now );
m_DeleteTimer.Start();
}
}

public override bool CanBeRenamedBy( Mobile from )
{
return ( from.AccessLevel >= AccessLevel.GameMaster );
}

public override void AddCustomContextEntries( Mobile from, ArrayList list )
{
EDI dest = GetDestination();

if ( dest != null && from.Alive )
{
Mobile escorter = GetEscorter();

if ( escorter == null || escorter == from )
list.Add( new AskDestinationEntry( this, from ) );

if ( escorter == null )
list.Add( new AcceptEscortEntry( this, from ) );
else if ( escorter == from )
list.Add( new AbandonEscortEntry( this, from ) );
}

base.AddCustomContextEntries( from, list );
}

public virtual string[] GetPossibleDestinations()
{
return m_TownNames;
}

public virtual string PickRandomDestination()
{
if ( Map.Felucca.Regions.Count == 0 || Map == null || Map == Map.Internal || Location == Point3D.Zero )
return null; // Not yet fully initialized

string[] possible = GetPossibleDestinations();
string picked = null;

while ( picked == null )
{
picked = possible[Utility.Random( possible.Length )];
EDI test = EDI.Find( picked );

if ( test != null && test.Contains( Location ) )
picked = null;
}

return picked;
}

public EDI GetDestination()
{
if ( m_DestinationString == null && m_DeleteTimer == null )
m_DestinationString = PickRandomDestination();

if ( m_Destination != null && m_Destination.Name == m_DestinationString )
return m_Destination;

if ( Map.Felucca.Regions.Count > 0 )
return ( m_Destination = EDI.Find( m_DestinationString ) );

return ( m_Destination = null );
}

private class DeleteTimer : Timer
{
private Mobile m_Mobile;

public DeleteTimer( Mobile m, TimeSpan delay ) : base( delay )
{
m_Mobile = m;

Priority = TimerPriority.OneSecond;
}

protected override void OnTick()
{
m_Mobile.Delete();
}
}
}

public class EscortDestinationInfo
{
private string m_Name;
private Region m_Region;
//private Rectangle2D[] m_Bounds;

public string Name
{
get{ return m_Name; }
}

public Region Region
{
get{ return m_Region; }
}

/*public Rectangle2D[] Bounds
{
get{ return m_Bounds; }
}*/

public bool Contains( Point3D p )
{
return m_Region.Contains( p );
}

public EscortDestinationInfo( string name, Region region )
{
m_Name = name;
m_Region = region;
}

private static Hashtable m_Table;

public static void LoadTable()
{
ArrayList list = Map.Felucca.Regions;

if ( list.Count == 0 )
return;

m_Table = new Hashtable();

for ( int i = 0; i < list.Count; ++i )
{
Region r = (Region)list[i];

if ( r is Regions.FeluccaDungeon || r is Regions.FeluccaTown )
m_Table[r.Name] = new EscortDestinationInfo( r.Name, r );
}
}

public static EDI Find( string name )
{
if ( m_Table == null )
LoadTable();

if ( name == null || m_Table == null )
return null;

return (EscortDestinationInfo)m_Table[name];
}
}

public class AskDestinationEntry : ContextMenuEntry
{
private BaseEscortable m_Mobile;
private Mobile m_From;

public AskDestinationEntry( BaseEscortable m, Mobile from ) : base( 6100, 3 )
{
m_Mobile = m;
m_From = from;
}

public override void OnClick()
{
m_Mobile.SayDestinationTo( m_From );
}
}

public class AcceptEscortEntry : ContextMenuEntry
{
private BaseEscortable m_Mobile;
private Mobile m_From;

public AcceptEscortEntry( BaseEscortable m, Mobile from ) : base( 6101, 3 )
{
m_Mobile = m;
m_From = from;
}

public override void OnClick()
{
m_Mobile.AcceptEscorter( m_From );
}
}

public class AbandonEscortEntry : ContextMenuEntry
{
private BaseEscortable m_Mobile;
private Mobile m_From;

public AbandonEscortEntry( BaseEscortable m, Mobile from ) : base( 6102, 3 )
{
m_Mobile = m;
m_From = from;
}

public override void OnClick()
{
m_Mobile.Delete(); // OSI just seems to delete instantly
}
}
}[/code:1][/code]
Aidsteen is offline   Reply With Quote
Old 09-24-2003, 09:31 PM   #8 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

What part of that code did you edit?

Does it have any errors?

What works, what doesn't.
Phantom is offline   Reply With Quote
Old 09-24-2003, 09:47 PM   #9 (permalink)
 
Join Date: Feb 2003
Location: Toronto, Ontario
Age: 20
Posts: 98
Send a message via AIM to Aidsteen Send a message via MSN to Aidsteen Send a message via Yahoo to Aidsteen
Default

everything in it works, I edited the town names. All I need to know is how do I add noble's destination points?
Aidsteen is offline   Reply With Quote
Old 09-24-2003, 10:52 PM   #10 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Well m_Destination is choosen randomly so you would have to change the class so it isn't.
Phantom is offline   Reply With Quote
Old 09-25-2003, 01:17 AM   #11 (permalink)
 
Join Date: Feb 2003
Location: Toronto, Ontario
Age: 20
Posts: 98
Send a message via AIM to Aidsteen Send a message via MSN to Aidsteen Send a message via Yahoo to Aidsteen
Default

so what, do I need to have the destinations in the Regions.xml file?
Aidsteen is offline   Reply With Quote
Old 09-25-2003, 01:44 AM   #12 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Well, in this case yes it loops through the locations in Region.xml and picks a region it likes.
Phantom is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5