Sunday, June 13, 2010

Ambient Behaviour: Animation

In my second post on ambient behaviour, I'm going to talk about ambient animations.  Much like ambient movement, it mostly revolves around setting a few variables on the NPC. Again, much of this is available on the wiki.

Once again, you'll need to set AMBIENT_SYSTEM_STATE to 1 to enable animations.  Once that's set, you then need to set AMBIENT_ANIM_PATTERN to a value found in the ambient_ai.xls file. You can find this file in the Dragon Age\tools\Source\2DA directory. (Note that I'm referring to the Dragon Age directory in which the game is installed, not the one in My Documents where your saves are kept) This spreadsheet contains a list of animations which your NPC can perform as an ambient animation.  Most of the names are fairly self explanatory.     You'll should note within the spreadsheet that some of the animations have comments, and others have a green background. (I'll explain the meaning of the background later)

Note that for each animation entry, there are a number of individual animations that will be performed by the NPC.  For example, look at merchant_wander below, which has a total of ten different animations.

Now the great thing about ambient behaviour is that it is possible to combine both movement and animation!  So what will happen is that the NPC will move to a location (either waypoint or random) and then perform animation(s) at that location. All you have to do is set the relevant variables and the NPC will happily walk and animate.  Keep these few points in mind:
  • Upon moving to any waypoint, as stated above, the creature will stop and face the direction that waypoint is facing. Thus any animation the NPC performs will be done while they are facing that way.
  • If you are using random movement without waypoints, you have no control over the potential direction the NPC will be facing when they deliver their animation.
  • The animation length (including pauses) for some of the animations are very long.  This may result in it looking like your NPCs are not moving at all.

Now, when a creature stops for its animation phase, by default it will perform each of the animations in the list for the selected animation number in order. For those animations with a green background, you cannot/should not change this. However, for other animations, it is possible to select a random number of animations to play for each animation phase between movement. In order to change this, you set the AMBIENT_ANIM_FREQ variable on the NPC.

To quote from the wiki "The part left of the decimal specifies the minimum and the part right of the decimal specifies the maximum number of random animations to play during an animation phase."  So a value of 1.2 would play 1 or 2 animations from that animation's list, whereas a value of 1.4 would play between 1 and 4.  I have not tested whether it is possible to have a maximum above the available number of animations for the selected animation entry. If anyone has tested this and was able to identify the behaviour, then please let me know!

So there is ambient behaviour in a nutshell. By simply setting a few variables on NPCs, you can have the NPCs moving and interacting with others within your mod, creating a background of life and movement.

No comments:

Post a Comment