9

State Transition Dialog 1209
explanations. These are presented for you to
modify and use in your own scenes.
Note: See this topic in the online User Reference
forsamplecodetotestanobjectposition,testthe
distance between two objects, and test a modifier
parameter.
Testing a Particle System Parameter
This sample script tests the number of par ticles
emitted by particle system Spray01, and returns
positive if the number equals 100.
fn TestParticles delt=(
if (particleCount $Spray01) == 100
then 1 else 0 )
Testing an Atmo spheric Property
This sample script tests the Density p arameter of a
fog effect, and returns positive if it equals 50.
fn TestAtmos delt=(
atmos_fog = getAtmospheric 1
print atmos_fog.density -- to:debug
if (atmos_fog.density == 50)
then 1 else 0 )
Note the second line, which assigns the fog
atmospheric to a variable named "atmos_fog".
This is necessary only for atmospheric effects; with
most standard objects, you simply use the object
name preceded by a $, as in the two previous
examples. The "1" following the getAtmospheric
command refers to the atmospheric’s position in
theRenderingEffectsdialog>Effectslist.
Once you’ve executed this assi gnment, you can
obtainalistoftheatmosphericspropertiesby
entering this command in the MA XScript Listener:
ShowProperties atmos_fog
Also, the third line in the sample script isn’t
necessary for the cognitive controller; it simply
prints the result of the test in the Listener w indow
for debugging purposes.
Testing Another Delegate’s Behavior
You might want to determine in a transition script
which behavior is currently influencing a certain
delegate. Crowd provides a MAXScript-based
method for doing this. You can even check
whether a particular delegate is specified as a
target within that behavior. An example would be
a cocktail party scene in which Betty avoids Harry
if Harry is seeking Sally. But if Harry is avoiding
Sally, then Betty will seek Harry.
The following example script is taken from the
sample file party.max,whichyoucanfindinthe
Biped download available on t
his p age,under
3ds Max 8 Tutorials Scene and Support Files
> Specialized. T he scene uses a more complex
scenario than the example described in the
previous paragraph. Following is an overview, but
to fully understand the setup, you should examine
the scene. Study, in particular, the behavior
assignments and cognitive controllers, which use a
total of eight different transition scripts.
Six delegates are confined in a "room" defined by
four grids, using a Wall Repel behavior. Delegates
1, 2, 3, and 5 simply wander at random during the
simulation. However, delegate 4 uses a cognitive
controller (cc1) that tells it to start wandering,
and then switch to one of three Avoid behaviors
if members of one of three arbit rary pairs of
delegates come within 50 units of each other. Each
of the Avoid behaviors targets a different group
of three delegates, two of w hich include delegate
2. Delegate 6 is assigned a second cognitive
controller (cc2) that uses the following script to
tell it to switch to an Avoid behavior if delegate 4 is
avoiding delegate 2. The heart of the script is this
line in function transfunc4:
Note: See t he online User Reference for this sample
code.
Load the file, press
F11 to open the Listener
window, and then solve. The Listener window