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!

Making Vendor live own life...

daat99

Moderator
Staff member
You too don't have OnThink method that accept a mobile as an argument:
Code:
public virtual void OnThink()
 

-Nox-

Wanderer
I agree. Having it accept a mobile argument in your case would be absolutley pointless. :rolleyes:

DO NOT USE AN ARGUMENT!

*slaps hand*
NO! BAD!

-Nox
 

Packer898

Knight
daat99 said:
You too don't have OnThink method that accept a mobile as an argument:
Code:
public virtual void OnThink()

Hehe when I got home I relooked up that mobile and I did remove the Mobile from argument from the OnThink method. =)- daat99 shoots and scores!
 

daat99

Moderator
Staff member
Galfaroth said:
So backing to topic, is there way to make it work with basevendor?
Ok I'm going to tell you 1 last time and then if you ask again I'm just ignoring you.
Use the OnThink method.
 

Galfaroth

Wanderer
Galfaroth said:
OK Packer, your idea:


Code:
		public override void OnThink( Mobile from )
		{
			if ( from is PlayerMobile )
			{
				PlayerMobile pm = (PlayerMobile)from;
				
				if ( 0 < DateTime.Compare( DateTime.Now, m_NextSpeakTime && from.InRange( this, 4 ) )
				{
					Say( m_Phrases[Utility.Random( m_Phrases.Length )] );
					m_NextSpeakTime = DateTime.Now + ( TimeSpan.FromSeconds( 10 ) );
				}

      		}

      		base.OnThink();
		}

Cause the error:

Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\Mobiles\Vendors\BaseVendor.cs: CS0115: (line 241, column 24) '
Server.Mobiles.BaseVendor.OnThink(Server.Mobile)': no suitable method found to o
verride

It is the best, but not work correctly


As you see OnThink in BaseVendor.cs doesn't compile, cause OnThink hasn't Mobile argument.
 

daat99

Moderator
Staff member
Galfaroth said:
As you see OnThink in BaseVendor.cs doesn't compile, cause OnThink hasn't Mobile argument.
Are you reading my messages at all???
Read post #51 because I told you what you need to do!!!
 

Galfaroth

Wanderer
daat99 said:
Code:
public override void OnThink([COLOR="Blue"] Mobile from [/COLOR])
There's no OnThink method that accept a mobile as an argument.
Either create a method that accept a mobile as an argument or use the method that is already there.

I know there is no, but OnThink is the best method that can be used here... Using method that is already there (to add lines to all vendors) will take ages (I have 122 vendors), so I want to use global (basevendor.cs) method, but as I can see it isn't posiible, is it?
 

daat99

Moderator
Staff member
Galfaroth said:
I know there is no, but OnThink is the best method that can be used here... Using method that is already there (to add lines to all vendors) will take ages (I have 122 vendors), so I want to use global (basevendor.cs) method, but as I can see it isn't posiible, is it?
daat99 said:
Either create a method that accept a mobile as an argument or use the method that is already there.
Now you reading this or you just going to paste it again and ignore it???
 

TMSTKSBK

Lord
Quick fix:

top of script:
private Mobile passMobile;

before call:
passMobile = mobile; //the one you want to supply as argument

mobile2.OnThink();

....


public override void OnThink()
{
Mobile internal = passMobile;
}
 

Packer898

Knight
Might try this or something similiar. I dont think the line I marked is the right call there maybe someone else can clarify that =)-

Code:
		public virtual void OnThink()
		{
			foreach ( Mobile m in [COLOR="Red"]World.Mobiles[/COLOR] )       //[COLOR="Red"]<--- This part is suspect. May need to be reworded.[/COLOR]
			{
				if ( m is PlayerMobile )
				{
					PlayerMobile pm = (PlayerMobile)m;
				
					if ( DateTime.Now >= m_NextSpeakTime && pm.InRange( this, 4 ) )
					{
						switch ( Utility.Random( 6 ) )
						{
							case 0: Say("Ludzie zawsze gadaja..."); break;
							case 1: Say("Nie powinnismy o tym mowic."); break;
							case 2: Say("Krol Rhobar jest chyba najlepszym wladca ktorego mielismy."); break;
							case 3: Say("Nie, nie.."); break;
							case 4: Say("No tak... to prawda."); break;
							case 5: Say("Moze pogodzimy ich ze soba..."); break;
						};
						m_NextSpeakTime = (DateTime.Now + TimeSpan.FromSeconds( 10 ));
					}
				}
			}
			base.OnThink();
		}
 

Aeolus

Sorceror
rsmiller21 said:
Packer :)

Ok, here we are. This snippet will respond to vendors and players. You can add more sayings by changing the Random number and adding more cases. This has been tested and works. Just throw it into and vendor, not basevendor:

