Exult Logo
 
Home | Download | Documentation | FAQ | Studio | Screen Shots
Development | Discussion | About Us | Letters | History | Links
 
Exult Discussion
Before posting, make sure you've read the FAQ and searched the message board for previous discussions. When reporting problems/bugs, please include details about your setup (Exult version, OS, sound and video cards).

 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 NPC Conversations
Author: agentorangeguy (---.localdomain)
Date:   08-01-09 20:47

I am needing a little help on NPC Conversations. I am trying to figure out how to make it to where you talk to one NPC, we'll call "NPC_A" and when the Met flag is set, when you talk to "NPC_B", "NPC_A"'s name shows up as a conversation topic when you met NPC_A.

I know it goes something like MET_NPC_A = ?? but I don't know how to figure out what number corresponds to that (what would go in the ?? space).

Reply To This Message
 
 Re: NPC Conversations
Author: Malignant Manor 
Date:   08-01-09 21:35

const int NPC_A= -200; // sample npc number
const int NPC_B= -201; // sample npc number
const int MET = 28; // met flag number

// npc A's function

	if (UI_get_item_flag(NPC_B, MET))
		add("NPC B");

	converse (0)
	{
		case "NPC B" (remove):
			// Met dialog, etc
		case	// other dialog cases and rest of function
	}

// npc B's function

	if (UI_get_item_flag(NPC_A, MET))
		add("NPC A");
	converse (0)
	{
		case "NPC A" (remove):
			// Met dialog, etc
		case	// other dialog cases and rest of function
	}	




If you have problems finding npc numbers:

The cheat key that has a default of ctrl-n will show npc numbers if they are already in the game. You need to left click on them though. Opening Exult Studio through the alt-ctrl-m inside Exult will link the two together enabling you to see a list of all npcs. Pressing F2 and using the [N]pc tool also let you see npcs already in the game. If it is in BG or SI, then the Keyring and SI Fixes sources (under content in the Exult source) have comprehensive npc lists in their headers. Npc functions are 0x400 + the positive value of the npc number.

Just remember that the npc number needs to be a negative number.

Reply To This Message
 
 Re: NPC Conversations
Author: agentorangeguy (---.localdomain)
Date:   08-08-09 14:02

Ok I'm still hitting a few snags on this.

I set the conversation up like that, but "NPC A" is still showing up in NPC B's topics even though NPC A hasn't been met and vice versa.

Also, how does one set an alternate greeting? Like when you first meet someone it says one thing, then if you have met them, it says another thing from then on?

Is it possible to set a greeting for morning/evening? like if you talk to the npc at night, the greeting is different than the greeting in the morning?

Thanks!

Reply To This Message
 
 Re: NPC Conversations
Author: Malignant Manor 
Date:   08-09-09 03:54

Check to make sure the npcs don't already have the met flag. I'm not sure what triggers the met flag off-hand.(never used it) The Avatar starts with it, and I think converse might set it.

If that doesn't work then you could try using global flags. Time checks for greetings are also in the following code. See also the UI_part_of_day() intrinsic that is similar but with less control.


const int MET_NPC_A = 2000 // example number
const int  MET_NPC_B = 2001

NPC A example:
	if (event == DOUBLECLICK)
	{
		if (!UI_get_item_flag(NPC_A, MET)) // un comment the next two comments and delete this if you still have trouble with met flag
//		if (!gflags(MET_NPC_A))
		{
//			gflags(MET_NPC_A) = true;
			// first meeting greetings
		}
	// already met greetings
		else if (UI_game_hour() >= 12 && UI_game_hour() < 18) // adjust to 24 hour time you feel is appropriate
		{
			// good afternoon
		}
		else if (UI_game_hour() >= 18 || UI_game_hour() < 6)
		{
			// night greeting
		}
		else
		{
			// morning greeting
		}
//		if (gflags(MET_NPC_B)	// using gflags example for if still having met flag issues
//			add("NPC B");
		//rest of doubleclick event usecode
	}

Reply To This Message
 
 Re: NPC Conversations
Author: agentorangeguy (---.localdomain)
Date:   08-14-09 18:54

