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 
 creating flags
Author: agentorangeguy (---.localdomain)
Date:   09-26-09 19:36

I have a few questions on creating flags. Basically what I want to do right now is have a flag set when a certain conversation topic is asked. When that flag is set, a new topic is set within the other NPC's conversation which sets another flag and sets a new conversation within the other NPC. Kind of like creating back and forth conversations.

With creating flags, how do you know which numbers to use?

Reply To This Message
 
 Re: creating flags
Author: Malignant Manor 
Date:   09-26-09 22:00

Quote:

how do you know which numbers to use?


You need to look at decompiled usecode to know what numbers have been used and also source code if a mod has also been added.


Global flags 900 and up should be fine for both games (and SI Fixes). If it's the Keyring Mod, start at 1700. You can use up to number 2047.

Reply To This Message
 
 Re: creating flags
Author: agentorangeguy (---.localdomain)
Date:   09-29-09 20:41

I'm having trouble getting flags to go off when supposed to. I am trying to set it up like this

(NPC 1)
flag1 goes off
NPC says this(bla bla bla)
sets flag 2 as true
return;

(NPC 2)
flag2 goes off
NPC says this(bla bla bla)
sets flag 3 as true
return;

(NPC 1)
flag3 goes off
NPC says this(bla bla bla 2nd time)
sets flag 4 as true
return;

(NPC 2)
flag4 goes off
NPC says this(bla bla bla)
(back and forth conversation complete)
return;

That was just a general idea of what I'm trying to do. my script compiles but when you initiate that convo. for NPC 1, it triggers only the 1st flagged conversation for NPC2. When you talk to NPC 1 again, it skips all other flags and goes to normal conversation.

what is the difference of setting it up like this:
if (gflags[FLAG_1])

or

if (!gflags[FLAG_1])

Does one way skip unless the flag is activated, or always runs once?

Reply To This Message
 
 Re: creating flags
Author: Malignant Manor 
Date:   09-30-09 00:19

It's hard to exactly what you are meaning without examples. You can likely figure out how to modify it to fit your conversation.


// NPC 1
{
	if (!gflags[FLAG_1]) // initial intro
	{
		gflags[FLAG_1] = true; // set now so it won't repeat
		// I'm pissed at npc 2
		return;
	}
	if (gflags[FLAG_2] && !gflags[FLAG_3])
	{
		gflags[FLAG_3]= true;
		// npc 2 said what?
		return;
	}
	if (gflags[FLAG_4]) // finished arguement
	{
		// normal conversation
	}
}


// NPC2
{
	if (gflags[FLAG_1] && !gflags[FLAG_2])
	{
		gflags[FLAG_2] = true;
		// npc 1 said what
		return;
	}
	if (gflags[FLAG_1] && !gflags[FLAG_4])
	{
		gflags[FLAG_4] = true;
		//  back and forth conversation
		return;
	}
	if (gflags[FLAG_4] || !gflags[FLAG_1]) // finished arguement or never started
	// normal conversation
}

Reply To This Message
 
 Re: creating flags
Author: agentorangeguy (---.localdomain)
Date:   10-03-09 16:54

Ok I'm still having a bit of trouble with the flags going off. At first they were just spouting off the initial argument conversation and not going any further. Then, it wasn't going on at all when I tweaked it. Here is an example I made, see if I did this right. it compiles and you can talk to them, but the argument won't trigger:


//testnpc1.uc
void Iolo object# (0x401) ()
{

//Back and forth convo should be triggered when asked about Dupre

if (event == DOUBLECLICK)
{
if (!gflags[FLAG1])
{
gflags[FLAG1] = true;
item.say("@Oh yeah? Tell him he's just a drunk@");
return;
}

if (gflags[FLAG2] && !gflags[FLAG3])
{
gflags[FLAG3] = true;
item.say("AARP? Tell Dupre he probably caught an STD from that tavern wench!@");
return;
}

if (gflags[FLAG4] && !gflags[FLAG5])
{
gflags[FLAG5] = true;
item.say("@It works perfectly fine! I do not need venom to cure that! Tell him that his alchohol breath is nauseating!@");
return;
}

if (gflags[FLAG6] && !gflags[FLAG7])
{
gflags[FLAG7] = true;
item.say("@Nursing home? I'm not that old! Wait, what were we talking about again?@");
}

if (gflags[GLENMOLE8] || gflags[GLENMOLE1])
{

}
else

if (!UI_get_item_flag(item, MET))
{
UI_set_item_flag(item, MET);
item.say("You see an old fart.");
}
else
item.say("@Hello.@");


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

converse(options)
{
case "name":
say("@Iolo.@");

case "job":
say("@Walmart greeter.@");

case "Dupre"(remove):
if (!gflags[FLAG1])
{
say("@Perhaps you should enroll him in Alcoholics Anonymous.@");
gflags[FLAG1] = true;

}
else
say("@Whatever.@");

case "bye":
say("@When are we going to stop at Denny's, Avatar?.@");
break;


}
}
}


//testnpc2.uc


