Making Throwable Flares
Although in TDS Garrett's Mechanical Eye provided a sort of murky night vision in addition to its zoom capabilities, it didn't provide the bright, persistent illumination that you might need for performing a complicated task. This tutorial shows how to make a flare inventory item as was used in the previous Thief game.
The flare is based on the same principles as the GasBomb and FlashBomb. These inventory items consist of to components, plus their effects, and use no scripting (other than the same pickup sound script that all inventory items use). They work by means of Links. The basic components of a bomb inventory item are the pickup and the projectile. The pickup item has a link of flavour InventorySwitch to the archetype of the projectile. Thus, when you frob the pickup, the frobbable pickup item is replaced in your inventory with the throwable projectile. When used from your inventory, the projectile is thrown, and is destroyed on impact. But it has a link of flavour DeathSpawn pointing to the archetype of the effect or effects it produces on detonation. The FlashBomb in particular has a whole cascade of LightFX and Stims that it produces.
To make the basic flare we will just make a bomb that spawns a LightFX that lasts for 20 seconds. First we need to make three new Actor classes. From Actor\Worldobj\InventoryObject\Powerups\Bombs derive a new pickup class called Flare. Make it placeable, add all the usual inventory properties for InvName, HelpText, MaxInventoryStack. (If you don't know how to set the text values, see another tutorial for this). Add the Render\ObjectMesh property, and give it an approriate mesh. GENiGOODSscrollcase, with the KepGoodA skin looks good, as it provides a nice nondescript cylinder, or you could use the FlashBomb mesh. Ideally use Gestalt's flare mesh when it becomes available. See Flares thread at TTLG Forums
From Actor\Worldobj\Spawned\SpawnedWeaponObject\Projectile derive FlareProjectile. Give it the same mesh and inventory properties as the pickup, and add the following properties:
- Inventory\bIsInventory = true
- Inventory\bIsStackable = true
- Inventory\InvType = eIT_ITEM
- Inventory\InvSlot = 0
- Contact\ContactResponse = eCR_Destroy
- Throw\bCanThrow = True
- Throw\MinThrowRotation = (X=360.000000,Z=-180.000000)
- Throw\MaxThrowRotation = (X=720.000000,Z=180.000000)
The third class is the lighting effect. This is not derived from Actor\Light or Actor\Worldobj\Light__ as you might think. If you try to use Light you will crash the game, and if you use Light__ or its derivatives, you'll get a mesh with no light. We actually need to derive FlareLight from Actor\FX\LightFX. If you derive it directly from LightFX you will have to tweak the lighting properties yourself until you get something suitably flare-like. This is is probably the better option in terms of keeping your Actor class tree nice, but its not the easy option. The lazy man's choice is to derive from Actor\FX\LightFX\FlashbombLight1. That way we inherit the lighting properties which are pretty close to what we want. If you derived directly from LightFX, you'll also need to add the lifetime properies, Lifetime\bHasLifetime and Lifetime\Lifetime. Whichever method you choose, change the Lifetime\Lifetime property to something like 20.000000 seconds, and set Lifetime\bHasLifetime to True.
We now have the components of our flare. Next we need to link them together. In the Actor Class Browser, right click the Flare archetype. Select Show links from the popup menu. This should open the Object Links dialog box. Click the Add Link button. From the list of link flavours, select InventorySwitch. The FROM box should already say Flare. Switch back to the Actor Class Browser, and select FlareProjectile. Now go back to the Links dialog and click the Use Current Archetype button nect to the TO box. Click OK, then DONE.
Right click FlareProjectile in the Actor Class Browser, open the Links dialog for this class. Add a DeathSpawn link, using the FlareLight archetype as the destination.
You should now have a working flare. Place the Flare object in your level, and the Links will take care of the rest.
So we've got a basic flare. But its fairly limited. The light appears as if from nowhere, and stays on until it wears out. What if Garrett lights a flare while searching for a secret passage, and then he hears a guard coming. He's stuck in full light for 20 seconds. Disaster! If only he could snuff out the flare or shoot it with a water arrow.
To add these capabilities we need a another actor class and a script. The new class is called UsedFlareProjectile. This will just be a junk object, so we can derive it from Actor\Worldobj\SetDressing\MiscSettDressing. Add the properties to this object to make it frobbable.
- Frob\IsFrobable = True
- Frob\FrobBias = 16.000000
- Highlight\HighlightDist = 64
Also, give it the same ObjectMesh as Flare, and the same Lifetime properties as FlareLight. Next, we need to set up the Links. The DeathSpawn link of the Flare projectile should point to the UsedFlareProjectile archetype. Add a Vunerability link to the FlameLightSourceVunerability archetype. This is so we can recieve a water stim. Add a RigidAttachment link to the UsedFlareProjectile, pointing to the FlareLight archetype. Highlight the ~RigidAttachment link, and click the Edit Selected Link button. In the link properties, locate the Lifetime\bDeleteChildOnDeath property and set it to True. Do the same for the ~RigidAttachment destination link in the FlareLight's links. The result of all this tomfoolery is that the body of the flare remains once the light appears, and if the flare is destroyed, the light goes out.At the moment nothing can destroy the flare, so we need to create a script that will extinquish the flare if it is frobbed or hit by a water arrow. Make the following script:
- Logic OR operator
Add this script to the UsedFlareProjectile. Now shooting with a water arrow or frobbing will extinquish the flare.
NOTE: You will find that the lighting effect on this enhanced flare is not as good as the basic flare. This is because the light is attached to the flare instead of spawning in mid air, and the light is cast in a strange way that doesn't illuminate the floor very well. I'm currently trying to work out a better way to do this. Any suggestions? Flares thread at TTLG Forums