Code:
private DateTime m_NextTalk;
		private string m_name;
		public DateTime NextTalk{ get{ return m_NextTalk; } set{ m_NextTalk = value; } }
   
		public override void OnMovement( Mobile m, Point3D oldLocation )
		{
			if( m is BaseVendor )
			{
				if ( DateTime.Now >= m_NextTalk && InRange( m, 4 ) && InLOS( m ) ) // check if it's time to talk & if mobile in range & in los.
				{
					m_name = m.Name;
					switch ( Utility.Random( 4 )) //the amount of lines you have it to choose from
					{
						[COLOR="Red"]case 0:[/COLOR] Say(m_name + ", how are you doing today?"); break; //line 1
						[COLOR="Red"]case 1:[/COLOR] Say("I hate that guy don't you " + m_name + " ?"); break; //line 2
						[COLOR="Red"]case 3:[/COLOR] Say("I wonder what I am going to have for dinner."); break; //line 3
					};
					m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds( 10 )); //channge the number 10 to the min amount of seconds to wait between talks.
				}
			}

			if( m is PlayerMobile )
			{
				if ( DateTime.Now >= m_NextTalk && InRange( m, 4 ) && InLOS( m ) ) // check if it's time to talk & if mobile in range & in los.
				{
					m_name = m.Name;
					switch ( Utility.Random( 4 )) //the amount of lines you have it to choose from
					{
						[COLOR="Red"]case 0:[/COLOR] Say(m_name + ", how are you doing today?"); break; //line 1
						[COLOR="Red"]case 1:[/COLOR] Say("What can I do for you " + m_name + " ?"); break; //line 2
						[COLOR="Red"]case 3:[/COLOR] Say("I wonder what I am going to have for dinner."); break; //line 3
					};
					m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds( 10 )); //channge the number 10 to the min amount of seconds to wait between talks.
				}
			}
		}

This however, should work the way you want regardless if anyone is present. The only trigger is the movement. This code is tested and works as well:

Code:
private DateTime m_NextTalk;
		private string m_name;
		public DateTime NextTalk{ get{ return m_NextTalk; } set{ m_NextTalk = value; } }
   
		public override void OnMovement( Mobile m, Point3D oldLocation )
		{
			if( m is BaseVendor )
			{
				if ( DateTime.Now >= m_NextTalk && InRange( m, 500 ) ) // check if it's time to talk & if mobile in range & in los.
				{
					m_name = m.Name;
					switch ( Utility.Random( 8 )) //the amount of lines you have it to choose from
					{
						[COLOR="Red"]case 0:[/COLOR] Say(m_name + ", how are you doing today?"); break; //line 1
						[COLOR="Red"]case 1:[/COLOR] Say("I hate that guy don't you " + m_name + " ?"); break; //line 2
						[COLOR="Red"]case 3:[/COLOR] Say("I wonder what I am going to have for dinner."); break; //line 3
					};
					m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds( 10 )); //channge the number 10 to the min amount of seconds to wait between talks.
				}
			}
}

Ok, I'm a nOOb, but out of curiosity, why does this skip from case 1 to case 3? Is it just a mistake or was that intentional? I have tried the script, and it works fine- I didn't notice it until after I tried it and wanted to edit the speech. Thanks for any responses.
 

X-SirSly-X

Sorceror
Hope this helps:

Code:
switch ( Utility.Random( 8 ))

means its going to pick one random case statement from 8 chances, even if the chances are not written ( like the 2,4,5,6,7,8) then it will be null, and depending on the script will behave accordingly. In this script the npc will not say anything.
 

daat99

Moderator
Staff member
Aeolus said:
Very helpful- thank you!
Aeolus first I like to say welcome to RunUO.
Second please try not to bump old threads.
If you see something simliar that you have a question about it'll be a lot better if you just start a new thread where you'll ask your question and add a link to the thread you are refering to so we will understand what you're talking about.
Also I like to say that you should take a look at the rules, while you didn't broke any (that I'm aware of) it's a good thing to know what rules we have here, it'll make people a lot nicer to you if you won't break the rules than if you did (knowingly or not).
Again I'm not saying that you broke the rules, just gives you a headsup before you might break them and get on the bad side of people here.
 

Joeku

Lord
Packer898 said:
Might try this or something similiar. I dont think the line I marked is the right call there maybe someone else can clarify that =)-

Code:
        public virtual void OnThink()
        {
            foreach ( Mobile m in [COLOR=red]World.Mobiles[/COLOR] )       //[COLOR=red]<--- This part is suspect. May need to be reworded.[/COLOR]
            {
                if ( m is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)m;
 
                    if ( DateTime.Now >= m_NextSpeakTime && pm.InRange( this, 4 ) )
                    {
                        switch ( Utility.Random( 6 ) )
                        {
                            case 0: Say("Ludzie zawsze gadaja..."); break;
                            case 1: Say("Nie powinnismy o tym mowic."); break;
                            case 2: Say("Krol Rhobar jest chyba najlepszym wladca ktorego mielismy."); break;
                            case 3: Say("Nie, nie.."); break;
                            case 4: Say("No tak... to prawda."); break;
                            case 5: Say("Moze pogodzimy ich ze soba..."); break;
                        };
                        m_NextSpeakTime = (DateTime.Now + TimeSpan.FromSeconds( 10 ));
                    }
                }
            }
            base.OnThink();
        }
World.Mobiles.Values
 
Top