0x0008

From SimsWiki
Revision as of 15:36, 24 April 2011 by MogHughson (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Random Number
OpCode:0x0008
Game Version:The Sims 2


Overview

This primitive allows you to generate a random number inside the simulation from SimAntics, i.e. flip a coin to make random desicions in your BHAV code based upon its result.

Using the Instruction Wizard

Random Number Instruction Wizard

The top half of the wizard covers where you are going to assign the generated random number. This should be familiar to you if you have used Expression [prim 0x0002] when you set the assignment operator (:=). The choices are any of the many variables and attributes that are part of SimAntics.

The bottom half of the wizard allows you to provide a variable or attribute containing the number to randomise up to, which can also be a literal as in the example above. Note that the number you pick here is exclusive, that is, the top boundary will not be picked as a random number. For a coin toss, i.e. randomise between two numbers, you need to choose Literal 2 as the upper bound. If all you need is a coin toss, there is an alternative Global [BHAV 0x01D2] "Coin Flip" that will randomly return True or False using exactly this instruction.

Your next instruction linked to the True target is likely going to make a descision about what route to take through your BHAV based on what is now contained in your assigned variable.


See also

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox