We're almost done with writing the Scripts for this Option; we have just two more to tackle. These are grouped together under the heading "DirObject", and they're labeled Acceptable and Desirable.
We never tell the Engine "this is the Actor I want" or "this is the Prop I want," because sometimes we want to include more than one Actor, Prop, or Stage. If we used the format "This is the Actor I want," then we'd have problems specifying more than one Actor. Therefore, we use a different approach, where the Engine goes through all the Actors (or Props or Stages) and for each one asks "Should I use this one?" The author tells it which Actors (or Props or Stages) are acceptable, and how desirable each one is.
Back to the punchOption. Who should the puncheepunch? Why, the guy who punched him! That Actor is the Subject of ThisEvent (the one we're reacting to). So all we want is to declare that the Acceptable criterion for the DirObject of the punch Option is that the Actor must be the Subject of ThisEvent:
This is just like the AssumeRoleIf Script, with two differences. First, we don't use ReactingActor—that is reserved for the punchee in this case. Instead, we use CandidateActor, which always means "the Actor that the Engine is considering for this particular task." And instead of using ThisDirObject, we use ThisSubject. If we used ThisDirObject here, then the punchee would react to being punched by punching himself.
Obviously, there's only one Actor who will pass the Acceptable test, so the Desirable test doesn't matter anymore. If you look at the Desirable Script, you'll see that it's set to a value of 0.0, which is just fine. We'll explain how you use Desirable in another lesson.
Now we need to deal with some tasks still undone. We already added the Verb "run away from" to the Options of the Role "punchee." Now we need to fill some details for this Option. In the WordSocket Acceptable and Desirable Scripts; that should be easy. (Use the same Acceptable script we used for the Option "punch," and leave Desirable at default.) We also need to fill in the Inclination Script. This task challenges your skill at translating what you know about human nature into mathematical terms.
Computers can't understand human language or motives, so we have to translate human behavior into a language the computer does understand: numbers. We tell the Engine that the likelihood that any Actor might take an action will be based on how much (i.e., how big a number) the Actor has an inclination to do it, and this in turn is based on his or her personality, mood, or other attributes. In other words, we use a number scale for Actor personality traits and moods, etc. Later on, we will go into more depth about how all this works, but for now, you dont have much material to work with, so we're going to simply tell you what to put into the Inclination Scripts:
Inclination for "run away from":
BInverse of:
Fearful_Angry of:
ReactingActor
Fearful_Angry can be found under "Mood" in the Operators menu.
Recall that we use a numerical scale for traits, moods, and characteristics. The angrier the Actor is feeling, the higher a number his or her Fearful_Angry will be. But if an Actor runs away, it is because he or she is afraid—not angry. So we need to flip the Actor's Fearful_Angry mood "upside down." To do this, we use BInverse. The BInverse Operator can be found under "Arithmetic" in the Operators menu. It uses the inverse (opposite) of its argument. Since the higher the value of Fearful_Angry (found under "Mood" in the Operators menu), the more angry the ReactingActor is, the inverse will be how fearful the ReactingActor is, so it fits the Verb "run away from" perfectly.
This completes our preliminary survey of scripting in SWAT. There's much more to learn, of course. In the next lesson, we'll see how all this stuff translates into action. It's time to actually do some interactive storytelling.
Next Tutorial: Running a Storyworld
Previous Tutorial: Scripting Exercise: AssumeRoleIf
This tutorial by Storytron, Inc. is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Comments (2)
Bill Maya said
at 8:07 am on Aug 7, 2009
"We'll explain how you use Desirable in another lesson." - Is this ever done?
LauraJMixon said
at 9:33 am on Aug 7, 2009
Yes -- see Attributes, here: http://storytron.pbworks.com/Attributes.
You don't have permission to comment on this page.