Candles that can be turned on/off with a frob

In this tutorial, I will explain how to create a candle archetype that, with minimal effort, can be used to create candles that the player can turn on or off by simply frobbing them.
Before you begin, your should download these candle models with vhot points - if you do not, you will need to manually offset the candle's particle effects so that they appear in the correct position, and remove the '-v' from the end of the model names specified below.

As this tutorial explains how to create a custom archetype for these candles, it assumes the use of a custom gamesys. If you do not want to use a custom gamesys, then just create an instance of the new archetype's parent object, and modify that instance each time the tutorial tells you to modify the new archetype.

Now, let's begin. First of all, create a new archetype under Candle (-181), and name it 'LitCandle'.

Open this new archetype's properties and change it's Shape->Model Name to Canstick-v. You''ll use the vhot on this slightly modified candle model to attach the candle flame to later.

Add Engine Features>Frobinfo and give it these settings:

World:   Script
Inventory:   None
Tool Cursor:   None

Once that's done, add S>Scripts and enter 'StdLever' into both the Script 0 and the Script 1 boxes, as that script needs to be on the object twice for this system to work.

In order for the StdLever script to work properly, you need to add the Tweq->Joints property. There's no need to change any of the settings in there, though; just press Ok.

Finally, add Tweq->JointsState and set the AnimC to Reverse. If you don't do this, then the player will need to frob the candle twice before it will switch off.

Now, you will need to create the candle's flame. Find the FireParticleFX (-3663) archetype, and create an archetype named 'CandleFlameYellow'.

Change this new object's Shape->Model Name to FX_Particle, and give it a Renderer->Transparency (Alpha) of 0.50.

Now, you need to set up this particle group to look like a candle flame. To do this, add SFX->Particles and set it up as follows:

Active   True
Particle Render Type   Single-coloured disc
Particle Animation   Launched continually
Particle Group Motion   Attached To Object
Number of particles   45
Size of particle   0.20
Bitmap name    
0 0 0
Gravity Vector  
0 0 3
Colour (Palettised)   125
2nd colour   188
3rd colour   47
Alpha   90
Fixed-group radius   0
Spin / pulse group   False
Spin speed  
0 0 0
Pulse magnitute   0.00
Pulse cycle time ms   0
Particle fade time   0.40
Launch period   0.03
Animation offset ms   0

Group scale velocity

Always simulate   False
Always simulate group   False
Sort particles (slow)   False (Unavailiable)
Particles start launched   True
Alpha subpixel particles   False
Skip subpixel particles   False

Ignore attachment refs

Force matching unrefs   False

Once that's done, you also need to set up the SFX->Particle Launch Info property, as follows:

Launch Type   Bounding Box
Box Min  
-0.04 -0.04 0
Box Max  
0.04 0.04 0
Min Radius   2.00
Max Radius   2.00
Loc unrotated?   False
Velocity min  
0 0 0
Velocity Max  
0 0 0
Vel unrotated?   False
Min Time   0.70
Max Time   0.75

Now the appearance of the candle flame is set up, but you still need the actual light.

First add S>Scripts and enter 'StdParticleGroup' into Script 0, and AnimLight intoScript 1.
Put a check into the Don't Inherit box.

Next, add the actual Renderer->Anim Light property, as set it up:
Mode   Smoothly brighten
Millisecs to brighten   1024
Millisecs to dim   256
Max brightness   125.00
Min brightness   0.00
Radius (0 for infinite)   11.00
Inner radius (0) for infinite   0.00
Quad lit   False
Offset from object  
0 0 0
Currently rising?   False
Current countdown   1024
Inactive   False

Don't forget to make use of the coloured lighting by adding Renderer->LightColour and setting it to Hue: 0.10, Saturation: 0.75.

Finally, add this link to the candle flame:
Flavour:   ParticleAttachment
From   CandleFlameYellow
To:   LitCandle
Type:   Vhot
vhot #:   1

The candle system is now fully set up, but the candles will not be extinguished when they are hit with a water or gas arrow, which is something of a must.
To make them react properly, you'll need two property sets; Joints2On and Joints2Off.

Give Joints2On the Tweq->JointsState property and set the AnimC to On, Reverse.
Give Joints2Off the Tweq->JointsState property and set the AnimC to On.

Now, go back to the LitCandle archetype and add these two Act/React Receptron:

Stimulus Min Max Effect Target Agent Addition Data
WaterStim 0 No Max Set Property [Me] Joints2Off Prop Name: StTweqJoints
FireStim 0 No Max Set Property [Me]


Prop Name: StTweqJoints

The WaterStim receptron will now douse the candle, and the FireStim receptron will relight it, even though that is a little bit unrealistic when it's a fire arrow that caused that FireStim!

And that concludes the tutorial.
To create one of these candles, just create a LitCandle, open up it's links, click 'Add', and select ControlDevice from the list. The link should already have copied the target object from the ~ParticleAttachment link; if it hasn't, enter the object number of the CandleFlameYellow that was created with the LitCandle.

One final note: You might also want to create an archetype under LitCandle named 'LitCandleGold', and give it a Shape->Model Name of Trcandle-v.