void Dupre object# (0x404) ()
{

if (event == DOUBLECLICK)
{

if (gflags[FLAG1] && !gflags[FLAG2])
{

item.say("@Alcholics Anonymous? Tell Iolo to fill out his AARP membership!@");
gflags[FLAG2] = true;
return;
}

if (gflags[FLAG3] && !gflags[FLAG4])
{
gflags[FLAG4] = true;
item.say("@Hey, I was cured after taking a red potion. Perhaps he should take some silver serpent venom for a certain problem he has, if you know what I mean.@");
return;
}


if (gflags[FLAG5] && !gflags[FLAG6])
{
gflags[FLAG6] = true;
item.say("@Avatar, perhaps we should just stick him in a nursing home. Besides, he eats too much.@");
return;
}

if (gflags[FLAG7] && !gflags[FLAG8])
{
gflags[FLAG8] = true;
item.say("@I suppose I should respect my elders...@");
}
else

if (!UI_get_item_flag(item, MET))
{
UI_set_item_flag(item, MET);
item.say("You see a slightly drunken Dupre.");
}
else
item.say("@BUUUUUURP!.@");


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



converse(options)
{
case "name":
say("@I am Dupre@");

case "job":
say("@To drink as much alchohol as possible@");

case "bye":
say("@I'm going to throw up, Avatar!@.");
break;


}
}
}

Reply To This Message
 
 Re: creating flags
Author: Marzo Sette Torres Junior 
Date:   10-04-09 02:33

Quote:

return;

This makes usecode stop executing the current function and go back to the function that called the current one; for dialog, this will usually stop the usecode machine. Use it only when you want to stop running usecode.

------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
How To Ask Questions The Smart Way

Reply To This Message
 
 Re: creating flags
Author: Malignant Manor 
Date:   10-04-09 02:54

Please use the [ code] [ /code] tags (no space inside the []) around code so it is formatted properly. Phorum codes link if this doesn't show up right.

I left the returns since I didn't know if it was intentional or not. You had flag1 used twice and
item.say("@Oh yeah? Tell him he's just a drunk@");
doesn't seem to make any sense at that point. I just commented that part out.

You also didn't make any check to see if the other npc is around. I added one.


#game "blackgate"
// just remove and change where appropriate. Better to have this stuff in header files
const int FLAG1 = 1000; 
const int FLAG2 = 1001;
const int FLAG3 = 1002;
const int FLAG4 = 1003;
const int FLAG5 = 1004;
const int FLAG6 = 1005;
const int FLAG7 = 1006;
const int FLAG8 = 1007;
const int FLAG9 = 1008;
const int GLENMOLE1 = 1008;
const int GLENMOLE8 = 1010;
const int DOUBLECLICK = 1;
const int MET = 28;
const int DUPRE = -4;
const int IOLO = -1;

//testnpc1.uc
void Iolo object# (0x401) ()
{
	//Back and forth convo should be triggered when asked about Dupre

	if (event == DOUBLECLICK)
	{
/*		if (!gflags[FLAG1]) // this part doesn't make sense and you use this flag later for asking him about Dupre
		{
			gflags[FLAG1] = true;
			item.say("@Oh yeah? Tell him he's just a drunk@");
			return;
		}*/
		if (UI_npc_nearby(DUPRE))
		{
			if (gflags[FLAG2] && !gflags[FLAG3])
			{
				gflags[FLAG3] = true;
				item.say("AARP? Tell Dupre he probably caught an STD from that tavern wench!@");
				return;
			}
			if (gflags[FLAG4] && !gflags[FLAG5])
			{
				gflags[FLAG5] = true;
				item.say("@It works perfectly fine! I do not need venom to cure that! Tell him that his alchohol breath is nauseating!@");
				return;
			}
			if (gflags[FLAG6] && !gflags[FLAG7])
			{
				gflags[FLAG7] = true;
				item.say("@Nursing home? I'm not that old! Wait, what were we talking about again?@");
			}
		}
		if (gflags[GLENMOLE8] || gflags[GLENMOLE1])
		{

		}
		else if (!UI_get_item_flag(item, MET))
		{
			UI_set_item_flag(item, MET);
			item.say("You see an old fart.");
		}
		else
			item.say("@Hello.@");

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

		converse(options)
		{
			case "name":
				say("@Iolo.@");

			case "job":
				say("@Walmart greeter.@");

			case "Dupre"(remove):
				if (!gflags[FLAG1] && UI_npc_nearby(DUPRE))
				{
					say("@Perhaps you should enroll him in Alcoholics Anonymous.@");
					gflags[FLAG1] = true;
				}
				else
					say("@Whatever.@");
			case "bye":
				say("@When are we going to stop at Denny's, Avatar?.@");
				break;
		}
	}
}


//testnpc2.uc

