Speech - NPC Respond with Gump

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
Mindless Automaton
UOX3 Apprentice
Posts: 189
Joined: Wed May 10, 2006 3:48 am
Has thanked: 0
Been thanked: 1 time
Contact:

Speech - NPC Respond with Gump

Post by Mindless Automaton »

This is just something I am fooling' around with:

Code: Select all

function onSpeech( myString, myPlayer, myNPC, pSock )
{
	
		if( !myNPC.InRange( myPlayer, 2 ) )
		return;
	var Speech_Array = myString.split(" ");
	var i = 0, currObj = 0;

	for( i = 1; i <= Speech_Array.length; i++ ) 
	{
		if( Speech_Array[currObj].match( /\bHail\b/i ) || Speech_Array[currObj].match( /\bHi\b/i ) || Speech_Array[currObj].match( /\bGreet\b/i ) || Speech_Array[currObj].match( /\bHello\b/i ))	
		{			
			myNPC.TextMessage( "Greetings, I am " + myNPC.name + "." );
			return;		}
			
		if( Speech_Array[currObj].match( /\bjob\b/i ))	
		{			
			myNPC.TextMessage( "I show you a card when you say 'show'." );
			return;		}

		if( Speech_Array[currObj].match( /\bshow\b/i ))	
		{			
			var myGump = new Gump; // create a new gump
			myGump.AddGump( 0, 0, 0x89C ); // add tile art
			myGump.AddGump( 210, 200, 0x6B ); // add tile art
			myGump.AddText( 195, 155, 0, "2" );
			myGump.AddText( 280, 290, 0, "2" );
			myGump.AddButton( 250, 310, 0xF7, 1, 0, 1 ); // add the "okay" button
			myGump.Send( myPlayer ); // send this gump to client now
			myGump.Free(); // clear this gump from uox-memory
			return false;
		}

		currObj++;
	}
}

Anyways, it could be the NPC shows you a map or a page from a book or whatever. Although, you may want to have it close when the PC leaves range.

What I am attempting to do is have the PC guess a number and then the NPC will show the card and give the PC a gold piece or something if they are right.

If anyone knows of card art hidden in the muls somewhere that I didnt see, let me know. :)
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Looks good.

My mind is trying to figure out what interesting things I can come up with, with this script. :)
Post Reply