How to Make Your AI Unique

From The DarkMod Wiki
Jump to navigationJump to search

written by Springheel

Running into clones of the same AI over and over again can ruin the illusion of being in a realistic environment. Beyond that, it's just plain boring. Luckily, there are some fairly easy ways to make your AI look a little different from each other.

Skins

An easy--and quite effective--way to make your AI quite different from each other is to use an alternate skin. A skin is basically a different texture from the default. It could be as simple as changing the colour of an AI's tunic from blue to green, or a totally new texture that changes the clothing entirely (though obviously the basic shape of the model remains the same). See Creating Multiple Skins For A Model for more information on how this process works.


generic_guard01.jpg

It's very easy to swap skins in Dark Radiant.

1. First, type a dummy spawnarg into the AI entity window: "skin" "x" (it doesn't matter what the second variable is. "x" will do.

2. Then click on the "skin" line in the list of properties.

3. A "choose skin" button will appear. Click it.

4. A new window will open. Select "Matching Skins" and then choose the skin you want. You can preview it in the right hand window. If there is no "Matching Skins" option, then the AI does not have skins available (most AI do).

Attaching A Different Head

Another option is choosing a different head. There are well over fifty heads (as of the release of 1.0) to choose from. See Heads Available for AI for more details and for images of all available heads.

citywatch_heads.jpg

Def_Attaching Prop Items

Another way to add more variety to your AI is to attach different objects to them. With a little creativity, you can get some surprising variation by attaching different models.

One easy way to add some character to your AI is to attach some kind of headgear. There are hats, hoods, hair extensions, (like pony-tails), and oddities like eyepatches which can all give your AI a unique flavour.

hats.jpg

What an AI wears can also be modified by attaching armour pieces, (like pauldrons), belt buckles, brooches and other jewellery.

Finally, AI can be carrying numerous things on their belt to add a little character. Game objects like weapons, purses, keys, or potions are obvious choices, but other objects like a spoon, a coil of rope, or a workman's hammer can also be used.

In order to be attached to an AI, an object needs to have an entity definition that sets what 'joint' it should be attached to (head, spine, etc. see next section) and how it should be positioned and rotated relative to that joint. The object will move with the joint it is attached to, so if you attach something to the head joint, it will move whenever the AI moves its head.

Currently, all our 'attachable' entities (with the possible exception of weapons--check that) are found in tdm_prop_wearable_items.def and tdm_prop_items.def. You attach one of them by selecting the AI in the editor, and typing in the key/var "def_attach" "[prop entity name]". If you want to attach something that doesn't already have a 'prop' entity, then you'll need to make one. See Making 'Prop' Entities.

Note that an attached object will not show up in the editor. You have to run the game in order to see it.

Prop objects can be 'tweaked' for each AI (the values that position a key perfectly on the belt of one model may be too low for another) but most are currently only set for a single AI. See Adding Offset Values for Specific AI for more info. This will be improved as time goes on.

Joints Names

The name of joints for use with def_attach can vary with the AI. They are listed in the .md5mesh files for each AI. These are in the darkmod/models/md5/chars folder and can be viewed in a plain text editor.

There is a cvar to enter in the console that shows the skeleton of the AI with joints names in-game. This is the cvar to show joint names is r_showskel 1 to show and 0 to hide.

For most purposes, here is a list of commonly used humanoid joints names for use with def_attach:

origin

Head

Neck

Spine, Spine1, Spine2 (chest), Spine_Dummy, joint8 (Spine2) joint9 (Spine2), leftpad (Spine2), rightpad (Spine2)

LeftShoulder

RightShoulder

LeftArm, LeftArmRoll,LeftArm_Dummy, LeftForeArm

RightArm, RightForeArm

LeftHand, LeftHandIndex1, LeftHandIndex2, LeftHandIndex3, LeftHandRing1, LeftHandRing2, LeftHandRing3, LeftHandThumb1, LeftHandThumb2, LeftHandThumb3

RightHand, RightHandIndex1, RightHandIndex2, RightHandIndex3, RightHandMiddle1, RightHandMiddle2, RightHandMiddle3, RightHandThumb1, RightHandThumb2, RightHandThumb3

Hips, LeftHips_Dummy (belt), RightHips_Dummy (belt), sword (Hips)

LeftLeg, LeftUpLeg, LeftUpLegRoll, LeftLegRoll, joint3 (LeftUpLegRoll), joint4 (LeftUpLegRoll)

RightLeg, RightUpLeg, RightUpLegRoll, joint5(RightUpLegRoll), joint6(RightUpLegRoll)

LeftFoot, LeftToeBase

RightFoot, RightToeBase

Attaching 'Alternate Animation' Objects

Some attached objects change the way your character moves. For example, if you attach a torch to your AI's hand, then the AI will play the 'carrying torch' animations, which keep his hand stuck out in front of him. See Overriding animations via attached objects for more information on how this works.

There are lots of ways to use this to make AI more interesting. AI can carry lots of regular things in their hands and use the 'carry torch' animation--candles, cups, brooms, etc. You could also create unique animation replacements, like attaching a wine bottle to a guard, and replacing the regular attack animations with the 'blind' attack animations to make him swing wildly when attacking (as if drunk).

There's also a sneakier way to use this system, by creating invisible entities that change the animations an AI uses.

For example, you could attach an entity that has no visual model, but causes the AI to replace the normal walk animation with a 'limp' animation. Or you could attach an invisible entity that makes an AI shake his fist whenever he senses someone around (replacing 'alert' animation with 'shaking fist' animation), etc. Or more simply, you could just choose an alternate walk cycle so two similar AI don't walk identically.

This system has a lot of potential, though it can't really be used effectively until more code exists to call animations (currently, though AI have a lot of animations, only the basic animations are called by the code).

Making AI move faster or slower

You can tweak the speed of individual animations that are played by an AI; for example, to subtly increase or decrease a particular AI's walk speed, or their attack speed, or the speed at which they turn their head when looking around. See changing the animation playback speed for details.

Extra note: To make an AI run on patrol add the property/value : run 1 to a path_corner on the AI's patrol and the AI will run to it (then resume walking after it if the next path_corner does not have that property set.)


Changing Voices

There are various voices available for different AI types and you can set these on individual AI, see Voices

Conclusion

Combining these effects can make your AI look like totally different models, allowing all kinds of variety. Imagine a skin with a no-draw texture on an AI's leg, and then attaching a wooden torch as a peg-leg (with a 'limping' animation)? There are all kinds of creative possibilities if you want to experiment.