void Dupre object# (0x404) ()
{
	if (event == DOUBLECLICK)
	{
		if (UI_npc_nearby(IOLO) && gflags[FLAG1] && !gflags[FLAG8])
		{
			if (gflags[FLAG1] && !gflags[FLAG2])
			{
				item.say("@Alcholics Anonymous? Tell Iolo to fill out his AARP membership!@");
				gflags[FLAG2] = true;
				return;
			}
			if (gflags[FLAG3] && !gflags[FLAG4])
			{
				gflags[FLAG4] = true;
				item.say("@Hey, I was cured after taking a red potion. Perhaps he should take some silver serpent venom for a certain problem he has, if you know what I mean.@");
				return;
			}
			if (gflags[FLAG5] && !gflags[FLAG6])
			{
				gflags[FLAG6] = true;
				item.say("@Avatar, perhaps we should just stick him in a nursing home. Besides, he eats too much.@");
				return;
			}
			if (gflags[FLAG7] && !gflags[FLAG8])
			{
				gflags[FLAG8] = true;
				item.say("@I suppose I should respect my elders...@");
			}
		}
		else if (!UI_get_item_flag(item, MET))
		{
			UI_set_item_flag(item, MET);
			item.say("You see a slightly drunken Dupre.");
		}
		else
			item.say("@BUUUUUURP!.@");

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

		converse(options)
		{
			case "name":
				say("@I am Dupre@");
			case "job":
				say("@To drink as much alchohol as possible@");
			case "bye":
				say("@I'm going to throw up, Avatar!@.");
				break;
		}
	}
}

Reply To This Message
 
 Re: creating flags
Author: Malignant Manor 
Date:   10-04-09 03:06

For a conversation with someone else in the same room, it seems far better to have this all one conversation instead of having to keep doubleclicking on each persons over and over again.


#game "blackgate"

const int FLAG1 = 1000;
const int GLENMOLE1 = 1008;
const int GLENMOLE8 = 1010;
const int DOUBLECLICK = 1;
const int MET = 28;
const int DUPRE = -4;
const int IOLO = -1;

//testnpc1.uc
void Iolo object# (0x401) ()
{
	//Back and forth convo should be triggered when asked about Dupre

	if (event == DOUBLECLICK)
	{
		if (gflags[GLENMOLE8] || gflags[GLENMOLE1])
		{

		}
		else if (!UI_get_item_flag(item, MET))
		{
			UI_set_item_flag(item, MET);
			item.say("You see an old fart.");
		}
		else
			item.say("@Hello.@");

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

		converse(options)
		{
			case "name":
				say("@Iolo.@");

			case "job":
				say("@Walmart greeter.@");

			case "Dupre"(remove):
				if (!gflags[FLAG1] && UI_npc_nearby(DUPRE))
				{
					gflags[FLAG1] = true;
					IOLO.say("@Perhaps you should enroll him in Alcoholics Anonymous.@");
					DUPRE.say("@Alcholics Anonymous? Tell Iolo to fill out his AARP membership!@");
					IOLO.say("AARP? Tell Dupre he probably caught an STD from that tavern wench!@");
					DUPRE.say("@Hey, I was cured after taking a red potion. Perhaps he should take some silver serpent venom for a certain problem he has, if you know what I mean.@");
					IOLO.say("@It works perfectly fine! I do not need venom to cure that! Tell him that his alchohol breath is nauseating!@");
					DUPRE.say("@Avatar, perhaps we should just stick him in a nursing home. Besides, he eats too much.@");
					IOLO.say("@Nursing home? I'm not that old! Wait, what were we talking about again?@");
					DUPRE.say("@I suppose I should respect my elders...@");
					DUPRE.hide();
				}
				else
					say("@Whatever.@");
			case "bye":
				say("@When are we going to stop at Denny's, Avatar?.@");
				break;
		}
	}
}


//testnpc2.uc

void Dupre object# (0x404) ()
{
	if (event == DOUBLECLICK)
	{
		if (!UI_get_item_flag(item, MET))
		{
			UI_set_item_flag(item, MET);
			item.say("You see a slightly drunken Dupre.");
		}
		else
			item.say("@BUUUUUURP!.@");

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

		converse(options)
		{
			case "name":
				say("@I am Dupre@");
			case "job":
				say("@To drink as much alchohol as possible@");
			case "bye":
				say("@I'm going to throw up, Avatar!@.");
				break;
		}
	}
}

Reply To This Message
 
 Re: creating flags
Author: agentorangeguy (---.localdomain)
Date:   10-05-09 22:31

The example I gave had some junk lines in it that I missed, which made the whole thing confusing. I guess what I am trying to do is this:

NPC1 has normal conversation until asked about a certain topic about NPC2, which sets Flag 1.

When Flag 1 is true, NPC responds to what was said. This should set flag 2.

When Flag2 is true, NPC 1's first response to NPC2 is triggered, which sets Flag 3 as true.

When Flag 3 is true, NPC 2's second response to NPC 1 is triggered, which sets Flag 4.

When Flag 4 is true, NPC 1's second response to NPC2 is triggered, which sets Flag 5.

We'll say that when Flag 5 is set as true, NPC 2 says one more thing in response and then the conversation is over. Once that flag is set, both NPC's go back to their normal conversation functions.

On a side note, !gflags means the line will run until that flag is set true, right?

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)