RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 1.0 Final/2.0 RC1] Talking, Training Npc's...

penndragon

Sorceror
[RunUO 1.0 Final/2.0 RC1] Talking, Training Npc's...

I use these to add a feeling of "Life" to towns and other areas where things feel "Dead".
They have some random phrases that they say when players are around and each one can train 2 basic skills. (Phrases and Skills are easily changeable).

They also have a large set of random clothing and titles so that they all appear different when spawned together.

Installation: Just drop in to you custom folder and either [add Commoner1 (change the number 1-6 to get the different NPC's) or add to spawner (same i.e. commoner1, commoner2, commoner3, and so on..... )

Hope these are helpful to some.
Enjoy.

Edit: Sorry for the problems, Changed to the right files.

Edit: Added the Personalized NPC's of commoner2, 4, 6. That way half just talk randomly and half will use the players name. If you want them all to use the players name the edits are here in this thread. Thank you very much ratzerna for the edits.
 

Attachments

  • Talking NPCs.zip
    12.5 KB · Views: 507
  • Personalized Talking NPC's.zip
    6.4 KB · Views: 406

zardoz

Sorceror
Just FYI, Scripts for Commoner2-6 are broken in that they have not had all the Commoner1 changed to Commoner[2-6] as required.
You also have spelling errors in that you reference to Utility.RandonNeutralHue rather than Utility.RandomNeutralHue.
Easy to fix, but not plug&play as it stands.

Z
 

Nam01

Wanderer
oh

i installed on runuo 2.0 and got these errors

RunUO - [www.runuo.com] Version 2.0, Build 2357.32527
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (5 errors, 0 warnings)
Errors:
+ Custom/TalkingNPC/Commoner2.cs:
CS1520: Line 178: Class, struct, or interface method must have a return type

CS1002: Line 178: ; expected
CS1519: Line 178: Invalid token ')' in class, struct, or interface member de
claration
+ Custom/TalkingNPC/Commoner3.cs:
CS1520: Line 177: Class, struct, or interface method must have a return type

CS1002: Line 177: ; expected
CS1519: Line 177: Invalid token ')' in class, struct, or interface member de
claration
+ Custom/TalkingNPC/Commoner4.cs:
CS1520: Line 178: Class, struct, or interface method must have a return type

CS1002: Line 178: ; expected
CS1519: Line 178: Invalid token ')' in class, struct, or interface member de
claration
+ Custom/TalkingNPC/Commoner5.cs:
CS1520: Line 178: Class, struct, or interface method must have a return type

CS1002: Line 178: ; expected
CS1519: Line 178: Invalid token ')' in class, struct, or interface member de
claration
+ Custom/TalkingNPC/Commoner6.cs:
CS1520: Line 175: Class, struct, or interface method must have a return type

CS1002: Line 175: ; expected
CS1519: Line 175: Invalid token ')' in class, struct, or interface member de
claration
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

penndragon

Sorceror
Sorry........

Sorry, was working on some changes and uploaded the wrong set of files. The problem is fixed now. Hope you enjoy them.
 

Ajax2000

Wanderer
Nice script.

Any idea how to get the NPCs to say the players name as he walks by?

Like "Hello there Ajax, how are you today?"
 
hmm, do i need any scripts on top of this one? they spawn fine and they talk fine, but i can't seem to get the train menu with a click or anything. Any ideas?
 

penndragon

Sorceror
They don't require any extra scripts. The only thing I can think of is that your skills are too high when you are trying to train. On a clean install they work fine here. They can only train to about 23 or 23 points. Try it with a new char is all I can think of.
 
FIGURED IT OUT! I was using Play UO from the begining and it would make my Razor Crash. So I assumed razor was not working. It would also make the server time out in character customization and YOUR SCRIPT not function. Play Uo is apparently really bad so that's where all my problems were comming from, this script is awesome man thanks.
 

ratzerna

Sorceror
Here is the code from the PK NPC scripts I have:

Notice the {0} part of the String. That should fix you up on saying the player name. I'm not 100% sure, but I think it's getting the name from the "Mobile from" being passed in. Worth a try. Should work with your SayRandom method.

Code:
        public override void OnDamage( int amount, Mobile from, bool willKill )
        {
            if ( from != null && !willKill && amount > 5 && from.Player && 5 > Utility.Random( 20 ) )
            {
                string[] toSay = new string[]
                {
                    "trammie noob",
                    "{0}!!  stupid nubi ganker!",
                    "OMG Gank Much???",
                    "{0}!!  piss off noob"
                };
                this.Say( true, String.Format( toSay[Utility.Random( toSay.Length )], from.Name ) );
            }
            
            base.OnDamage( amount, from, willKill );
        }
 

ratzerna

Sorceror
I just tested it on my test system and it appears to work. here is the modified code fragments.
Code:
        public Commoner1( Serial serial ) : base( serial )
        {
        }
        
                public override void OnMovement( Mobile m, Point3D oldLocation ) 
               {                                                    
                 if( m_Talked == false ) 
                 { 
                        if ( m.InRange( this, 1 ) ) 
                        {                
                          m_Talked = true; 
[B][COLOR=Red]                               SayRandom( kfcsay, this, m ); [/COLOR][/B]
                this.Move( GetDirectionTo( m.Location ) ); 
                SpamTimer t = new SpamTimer(); 
                t.Start(); 
                        } 
        } 
    }
Code:
[B][COLOR=Red]     private static void SayRandom( string[] say, Mobile m, Mobile t ) [/COLOR][/B]
    { 
        [B][COLOR=Red]m.Say( String.Format("{0}, " + say[Utility.Random( say.Length )] ,t.Name) ); [/COLOR][/B]
    }
 

penndragon

Sorceror
Thankyou so much....... I will give it a test also and if it stays stable I will update the package. :) Thanks again.
 

ratzerna

Sorceror
You may not want to stick the "{0}, " in the SayRandom method though. If you make it part of your commoner sayings the String.Format should part should still work okay with the target.Name replacement.

That will give you the flexibility to have sayings with the Target name or just generic ramblings that could be for anybody.

Ratzerna
 

chocomog

Wanderer
npc's not showing the custome titles

fantastic idea I love it. adds just a litte life to the towns. everything works fine except they do not show the title next to thier name.
so I see bob , not bob the peasant
I set them so that the title represents sorta the skills they offer to train some static depending on the npc and a few that are random so that they all do not spawn the same skills. I also have them set to train up to a random up to a max 75 in the skills thay have. and adjusted some of the cloths to better represent thier proffession. here is one of my alterated scripts. I do not think I changed anything else. but I love what you have done with this thanks.
Code:
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Mobiles;
using Server.ContextMenus;

namespace Server.Mobiles
{
    public class Commoner3 : BaseCreature
    {

		public override bool CanTeach{ get{ return true; } }

    		private static bool m_Talked;

		string[] kfcsay = new string[]
		{
		
		"Good Day!!!",
		"Hail",
		"Can I help you?",
		"Are you from around here?",
		"Have you heard any good gossip?",
		"Have you ever ridden a dragon?",
		"I quit comeing to town when that tanner tried to pawn some ferret hides for my dragon scales",
		"Sorry. No time to talk.",
		"Where are you going?",
		"You look lost.",
		"Where has the day gone?",
		"Be safe",
		"Safe Travels",
		"Please give me a minute.",
		"Be kind to furry animals",
		"Will you help keep the forsests clean?",
		"You look tired",
		"You should rest",
		"You need Help?",
		"Have a nice day!!!",
		"*opps* sorry",
		"What a wonderful Day!!!",
		"I shoulda stayed in bed"
		};

        private static string[] Titles = new string[]
        {
            "the explorer",
            "the lumberjack",
            "the elf",
            "the outlander",
            "the mountainier",
            "the traveler"
        };

        [Constructable]
        public Commoner3() : base( AIType.AI_Melee, FightMode.None, 10, 1, 0.8, 3.0 ) 
        {
            SetStr( 200, 300 );
            SetDex( 200, 300 );
            SetInt( 10, 30 );
			SetHits( 150, 300 );
			SetMana( 50 );
            Fame = 4000;
            Karma = 0;
	switch ( Utility.Random( 3 ))
			{
				case 0: SetSkill( SkillName.Fencing, 66.0, 150.5 ); break;
				case 1: SetSkill( SkillName.Macing, 65.0, 150.5 ); break;
				case 2: SetSkill( SkillName.Swords, 65.0, 150.5 ); break;
			}
						SetSkill( SkillName.Tactics, 65.0, 150.5 ); 
	switch ( Utility.Random( 7 ))
			{
				case 0: SetSkill( SkillName.DetectHidden, 0.0, 150 ); break;
				case 1: SetSkill( SkillName.AnimalTaming, 20.0, 150.0 ); break;
				case 2: SetSkill( SkillName.TasteID, 10.0, 150.0 ); break;
				case 3: SetSkill( SkillName.Veterinary, 25.0, 150.0 ); break;
				case 4: SetSkill( SkillName.AnimalLore, 30.0, 150.0 ); break;
				case 5: SetSkill( SkillName.Tracking, 36.0, 150.0 ); break;
				case 6: SetSkill( SkillName.Cooking, 45.0, 150.0 ); break;
			}
	   
            SpeechHue = Utility.RandomDyedHue();
            Title = string.Empty;//Commoner3.Titles[Utility.Random( 0, Titles.Length )];
            Hue = Utility.RandomSkinHue();
            if ( this.Female = Utility.RandomBool() )
            {
                this.Body = 0x191;
                this.Name = NameList.RandomName( "female" );
                Item hair = new Item( Utility.RandomList( 0x203B, 0x203C, 0x203D, 0x2045, 0x204A, 0x2046 , 0x2049 ) );
                hair.Hue = Utility.RandomHairHue();
                hair.Layer = Layer.Hair;
                hair.Movable = false;
                AddItem( hair );
                Item hat = null;
                switch ( Utility.Random( 5 ) )//4 hats, one empty, for no hat
                {
                    case 0: hat = new FloppyHat( Utility.RandomNeutralHue() );		break;
                    case 1: hat = new BearMask( Utility.RandomNeutralHue() );	break;
                    case 2: hat = new DeerMask();			break;
                    case 3: hat = new FeatheredHat( Utility.RandomNeutralHue() );			break;
                }
                AddItem( hat );
                Item pants = null;
                switch ( Utility.Random( 3 ) )
                {
                    case 0: pants = new ShortPants( GetRandomHue() );	break;
                    case 1: pants = new LongPants( GetRandomHue() );	break;
                    case 2: pants = new Skirt( GetRandomHue() );		break;
                }
                AddItem( pants );
                Item shirt = null;
                switch ( Utility.Random( 7 ) )
                {
                    case 0: shirt = new Doublet( GetRandomHue() );		break;
                    case 1: shirt = new ElvenShirt( GetRandomHue() );		break;
                    case 2: shirt = new ElvenDarkShirt( GetRandomHue() );		break;
                    case 3: shirt = new Robe( GetRandomHue() );	break;
                    case 4: shirt = new Robe( GetRandomHue() );	break;
                    case 5: shirt = new FancyShirt( GetRandomHue() );	break;
                    case 6: shirt = new Shirt( GetRandomHue() );		break;
                }
                AddItem( shirt );
            }
            else
            {
                this.Body = 0x190;
                this.Name = NameList.RandomName( "male" );
                Item hair = new Item( Utility.RandomList( 0x203B, 0x203C, 0x203D, 0x2044, 0x2045, 0x2047, 0x2048 ) );
                hair.Hue = Utility.RandomHairHue();
                hair.Layer = Layer.Hair;
                hair.Movable = false;
                AddItem( hair );				
                Item beard = new Item( Utility.RandomList( 0x0000, 0x203E, 0x203F, 0x2040, 0x2041, 0x2067, 0x2068, 0x2069 ) );
                beard.Hue = hair.Hue;
                beard.Layer = Layer.FacialHair;
                beard.Movable = false;
                AddItem( beard );
                Item hat = null;
                switch ( Utility.Random( 7 ) ) //6 hats, one empty, for no hat
                {
                    case 0: hat = new SkullCap( GetRandomHue() );					break;
                    case 1: hat = new Bandana( GetRandomHue() );					break;
                    case 2: hat = new WideBrimHat();								break;
                    case 3: hat = new DeerMask( Utility.RandomNeutralHue() );	break;
                    case 4: hat = new BearMask( Utility.RandomNeutralHue() );		break;
                    case 5: hat = new FeatheredHat( Utility.RandomNeutralHue() );	break;
                }
                AddItem( hat );
                Item pants = null;
                switch ( Utility.Random( 2 ) )
                {
                    case 0: pants = new ShortPants( GetRandomHue() );	break;
                    case 1: pants = new LongPants( GetRandomHue() );	break;
                }
                AddItem( pants );
                Item shirt = null;
                switch ( Utility.Random( 5 ) )
                {
                    case 0: shirt = new ElvenDarkShirt( GetRandomHue() );		break;
                    case 1: shirt = new Robe( GetRandomHue() );		break;
                    case 2: shirt = new Tunic( GetRandomHue() );		break;
                    case 3: shirt = new ElvenShirt( GetRandomHue() );	break;
                    case 4: shirt = new Shirt( GetRandomHue() );		break;
                }
                AddItem( shirt );
            }

            Item feet = null;
            switch ( Utility.Random( 3 ) )
            {
                case 0: feet = new Sandals( Utility.RandomNeutralHue() );	break;
                case 1: feet = new ThighBoots( Utility.RandomNeutralHue() );	break;
                case 2: feet = new ElvenBoots( Utility.RandomNeutralHue() );		break;
            }
            AddItem( feet );
            Container pack = new Backpack();

            pack.DropItem( new Gold( 0, 50 ) );

            pack.Movable = false;

            AddItem( pack );
        }

        public Commoner3( Serial serial ) : base( serial )
        {
        }
        
        		public override void OnMovement( Mobile m, Point3D oldLocation ) 
               {                                                    
         		if( m_Talked == false ) 
        		 { 
          		 	 if ( m.InRange( this, 1 ) ) 
          			  {                
          				m_Talked = true; 
              				SayRandom( kfcsay, this ); 
				this.Move( GetDirectionTo( m.Location ) ); 
				SpamTimer t = new SpamTimer(); 
				t.Start(); 
            			} 
		} 
	} 

	private class SpamTimer : Timer 
	{ 
		public SpamTimer() : base( TimeSpan.FromSeconds( 10 ) ) 
		{ 
			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 )] ); 
	}

        private static int GetRandomHue()
        {
            switch ( Utility.Random( 6 ) )
            {
                default:
                case 0: return 0;
                case 1: return Utility.RandomBlueHue();
                case 2: return Utility.RandomGreenHue();
                case 3: return Utility.RandomRedHue();
                case 4: return Utility.RandomYellowHue();
                case 5: return Utility.RandomNeutralHue();
            }
        }

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

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

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

            int version = reader.ReadInt();
        }
    }
}
thanks for any help you may have on getting the titles to display. all my venders display thier titles gust not these guys.
 
Top