Jump to content

dialog/special encounter problem


Iluvhorses

Recommended Posts

Ok, this is my first time trying to create a BOA scenario. I don't have a story yet, but I'm just trying to get myself familiar with scripting and all that jazz until I do decide what I want to make a scenario about.

 

Ok, the current problem I'm having is with a special encounter. I have a town and I have a beggar in this town. Here's the code:

 

Code:
  beginstate11;     reset_dialog();     add_dialog_str(0, "You see a beggar holding out a tin cup to you.  _Could you please spare a few coins so I can eat?_" 0);     add_dialog_choice(0, "Yes I will. (Give him coins)");     add_dialog_choice(1, "Sorry, I don't have any myself.");     add_dialog_choice(2, "Back off old man and leave me alone!");     if (run_dialog(0) == TRUE) {         change_coins(-10);         message_dialog("He thanks you profusely and walks to the nearest bakery."," ");     }     else {                message_dialog("He sighs and sulks away."," ");                }                else {                          message_dialog("He spits in your face and walks away, muttering about how young people only think of themselves these days."," ");                           }break;
Ok, the problem I'm having is that when I play the scenario and I choose the third option, it gives the response "He sighs.." instead of "He spits...". I've tried figuring out what I should do differentely, and I've tried all of my resources (docs, westra's cookbook, Kelandon's page, plus looking at other scenarios). Any ideas??
Link to comment
Share on other sites

Have you tried looking at door.txt script that comes with every scenario? It has an example of how to do this sort of thing.

 

The problem you are having is that there is only supposed to be one ELSE statement at the end of an IF-ELSE statement. This is because the ELSE statement is the "in the advent of nothing matching the preceeding if statements, do this".

 

But... you can have something similar to this:

 

Code:
if (condition) {  action;}else if (condition) {  action;}else {  action;}
Link to comment
Share on other sites

What CPeters said, since he got in before me.

 

Note, however, that you should only call run_dialog once per encounter and save its value to a variable, so the player doesn't have to deal with the dialog box twice. That's the purpose of lines like "choice = run_dialog(0)" that you see in scripts.

 

So here's the fixed version of your script:

 

(Note that this requires that "choice" be defined as a variable in the variables list at the start of the script)

 

Code:
beginstate 11;reset_dialog();add_dialog_str(0, "You see a beggar holding out a tin cup to you. _Could you please spare a few coins so I can eat?_" 0);add_dialog_choice(0, "Yes I will. (Give him coins)");add_dialog_choice(1, "Sorry, I don't have any myself.");add_dialog_choice(2, "Back off old man and leave me alone!");choice = run_dialog(0);if (choice == 1) {change_coins(-10);message_dialog("He thanks you profusely and walks to the nearest bakery."," ");end();}if (choice == 2) {message_dialog("He sighs and sulks away."," ");end();}message_dialog("He spits in your face and walks away, muttering about how young people only think of themselves these days."," ");break;
By the way, you should also make sure that you find some way to handle the situation where the player offers to give money (selects the first option) but doesn't actually have any gold.
Link to comment
Share on other sites

Ok, that helped a little - 1 slight problem. I got it to give me the correct response when I choose option three, however the

choice = run_dialog(0); is not working. I keep getting an error message saying "Unknown command choice in line 39" (or whatever line it happens to be in). I tried declaring it in the variables sectiong, and where Thuryl put it in the code, but it still doesn't work. And without it the dialog box repeats when I choose the 2nd and 3rd options.

 

BTW, about what Thuryl suggested about having a way to handle it if the player offers the money but has none - would I use another if statement for that???

 

(bear with me, guys, I'm new to this, you'll probably hear more from me on this forum than the other one!)

Link to comment
Share on other sites

Code:
 

// TOWN SCRIPT
// Town 2: New Town

// This is the special encounter script for this town.

begintownscript;

variables;

choice = run_dialog(0);

body;

