How to Make Your AI Unique: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Line 35: Line 35:
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) 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.
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) 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 props.def.  You attach one of them by selecting the AI in the editor, and typing in the key/var "def_attach" "[prop entity name]".
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]".


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

Revision as of 02:13, 19 June 2007

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.


proguardskin.jpg

At the moment, not very many of The Dark Mod's AI actually have alternate skins to choose from, but things will improve slowly.

To use a different skin, you need to add the key/var "skin" "[skin name]" to the AI in the entity window. You can browse for skins in D3ed, but existing skins will not show up in the "Matching Model" section, so you would have to scroll through the existing skins to find them (they should be under "characters") (look this up). I don't know how this works in Dark Radiant.

Attaching A Different Head

Another option is choosing a different head. Most human AI have at least six alternate heads to choose from. See Swapping Heads on AI Models for instructions about how to do this.

heads5.jpg

Not every head looks good on every body. Some heads are too large or too small, or have necks that don't match up very well. Even on good heads, the necks can clip into the body in a somewhat displeasing way sometimes. Unfortunately we can't do much about that. Luckily it's usually only a problem when the AI looks up or turns in an odd way.

Be aware that not all heads have the same animations. The default D3 heads don't have lipsynching and don't close their eyes when they're KO'd, for example. So if you're choosing a head for an AI that has is an important NPC or has a scripted conversation, you may want to avoid those heads. Also, some heads come with headgear permanently attached--you wouldn't want a townsfolk walking around with a city watch helmet on.

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) 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]".

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. This will be addressed as time goes on.

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 aniamtion 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.

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).