Page 1 of 1

Speech - NPC Respond with Gump

Posted: Fri Sep 12, 2008 4:12 am
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. :)

Posted: Mon Sep 15, 2008 8:51 pm
by stranf
Looks good.

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