beginstate INIT_STATE;
// This state is called whenever this town is entered.
enable_add_char(0);
set_crime_tolerance(2);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
message_dialog("You walk out of New Town, curious as to what adventures you can find!"," ");
break;

begingstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate11;
reset_dialog();
add_dialog_str(0, "You see a beggar holding out a tin cup to you. _Could you please spare a few coins so I can eat?_" 0);
add_dialog_choice(0, "Yes I will. (Give him coins)");
add_dialog_choice(1, "Sorry, I don't have any myself.");
add_dialog_choice(2, "Back off old man and leave me alone!");
choice = run_dialog(0);
if (choice == 1) {
change_coins(-10);
message_dialog("He thanks you profusely and walks to the nearest bakery."," ");
}
else if (choice == 2) {
message_dialog("He sighs and sulks away."," ");
}
else {
message_dialog("He spits in your face and walks away, muttering about how young people only think of themselves these days."," ");
}
break;
Anything??
Link to comment
Share on other sites

Declaring the variable looks like this:

Code:
 int choice; 
Thus your script ought to look like this:

Code:
 // TOWN SCRIPT//        Town 2: New Town// This is the special encounter script for this town.begintownscript;variables;     int choice;body;beginstate INIT_STATE;// This state is called whenever this town is entered.     enable_add_char(0);     set_crime_tolerance(2);break;beginstate EXIT_STATE;// Always called when the town is left.      message_dialog("You walk out of New Town, curious as to what adventures you can find!"," ");break;begingstate START_STATE;// This state is called every turn the party is in this town.break;beginstate11;       reset_dialog();       add_dialog_str(0, "You see a beggar holding out a tin cup to you. _Could you please spare a few coins so I can eat?_" 0);       add_dialog_choice(0, "Yes I will. (Give him coins)");       add_dialog_choice(1, "Sorry, I don't have any myself.");       add_dialog_choice(2, "Back off old man and leave me alone!");choice = run_dialog(0);if (choice == 1) {    change_coins(-10);    message_dialog("He thanks you profusely and walks to the nearest bakery."," ");}else if (choice == 2) {           message_dialog("He sighs and sulks away."," ");}else {         message_dialog("He spits in your face and walks away, muttering about how young people only think of themselves these days."," ");}break; 
Link to comment
Share on other sites

Thank you, thank you, thank you, thank you, thank you, thank you!!! Ok, so anytime your going to use anything as a variable that's how you declare it? Ok, now I know. That was something else I was confused about. Like I said, bear with me - it's been a long time since I've done any sort of programming, and this is my first time with Avernumscript. Thanks again for the help guys!

Link to comment
Share on other sites

You still don't have a check for the party's actual coins. Here:

 

Code:
 // TOWN SCRIPT//	 Town 2: New Town// This is the special encounter script for this town.begintownscript;variables;     int choice;body;beginstate INIT_STATE;// This state is called whenever this town is entered.     enable_add_char(0);     set_crime_tolerance(2);break;beginstate EXIT_STATE;// Always called when the town is left.      message_dialog("You walk out of New Town, curious as to what adventures you can find!"," ");break;begingstate START_STATE;// This state is called every turn the party is in this town.break;beginstate11;	reset_dialog();	add_dialog_str(0, "You see a beggar holding out a tin cup to you. _Could you please spare a few coins so I can eat?_" 0);	add_dialog_choice(0, "Yes I will. (Give him coins)");	add_dialog_choice(1, "Sorry, I don't have any myself.");	add_dialog_choice(2, "Back off old man and leave me alone!");choice = run_dialog(0);if (choice == 1) {	if(coins_amount() >= 10){		change_coins(-10);		message_dialog("He thanks you profusely and walks to the nearest bakery."," ");	}	else{		message_dialog("When he sees that you yourself don't have enough coins to give him, he looks rather ashamed of himself.","");	}}else if (choice == 2) {	message_dialog("He sighs and sulks away."," ");	}	else {		message_dialog("He spits in your face and walks away, muttering about how young people only think of themselves these days."," ");	}break; 
