Torch Bearing Guards
From FleshWorks
by jay pettitt
Contents |
Inserting a Guard
It doesn't have to be a guard, you can attach a torch to pretty much any roughly humanoid member of the AI cast. In fact, you can attach most things to pretty much anything. But this tutorial is about attaching torches to guards.
Open the Actor Class Browser. Combat class human Thief3 AI pawns (guards) can be found by expanding the Actor, Pawn and AIPawn classes in the class tree until you find a suitable candidate. *CastleGuard_GNormal_04 will do nicely.
To insert our guard into the game world highlight him/her/it in the Actor Class Browser, right click a likely spot in one of the T3ed view ports and select Add *CastleGuard_GNormal_04 Here from the menu. Make sure the guard is positioned nicely and the right way up. It doesn't matter if the guard is floating slightly above floor level, he'll soon sort himself out when the map starts.
Inserting a Torch
Hand held torches are also found via the Actor Class Browser, under Actor > WorldObj > Light_ > FlameLight > TorchLight > *HandTorch. Again, right click on a view-port and select Add *HandTorch Here. Select the hand torch, and take a look at its associated Actor Properties dialogue box. Make a note of its name. Probably something like HandTorch__0. Note that there are two underscores between HandTorch and it's number.
Linking Guard and Torch
Now we need to associate our torch with the guard. Select the guard and open the Show Actor Links dialogue box. The guard is already linked to his eyeballs, teeth and some armor. We need to create a link to the torch. Click the Add Link button.
The Create Link dialog provides a list of link types. We want to scroll down the list and select RigidAttachment. The FROM: field should already be filled in with the identity of our guard. We need to type the name of our torch, possibly HandTorch__0 in the TO: field. Once done, click the OK button to confirm.
More Tea, Vicar?
Hooray. We now have a torch bearing guard. But a bit of play testing reveals that the torch is attached to the guard's middle regions. As the poor guard wanders about, flames appear to emerge from his bottom. That won't do. We need to attach the torch to the guards left hand.
Have another look at the guard's Show Actor Links dialog. Highlight the link to the torch (look in the Destination column for a match) and click on the Edit Selected Link button.
From the Edit Link Data dialog expand the last property's element from the data tree. You'll find a property called Attachment, expand that to provide two options for attaching to specific bones. Highlight one and click the ... button and select hp_LeftHand for both Attachment Bone and Parent Bone properties.
Nearly Done
Thats almost it. But to finish off we should customise our guard's animations so he holds his torch aloft and doesn't set fire to himself as he casually waves his arms around.
Make sure the guard is selected and open the Actor Properties dialogue box. Expand the last property branch from the tree. Highlight AIPawn, right click and choose Add Property. You'll be presented with two lists: the left hand Property Categories list should already have AI Pawn selected, for the right hand list select MovementModelClass. Click the Add Property button to confirm. Back in the Actor Properties dialog expand the AIPawn branch to see our new MovementModelClass property. Highlight it and use the ... button and select HoldingTorchMovementModel from the list.
Customising Scripts.
Lastly, we need to add some scripts to the guard and the torch to customise their behavior. Open the Trigger Script Manager dialog box. Scroll down the list until you find an entry named TorchGuard. Expand TorchGuard, you should find entries for a number of scripts.
The TorchGuard_AIDeadUnconsciousFleeing and TorchGuard_AIHitWithWaterStim scripts are needed by the Guard to instruct him to drop the torch and adopt the normal animation class if he dies or if the torch is extinguished.
Highlight TorchGuard_AIDeadUnconsciousFleeing in the Trigger Script Manager. Now select the guard in one of the T3Ed viewports. Right click on the guard and select Add script TorchGuard_AIDeadUnconsciousFleeing to selected actors. Go back to the Trigger Script Manager and select TorchGuard_AIHitWithWaterStim and add that to the guard too.
TorchGuard_TorchDropped and TorchGuard_TorchExtinguished are scripts needed by the torch, causing it to extinguish if dropped or if hit with a water arrow. These are applied to the torch in much the same way. But make sure you select the torch, not the guard ;)
Addendum: Right click your guard and open his Actor Links. Edit the HandTorch link. In the properties list, under "Link", set m_name to Torch. Without this, the scripts don't know what to act on.
Scripts can be removed from an actor by deleting its entry from the actor's Actor Properties dialog.
Congratulations. You're done.
Back to Mission Design: AI Tutorials Page
