The vRand System

This tutorial explains how to create a vRand system to randomly perform only one of up to five actions.

The vRand system relies primarily on the ability to attach particles to an object's vhot points, so before you start, you need to create up to five different custom object models. Each of these must have a vhot #1 in a different position. For example, increase the Z placement of the vhot by one unit per model. Although you can build your own models, this tutorial assumes that you use the vRand Model Pack (5k).

The first thing to do is to create a blue room around 10x10x10 in size.
Place an Object (the root of the Object Hierarchy) in the centre of this blue room and name it 'vRand'.
Give the object you've just created the Tweq->Models property and configure it as follows:

Halt:   Continue
AnimC:   Sim
MiscC:   Anchor, Random
CurveC:   JitterHi
Rate:   2500
Model 0:   vRand-1
Model 1:   vRand-2
Model 2:   vRand-3
Model 3:   vRand-4
Model 4:   vRand-5
Model 5:    

Set the Tweq->ModelsState's AnimS property to On and the Shape->Model Name property to vRand-1.

Next, create an EmitterTrap (-2555) and name it 'vRandEmitter'.
Give it the ReloadTweqEmit script (replace the TrapTweqEmit script and leave the Don't Inherit checkbox set to False), then add the SFX->Particles property and set it up as follows:

Active:   False
Particle Render Type::   Single-Coloured Disc
Particle Animation:   Launched Continually
Particle Group Motion:   Attached To Object

Leave the rest of the options at their default settings. DromEd should automatically give the object the SFX->Particle Launch Info property too, but you do not need to modify these settings.

Finally, give the vRandEmitter this link:

Flavour:   ParticleAttachment
From   vRandEmitter
To:   vRand
Type:   Vhot
vhot #:   1

If you haven't already guessed, the only reason we've given the vRandEmitter the SFX->Particles property is to allow it to be attached to the vRand's vhot with a ParticleAttachment link. As the vhot's position is randomly selected from one of five possibilities every 2500ms, we have in fact just created an EmitterTrap that is randomly placed every two and a half seconds.

The only thing that remains to be done to complete the vRand system is to make five objects to act as the vRand's output.
To do this, first create an object suitable for use as a stim receiver. For this example, we will use a gravestone.

Place your gravestone at the same location as the vRand, but with the following offset:

X: +3.00   Y: 0.00   Z: -1.50

Change the size of your gravestone to 1 square unit (1x1x1), and modify the Physics->Model-> Dimensions property accordingly.
Now, create four more of these squashed gravestones, placing each object 1 unit higher than the previous one. (Giving them these Z values:-0.50, 0.50, 1.50, and 2.50.)

Each of these 'output plates' should be given PokeStim receptrons for the effect(s) they should trigger when they are selected by the vRand.

Now that we have what should be a fully working vRand System, we still need to connect it to an effect. For this tutorial, we'll create the simple effect of randomly opening one of five doors when the player presses a button.

First of all, we need to create the five doors. Give each of the five 'output plates' a PokeStim receptron (Intensity 0 to No Max) to frob one of the doors, making sure to assign a different door to each 'output plate'.

Finally, create a button and link it with a ControlDevice link to the vRandEmitter.
Every time the button is pressed, one of the doors will randomly open. If the door is already open, it will close.

Because the vRand's modelcycling Rate is set for 2500ms, the button will only select a new door every two and a half seconds. You could easily decrease the Rate, but setting it to an unnecessarily low value could cause the game to slow down, so don't set the value lower than the minimum amount of time that can elapse between calls to the vRand. Bear in mind that the maximum amount of time between model cycles that DromEd will allow is around 32768ms.

A model-cycling object with the Random flag will never choose Model 5 (the sixth model), so until I find a solution to this problem, you can only give each vRand five outputs.