There is a group of functions that allows you to play specific animations that are defined in a model (.nif file). You can find out about the animation group names by loading a model into the preview window and then skipping through the different animation groups or by looking at "base animation" windows in the "Character" menu. An excellent summary of Actor animation groups can be found here:
http://www.preik.net/morrowind/animationgroups.html
but only the ones listed in the base animation window can be called by this function. Additional animations can be loaded to a model via the animation button in the object window. See the Dancing girls in "Suran, Desele's house of earthly delights" for an example.
Not all models have animation groups, but the different banners (under activators) are good examples to see what is meant (see example below). Examples for GroupName are: idle, idle2, idle3, walk, etc.
These functions do not work on the player character.
PlayGroup, GroupName, [Flags]
PlayGroup, walk, 1
Plays the animation group defined by GroupName. Optional flags can be used to start the group in different ways (see below).
LoopGroup, GroupName, Number_enum, [Flags]
Plays the animation group defined by GroupName. The animation will be looped the number of times specified, and then return to the Idle animation. Optional flags can be used to start the group in different ways (see below).
Flags:
0 = Normal
The current animation will finish its full cycle, and the new animation will start from its beginning.
1 = Immediate Start
The current animation will stop regardless of the frame it is on, and the new animation will start from its beginning.
2 = Immediate Loop
The current animation will stop regardless of the frame it is on, and the new animation will start at the beginning of its loop cycle.
Note: With Bloodmoon installed (not necessarily Bloodmoon.esm selected) some of NPC animations are crosswired. When called from console, they may look correct, but if you insert NPC->PlayGroup, group, 1 into the script, you may be unpleasantly surprised to see a different animation than you expected (Forum info / Kir). You may have to experiment to find the correct animation (Check out the info in the section on AIWander for a list of NPC idle movements, or download the NPC Animation Explorer mod to see all possible animations ingame: http://www.angelfire.com/rpg2/mad_weather/animexp.htm).
Note: NPCs may play a different animation on the upper body while the lower body does the scripted animation. This may also be version-dependent(?), but in any case these functions appear to be unreliable when used with NPCs.
Example Script:
This original script is attached to all the outside banners and makes them move differently depending on the weather:
begin OutsideBanner
;this script is for a banner object outside that
;animates in the wind.
;Idle is still, Idle2 is a little breeze, and Idle3 is a large breeze
short ran
if ( MenuMode == 0 )
set ran to random 100
if ( ran < 30 ) ;30% chance the flag does something new
if (GetCurrentWeather >= 5 ) ;thunder, ash, or blight
LoopGroup, Idle3, 5
endif
;the last anim called in this script is the one it will play
if ( ran <= 10 )
PlayGroup, Idle
elseif ( GetCurrentWeather < 5 )
PlayGroup, Idle2
endif
endif
endif
end OutsideBanner
SkipAnim
Causes the current animation to not be played for this frame.