Game Development Reference
In-Depth Information
ireAll(node,node…) The fireAll() command does exactly the same thing as the
fire() command, but it accepts more than one parameter. When executed, it fires all
the named nodes simultaneously.
ireSequence(node,node…) The fireSequence(), command is rather specialized: It acti-
vates the nodes listed in its parameters one at a time in order, changing to the next
node each time the command is executed. The first time the script executes fireSe-
quence() , it will activate the first node in the parameter list. The second time the
script executes fireSequence(), , it will activate the second node in the list, and so on.
It automatically keeps track of which one is next. If the command is executed more
times than it has parameters, it will simply start again from the first parameter. For
example, the command fireSequence(Produce, Produce, Upgrade, Produce, Consume)
will cycle through activating the source twice, the converter, the source again, and
then the drain in Figure 8.1.
ireRandom(node,node…) This command takes as parameters the names of multiple
nodes, but it selects one of them at random and fires it. To increase the probability
of it firing a given node, you can enter that node's name more than once. For exam-
ple, in Figure 8.1, the command fireRandom(Produce, Produce, Consume, Upgrade) has
a 50% chance of activating the source, a 25% chance of firing the drain, and a 25%
chance of firing the converter.
iF sTaTemenTs
The script of an artificial player also lets you specify conditional commands using if
statements. if statements consist of the word if, a condition specified in parenthe-
ses, and a command to execute if the condition is true.
if(condition)command The condition in an if statement can refer to pools and reg-
isters to check the state of the diagram. For example, the script line if(Resources>3)
fire(Consume) activates the drain in Figure 8.1 when there are more than three
resources in the pool labeled Resources .
There is no need for an else statement in the scripts for artificial players because the
script executes until it finds either an if statement that is true or one of the direct
commands. For example, the following script will fill the pool marked Resources in
Figure 8.1 with a few resources before randomly choosing between a Consume or
Upgrade action:
if(Resources>4) ireRandom(Consume, Upgrade)
fire(Produce)
 
Search WWH ::




Custom Search