SD Flags:

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: SD Flags:
Apprentice
Member # 12070
Profile Homepage #0
WARNING! Extremely long winded post below.

Years ago I purchased BoE and began creating my own massive Scenario. I was doing more then just fine with Maps, NPCs, Dialog, Story Line, etc...basically I covered the entire gambit from points "A" to "Z," that is, until I was finally confronted with the dreaded "stuff done flags."

I just didn't get them. I knew what I wanted to have happen, but didn't know how to make the program listen to me (so to speak).

For instance: a generic Mayor (or other NPC) from a generic Town requests that you and your companions venture forth towards a generic Cave in order to kill a specific Enemy (a basic quest). After killing said Enemy, you return to discover a bit of new dialog coming from the Mayor, and, he/she rewards your group with a bit of cash, and/or an interesting item, and/or some rep points, and/or some experience points, and/or some new information regarding where to go next.

Sounds simple enough, right? Well...I still don't get it, and that bytes because I would very much like to purchase BoA in order to recreate my previously failed BoE scenario. Like I said above...I know what I want to do, but not how to program it all in.

My question here is: is there a walkthough, or other such, available on "stuff done flags" which offers a "very detailed" step-by-step tutorial? One that even someone like me (dazed and confused as I am)could understand?

Thanks for listening.

--------------------
Hmmmmm...
Posts: 1 | Registered: Friday, November 23 2007 08:00
Agent
Member # 8030
Profile Homepage #1
Here.

--------------------
Jesus is a pacifist.
Posts: 1384 | Registered: Tuesday, February 6 2007 08:00
Off With Their Heads
Member # 4045
Profile Homepage #2
It's not complicated at all; it's just a matter of getting it. If you don't get it, it sounds horribly confusing and weird. Once you get it, you'll wonder how you could've ever not understood it in the first place.

The principle is the same in BoE and BoA, although the implementation is slightly different. BoA centers on two calls: set_flag() and get_flag(). set_flag() sets a flag to some value. get_flag() checks that value. BoE used If-Then nodes to accomplish the checking.

You can imagine flags as being a grid of numbers that is 200 rows by 30 columns. Each number starts at 0 and can be set to some other value by a set_flag() call. Then a get_flag() call checks that value and (generally) tells the script what do in response.

Let's take an example. Imagine you have a scenario in which a mayor gives a quest to kill a bandit leader. Once that quest is done, the mayor gives a reward of a magic sword and assigns another quest to kill two ogre mages. When that quest is done, the mayor gives a reward of a magic shield.

To simplify things, let's consider just a 5 row by 3 column set of flags, and let's assign values as follows:

(0,1) = 1 means the party has been rewarded with the magic sword
(0,2) = 1 means the mayor has given the magic shield
(1,0) = 1 means the bandit leader has been killed
(2,0) = x means x ogre mages have been killed

[My flag numbering convention is to use the first coordinate to indicate the town in which the stuff is happening, so this is assuming that town 0 is where the quests are assigned and towns 1 and 2 are where they are carried out.]

Here's how the flags start:

0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

Now the party kills the bandit leader. You use set_flag(1,0,1) to set the flag identified as (1,0) to the value 1 to mark that the bandit leader has been killed. Your flags now look like this (remember that the numbering starts with zero, so the upper-left flag is (0,0), and they count down and right in this example):

0 1 0
0 0 0
0 0 0
0 0 0
0 0 0

When the party returns to town and talks with the mayor, you use get_flag(1,0) to check that the right flag has been set. Since it has, they get the magic sword reward, but they need to get it only once, so you set (0,1) to 1. Now your flags look like this:

0 1 0
1 0 0
0 0 0
0 0 0
0 0 0

If they try to get the sword again, you use get_flag(0,1) to check if they've already gotten it, and you don't give it again.

Then they wander off and kill an ogre mage. You set flag (2,0) to 1 to mark that one mage has been killed.

0 1 1
1 0 0
0 0 0
0 0 0
0 0 0

If they try to return to town now, you use get_flag(2,0) to check if they've killed both. Since it's smaller than 2, you know that they haven't, and you don't give them their reward.

Next, they kill another ogre mage. Now you set flag (2,0) to 2 to mark that they're both dead.

0 1 2
1 0 0
0 0 0
0 0 0
0 0 0

They return to town and get their magic shield. Now you set (0,2) to 1 to mark that they've gotten their reward.

0 1 2
1 0 0
1 0 0
0 0 0
0 0 0

And of course you can use get_flag(0,2) to check if they've gotten the reward just yet.

Once you understand what flags are, I wrote an article that (among other things) explains how "if" conditions in BoA work: Basic Scripting for Complete Beginners. This is how you use flags.

It's more complicated to explain than it is to do. I advise taking a look at someone's else's code (many of the towns in Exodus involve fairly simple implementations of flags, for instance) and then trying it yourself.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Shock Trooper
Member # 7662
Profile #3
Also, if you want to record a number you could use a flag. If you leave a town the values of all variables are immediately forgotten. Whereas a number recorded as the value of SDF won't be.
Posts: 292 | Registered: Monday, November 13 2006 08:00
Lifecrafter
Member # 6193
Profile Homepage #4
Kel just gave you a fairly thorough explanation, but let me just add that the matrix/grid thing isn't really important to a basic understanding of flags. If it confuses you, just forget about it. What's important is that you have a list of flags for a town (and you definitely SHOULD keep a list of what each flag corresponds to) and you know that each flag is only set when the player has done the appropriate corresponding action (Like killing a bandit, or receiving a quest reward) and checked when you want to know if said action has been completed. So (0,2) would check if you've received the quest from the mayor, and nothing else. It'd be set in the dialog node where the quest is given, and checked, say, at the entrance of the dungeon or even in NPC's dialog nodes to allow you to ask other townsfolk about your quest. It would NOT be checked if you want to know how many bandits the player has killed, you'd use a whole new flag for that.

"Building The Basic Quest"-- an article by Jeff Vogel,-- might help as well.

--------------------
"NOW PASS ME MY BOOTS. I HAVE AN APPOINTMENT WITH A FACE." -Nikki

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00