Ok I'm still having a little trouble with getting that to work. I guess the first thing I want to work out is how to get the NPCs to change their greeting after that NPC has been met. Here is a example npc script I will paste here to show you the basic setup of a test npc. I don't know who the actual npc is, I think it might be one of the skara brae ghosts. I just pulled the number

#game "blackgate"

void TestNPC object# (0x493) ()
{

var DOUBLECLICK= 1;
if (event == DOUBLECLICK)
{
TestNPC.say("You see a Test NPC");


//TestNPC.say("Back already?");
//what npc is supposed to say after MET.. still can't get it to work.


}


var options = ["name", "job", "bye"];


converse(options)
{

case "name":
say("\"Insert Name hEre\"");


case "job":
say("\"Insert Job Here\"");
add(["whatever"]);

case "whatever":
say("\"other added conversation\"");



//THese should be dependant on if npcs are met, still can't get it to
// work properly

case "Lord British"(remove):
say("\"Try dropping a sign on his head.\"");


case "bye":
say("\"Goodbye.\"");
break;


}

}


Ok when my conversation scripts are compiled, I cant seem to get the MET thing to work. It will say both the first greeting and the second greeting right after. NPCs I have created (well, modified with my own convo. scripts) aren't acting right. I gave them new portraits that have been indexed, one of them works fine, but the rest just show up a blank next to the text they say. It seems when I approach those npcs, it initiates conversation, yet I can't see their responses or face.

Could this be because I have a few npc scripts pasted right after each other in the same usecode.uc file? #include statements don't seem to work for me when I try to organize like Alun Bestor's usecode. UCC will crash when i try to compile. I just gave up tryign tomake it look neat and put them all on the same file

Reply To This Message
 
 Re: NPC Conversations
Author: Malignant Manor 
Date:   08-15-09 02:16

I believe there needs to be a newline between includes (or maybe just a newline at the end of the previous include). I've tested the following code I wrote. Here is a download with the very basic headers setup and this code. Feel free to add more from a mod or your own. Drop ucc in the usecode folder or use an environmental variable (assuming using Windows).



// Spark
void TestNPC object# (0x402) ()
{
	if (event == DOUBLECLICK)
	{
		if (!UI_get_item_flag(item, MET))
		{
			UI_set_item_flag(item, MET); // not sure what exactly triggers this and don't have time to check so set it manually
			SPARK.say("We haven't met yet");
		}
		else
			SPARK.say("Back already?");

		var options = ["name", "job", "bye"];

		if (UI_get_item_flag(LORD_BRITISH, MET)) // his met does trigger fine when talking to him
			add ("Lord British");

		converse(options)
		{
			case "name":
				say("\"Insert Name Here\"");

			case "job":
				say("\"Insert Job Here\"");
				add(["whatever"]);

			case "whatever":
				say("\"other added conversation\"");

			case "Lord British"(remove):
				say("\"Try dropping a sign on his head.\"");

			case "bye":
				say("\"Goodbye.\"");
			break;
		}
	}
}

Reply To This Message
 
 Re: NPC Conversations
Author: agentorangeguy (---.localdomain)
Date:   08-16-09 15:59

Thanks for that, I used that template and the conversations are working as they should... except for one problem. Faces are now not being shown next to the conversation. It is just blank now. Is there some other line I need to put in to show the faces, or is there something else I need to do?

I appreciate all the help, I am decent at scripting with Rise of Nations so scripting for Ultima is a little different to me but similar as well. I have a very basic knowledge of scripting, its been years since I had any programming classes (didn't do so well in them..haha)

Reply To This Message
 
 Re: NPC Conversations
Author: Malignant Manor 
Date:   08-16-09 21:37

converse won't change faces. It worked in the text I used since Spark talked through .say and his face was already showing.

You would should add something like this right before converse.

// negative npc number or face number then face frame
UI_show_npc_face0(SPARK, 0);

If you are using an npc whose number would give the wrong portrait (due to the portrait being used in the original game for something else), then you would need to specify the appropriate face number instead of npc number.

Reply To This Message
 Go to Top  |  Go to Topic  |  Threaded View   Newer Topic  |  Older Topic 


 
 Reply To This Message
 Your Name:
 Your E-mail:
 Subject:
 Subject:
   
 
SourceForge   phorum.org
 
Problems with Exult or this webpage? Contact us.
Last modified: 24 Oct 2001(GMT)