Jump to content

"Stuff Done" help


rihwin

Recommended Posts

Hello,

 

I've been working on my first scenario, trying to get a grasp for all the core concepts. I have set up a small town and I am looking to add a simple side quest to it.

 

What I'm looking for help with is how to use the "stuff done" flags. I'd like to know how I can change the setting of a "stuff done" flag upon the party stepping onto a specific spot in the town.

 

Thank you for your time in helping a new scenario designer out.

 

*Edit: Sorry I meant to post this in the editor section, my mistake

Link to post
Share on other sites

I'm not sure how much you've looked at scripting so far, but the call you want is set_sdf(), which takes three parameters: the two coordinates of the flag and the value you want to set.

 

If you haven't already, you will need to create a town script for the town; see section 2.10 in the editor documentation for more details, and set it as the town's assigned script in the town details dialogue in the editor. You'll then need to create a new state in the town script and write in it the appropriate call to set_sdf(). Finally, you'll need to place a special encounter rectangle in the editor and set its called state to be the new state you wrote in the town script.

 

EDIT: Shazam! Topic moved.

Link to post
Share on other sites

Yeah, set_sdf is the call you want. set_flag does the same thing. Which you use is just a matter of taste.

Also, you can use the call inc_flag(x,y,z) to change the value, but this time you will be adding to the value the flag has already. x and y are the coordinates of the flag, and z is the amount you want to change the value by, which can also be negative. Note however that SDFs cannot have a negative value.

Link to post
Share on other sites

So I like to see examples when I learn programming.

 

Code:
begintownscript;variables;int i,j,k,r1,choice;body;beginstate INIT_STATE;// Called when the town is loadedbreak;beginstate EXIT_STATE;// Always called when the town is left.break;beginstate START_STATE;// Called about once per turn. Please for God's sake don't ask what a "turn" isbreak;beginstate 10;	if (get_flag(0,1) == 0) {		message_dialog("a","b");		set_flag(0,1,250)		}	else {		inc_flag(0,1,-1);		}break;beginstate 11;	if (get_flag(0,2) == 250)		end();	message_dialog("If you don't change flag(0,2) in any other place","This message should be displayed once and only once.");	set_flag(0,2,250);break;

 

1) It isn't recommended to use states of less than ten. So you notice I wrote "beginstate 10". Certain states are reserved; for example, I think state 3 is also the START_STATE. (Now I wonder what happens when you include both? But don't do that!)

 

2) To call this script, you should open your scenario with the scenario editor. Then enter town mode. Then go to "Town Details" and in the upper right, set the town's script to the name of the script. Let's say you cut and paste the code below into a text file and name it "t0starter". Then in the editor, if you want a town to be able to run this script, you should list it's script file as "t0starter". (Does anyone know what happens when two towns load the same town script?)

 

3) To call state 10: be sure you're in town mode in the scenario editor. In the lower right there is a big clump of buttons. The one that looks like a big dot is the "Create Special Encounter" button; it lets you indicate the northwest and southeast corners of a rectangle. Then you are prompted to set the state to be called; if you wanted to call state 10 in the town's script, you should enter "10". That state will be called most times that the party enters the rectangle.

 

4) SDFs! Stuff Done Flags. A state is called almost every time that the party enters a special node's rectangle. SDFs allow the designer to record what nodes the party has activated, and thereby, what the party has done. SDFs are accessed by the call get_flag(x,y); this returns the value of the flag (x,y). You can envision SDFs as a Cartesian point system, where each point has a value.

Code:
  ...6.  .....  ..4..  .....x 1.... y

 

In computer science, you usually begin counting with 0, not 1.

get_flag(0,0) is 1

get_flag(2,2) is 4

get_flag(3,4) is 6

And presumably all other flags are currently set to 0.

 

inc_flag(x,y,value) does not return a value; it changes the value of flag(x,y) by value. So inc_flag(0,0,3) would make flag(0,0) equal to 4, inc_flag(2,2,-1) would make flag(2,2) equal to 3, and inc_flag(get_flag(0,0),get_flag(0,0),3) would make flag(1,1) equal to 3.

 

set_flag(x,y,value) does not return a value; it sets the value of flag(x,y) to value, regardless of what the flag's value was before.

 

So using states 10 and 11 above:

In state 10, flag(0,1) is assumed to be 0. So the statement is true. Then BoA calls the if section's {} enclosed code. The player will see an "a" and a "b". The next time the party steps on state 10's rectangle, the if(statement) will be false, because flag(0,1) will now be 250. Because the if statement was followed by an else statement, BoA links the two together. When an if(statement) is failed, but is linked to an else {} statement, the else's {} enclosed code is called. So now flag(0,1) will be decremented to 249. The next time the party steps on the rectangle, the flag will be decremented to 248... After 250 visits, flag(0,1) would be 0 once again and on visit 251, the party would see "a" and "b" again.

 

In state 11, flag(0,2) is initially 0. So the if (statement) fails, and the immediately following line of code, "end()", is not called. But the rest of the state's code is called. The player sees a message, and then flag(0,2) is set to 250. The next time the party steps on state 11's rectangle, flag(0,2) is 250. The if(statement) is true, so following line is called. end() is called, and end() stops the state being run. So end() prevents the later lines from being run. The party will see the message_dialog("","") of state 11 once and only once.

Link to post
Share on other sites
Originally Posted By: Metatron
2) To call this script, you should open your scenario with the scenario editor. Then enter town mode. Then go to "Town Details" and in the upper right, set the town's script to the name of the script. Let's say you cut and paste the code below into a text file and name it "t0starter". Then in the editor, if you want a town to be able to run this script, you should list it's script file as "t0starter".
Not quite; for this to work, the name of the file needs to be "t0starter.txt", not just "t0starter". If you're saving it with Notepad, the ".txt" may be added automatically, but if you're using TextEdit you need to do some minor fiddling.

Originally Posted By: Metatron
(Does anyone know what happens when two towns load the same town script?)
Presumably it works without comment.
Link to post
Share on other sites
Originally Posted By: Celtic Minstrel
Originally Posted By: Metatron

(Does anyone know what happens when two towns load the same town script?)

Presumably it works without comment

It should work, on entering a town I think that the game will just load the script from the indicated file in total ignorance of whether it has been loaded before. Also, it only ever has one town in memory at a time, so there's no possible way to have a conflict.

Nice example, by the way, Metatron.
Link to post
Share on other sites

Thanks, this has been very helpful. I'm trying to experiment with the example script provided. I set a special encounter rectangle for state 10 and another for state 11. When I try to test this with a party, walking onto the rectangle for state 10 brings up the message box with a and b written in it, but then it says in red text there is a error with the townscript file, Missing semicolon in line 25.

 

I've been looking over it and I don't see where the semicolon should go. The script file for this town is currently an exact copy/paste of the example provided in this post from Metatron.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...