SWAT TUTORIAL
Enriching the Storyworld
Letís add some Props to this storyworld. We already have two Props that we created earlier: the whiskey bottle and the chair. Let's have Tom and Fred use them as weapons.

Start by creating a new
Verb, "hit with." For its WordSockets, include 3Actor and 4Prop (in case you're wondering, the numbers in front of the WordSocket terms, in this case 3Actor and 4Prop, tell you in what positions they will show up in Storyteller when someone is playing your storyworld).  Now go back to the Verb "punch" and add "hit with" as an Option to the Role punchee. We'll need to specify the Acceptable and Desirable for the two WordSockets. For the DirObject WordSocket, we'll simply use the same Scripts that we used with the Option "punch:" 

DirObject
     Acceptable
          AreSameActor
              
ThisSubject
               CandidateActor

     Desirable
     0.0

But now we need to write the Acceptable and Desirable Scripts for the 4Prop WordSockets. On what basis should an Actor decide which Prop to use?

Let's assign one
Prop to each of the two Actors: Tom always uses the whiskey bottle and Fred always uses the chair. We do all of this within the Acceptable Script. We'll need to organize this information in a way the Engine will understand. 

First, we want to restrict our considerations to
Tom and Fred The beginning of our script structure (not the actual Script) will look something like this:

Acceptable
     OR (either of the next two situations is acceptable)
          We're considering
Tom and the whiskey bottle together
          We're considering
Fred and the chair together

Let's flesh out the first part, the one for
Tom. To logically put two requirements together, we combine them with AND, like so:

     AND (both conditions are met)
          AreSameActor
              
ReactingActor
               Tom
          AreSameProp
              
CandidateProp
               whiskey bottle

We'll do the same for Fred and the chair.  Combining these Scripts with the initial decision (which Actor is being considered), our finished Script looks like this:

Acceptable
     OR
          AND
               AreSameActor
                   
ReactingActor
                    Tom
               AreSameProp
                   
CandidateProp
                    whiskey bottle
          AND
               AreSameActor
                   
ReactingActor
                    Fred
               AreSameProp
                   
CandidateProp
                    chair

We don't need to worry about the Desirable Script, because the decision is made by the Acceptable Script.

Going back up a level, we need to define the
Inclination Script.  How does the ReactingActor choose between punch, run away, and hit with?  We used Anger as the Inclination for punch and the inverse of Anger as the Inclination for run away.  Now itís time for a new idea: letís say that ReactingActor never repeats himself. If, the last time around, he punched, then this time around, he should hit with. And if, last time around, he hit with, then this time he should punch.

This brings us to one of the really neat features of Storytronics:
Actors have memories. They remember what they did in the past and use that memory to shape their future actions. To pull off this trick, you use the HistoryBook (see HistoryBook Operators for full discussion of this feature).

We're going to use two new Operators:
PickUpperIf and IHaventDoneThisSince. The first is in the Arithmetic menu; the second is in the History menu. 

Make sure "
hit with" shows in the Option window, and click on Inclination. The prompt shows 0.0.  Click on the Arithmetic menu and choose PickUpperIf.  You'll see this:

PickUpperIf:
     Switcher?
    
ValueIfTrue?
     ValueIfFalse?

The idea behind PickUpperIf is that sometimes you want to choose between two different numbers depending upon the circumstances. The three arguments can be defined like this:

PickUpperIf:
     logical circumstances
    
upper number
     lower number

If the logical circumstances are TRUE, then it will pick the upper number for the value of Inclination. If the logical circumstances are FALSE, then it will pick the lower number.

The logical circumstance, in this case, is whether the
ReactingActor has done "this" (this Option, hitting with) in a certain amount of time.  Here's where we use IHaventDoneThisSince.

The Switcher? prompt should be highlighted (if it isn't, click on it), then click on the History menu.  Choose IHaventDoneThisSince.  You'll get a prompt, HowLongBack?  Choose NumberConstant and enter 2, for 2 moments.  Here's how our Script looks now:


PickUpperIf:
     IHaventDoneThisSince
         
2
     ValueIfTrue?
     ValueIfFalse?

Now for the numbers.  Let's make the upper number 0.99much bigger than the Inclination for either of the other two Options. And we'll make the lower number -0.99much lower than the Inclination for either of the other two Options. Use the BNumberConstant button to fill in these values. 

Inclination
     PickUpperIf:
          IHaventDoneThisSince
         
2
          0.99
          -0.99

So if the logical circumstances are TRUE, then ReactingActor will definitely choose the hit with Option, but if the logical circumstances are FALSE, then the ReactingActor will choose one of the other Options.  If ReactingActor had indeed used the Verb hit with on his last action, then that would have taken place 1 moment ago (each action takes one game "moment") and would have been caught by IHaventDoneThisSince.

Thereís one more step: we need to create a
Role and Options for the Verb "hit with." Hereís an easy way to do so:

We should still be editing the
Verb "punch." Look under the main menu option "Edit," and select "Copy Role." This copies the current (and only) Role "punchee" into the clipboard. Next, double-click on the verb "hit with" so that youíre set up to edit that Verb. Select "Paste Role" and voila! A copy of the Role punchee has been inserted into the Role list for the Verb "hit with." It has the same Options and Scripts that the original Role had, so it will work exactly like that Role works. Change the name of the Role to "hittee," and we're done.

Letís try out our handiwork. Fire up Storyteller Lizard and see what happens. Notice that
Fred always alternates between punch and hit with, while you (as Tom) get to do them in any order you wish. Thatís because Inclinations are not used to make decisions for human players. Only the other Scripts affect human players.



Previous tutorial:  Running a Storyworld                                                                                  Next tutorial:  Attributes


Home     SiteMap     Feedback     FAQ     Press Room     Privacy Policy     Login