This way, if the party doesn't actually have 10 coins, it doesn't say that the party gives the beggar 10 coins.

 

Alternatively, you could call the change_coins() call and then check to see if the party has 0 or fewer coins afterwards- if so, then you can have the party give the beggar as many coins as they are able.

Link to comment
Share on other sites

Here it is fixed, and it works:

 

Code:
  //	  Town 2: New Town// This is the special encounter script for this town.begintownscript;variables;	int choice;body;beginstate INIT_STATE;// This state called whenever this town is entered.		enable_add_chars(0);	// Names must appear first.	set_name(11,"Jean");		set_crime_tolerance(2);break;beginstate EXIT_STATE;// Always called when the town is left.	message_dialog("You walk out of New Town, curious as to what adentures you can find!"," ");break;beginstate START_STATE;// This state is called every turn the party is in this town.break;beginstate 11;	reset_dialog();	add_dialog_str(0, "You see a beggar holding out a tin cup to you.  _Could you please spare a few coins so I can eat?_" 0);	add_dialog_choice(0, "Yes I will. (Give him coins)");	add_dialog_choice(1, "Sorry, I don't have any myself.");	add_dialog_choice(2, "Back off old man and leave me alone!");	choice = run_dialog(0);	if (choice == 1) {		if (coins_amount() == 0) {			message_dialog("When he sees that you yourself don't have enough coins to give him, he looks rather ashamed of himself."," ");		}		else {				change_coins(-10);				message_dialog("He thanks you profusely and walks to the nearest bakery."," ");		}             }	else if (choice == 2) {			message_dialog("He sighs and sulks away."," ");			end();	}	else {			message_dialog("He spits in your face and walks away, muttering about how young people only think of themselves these days."," ");	}	break;
Thanks for the help guys! I've just finished creating dialog for two shops!! I think I'm getting a hang of this!! I doubt I'll have much time to work on it the next three weeks because of school, but I do have another question (surprise surprise). How do I make the outer walls of the city taller?? When my party is actually in the city, they look taller than the city walls! And, how can you put items inside things like crates, bookshelves, desks, etc....???
Link to comment
Share on other sites

If you mean the walls of the city that are still inside the town, you go to Town Details and set the height of the wall. If you mean outdoors, you have to use a custom graphic, and I don't think one like that exists yet.

 

Putting things inside containers is easy. Put them on top of the container. Make sure that they say Contained (down by Property/Not Property) — this is their default state. You won't see any difference in the editor, but they're contained.

Link to comment
Share on other sites

Code:
 choice = run_dialog(0); COINS = COINS_AMOUNT(); // define coins as integer	if (choice == 1) {		if (COINS < 10) { // Not 0, but 10	message_dialog("When he sees that you yourself don't have enough coins to give him, he looks rather ashamed of himself."," ");        message_dialog("Clearly this fellow is needy and humble, so you toss him your last coins."," ");	change_coins(-1*coins);	}		else {		change_coins(-10);	message_dialog("He thanks you profusely and walks to the nearest bakery."," ");		}        } 
Otherwise your 4 coins turns into a negative. I think you can use arithmetic in the change_coins command, but may be wrong. You can make a new variable if I am wrong.

*this message sponsored by the Shayder Chamber of Commerce*
Link to comment
Share on other sites

Kelandon - I got the wall thing figured out - I just used different walls smile And thanks for the tip on putting things inside of stuff. I thought that the contained/not contained meant that they were already contained somehow, like potions in a bottle.

 

Thanks for trying to help, Jumpin' Salmon - but right now I'm trying to avoid confusion at all costs, so I'm just taking baby steps until I get this all figured out - but it was a really good tip, I'll have to keep it in mind for the future!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...