Animations
"Animations" are very similar in nature to "Functions", and may perform any operation that can be performed by a standard Function.
The only significant differences are that each Animation contains its own special timer for use in Frame delays, and that each Animation has an associated Sprite Frame ID whose corresponding Sprite is displayed for as long as that Animation remains active.
Both can be controlled by Animation Script Commands.
A Sprite Frame that should display for more than one Game Frame does not need to be set repeatedly, but if a Sprite Frame set at the end of an Animation is meant to remain visible, the Animation must not be allowed to end (it should break and loop),
Multiple Animations and the "Primary Animation"
More than one Animation may be active for any Status Script Object, Player, or Game Object at one time, causing them to display more than one Sprite.
These Sprites will be drawn to the screen in the order in which the Animations were started, placing the first one at the back, and the last one at the front.
The first Animation that is run is considered to be the "Primary Animation", and the Sprite that it is referencing at any given time is considered to be the "Primary Sprite".
During Collision tests against "Attack" and "Hurt" boxes, the Sprites referenced by every active Animation are tested.
When testing "MainBounds" Boxes or Hotspots, only the settings for the "Primary Sprite" are used.
Animations and Status Script Objects
Status Script Objects are the only visible game entities that do not absolutely require an Animation to be active for a Sprite to be displayed.
The only external way to apply an Animation to a Status Script Object is through the "Animation" setting for the Object's entry in the Status Script, but that Animation may still use standard Function Control Script Commands to start/stop others within the same Object.
Animations and Players
The Player that is running the Animation is considered to be the "Current Player" for the duration of that Animation.
The Ani_Set_Delay_Relative_Player_??? and Ani_Set_Delay_Chr Script Commands can be used to delay Animation based on a value stored in a Player Variable for the Current Player.
Any Function or Animation may manage any Player's Animations by using the following Script Commands:
- Func_Set_Chr_Animation - Starts the given Animation as the Player's "Primary Animation", and stops any other Animation it's currently running.
- Func_Add_Chr_Animation - Causes the Player to run the given Animation in addition to its currently-active Animations.
- Func_Stop_Chr_Animation - Stops the given Animation if the Player is currently running it. All others remain active.
The listed Commands take ID numbers based on the Character Common Functions listing as Parameters.
The Parameters for their "_From_List" counterparts reference entries in the Current Player Character's Animation Function ID Listing, defined in his Character Def File.
At any time, Players may switch Animations mid-processing by using the Func_Change_Player_Animations Script Command.
This Command not only changes the ID number stored in one or more entries in the Player's Animation Function ID Listing, but also updates any Animation that is already active to reflect those changes.
If the "Smooth Switch" setting is used, this will cause the new Animation to start at the same position that the original Animation had left off (if the old Animation was about to process its fifth Command, the new Animation will begin with its fifth Command, and its delay timer will not be reset).
This means that, for best results, both the old and new Animations should "look the same" (the only real difference between the two should be the Frame numbers that are used).
This is best used for "similar-yet-different" Animations, such as the Player performing a certain action at various degrees of rotation.
If, however, the "Smooth Switch" setting is not used, the new Animation will start at its beginning.
Animations and Game Objects
The Object that is running the Animation is considered to be the "Current Object" for the duration of that Animation.
The Ani_Set_Delay_Relative_Object_Var and Ani_Set_Delay_Obj Script Commands can be used to delay Animation based on a value stored in an Object Variable for the Current Object.
Any Function or Animation may manage any Object's Animations by using the following Script Commands:
- Func_Set_Obj_Animation - Starts the given Animation as the Object's "Primary Animation", and stops any other Animation it's currently running.
- Func_Add_Obj_Animation - Causes the Object to run the given Animation in addition to its currently-active Animations.
- Func_Stop_Obj_Animation - Stops the given Animation if the Object is currently running it. All others remain active.
The listed Commands take ID numbers based on the Game/Zone/Act Object Def listings for Scripted Object Animation as Parameters.
The Parameters for their "_From_List" counterparts reference an entry in the Animation Function ID Listing for the Object's Type entry in the Object Def.
For Objects, there also exist "_With_Offset" versions of both "Set" and "Add" Commands which cause the Sprites referenced by the Animation to be drawn at an offset from the Object's Position.
The X and Y offsets are taken from Object Variables whose IDs are given as Parameters to the Command, so they can be freely manipulated at any time.
This is beneficial for Animations that must move in relation to the Object's Position to avoid using too many Sprite Frames, or to visually simulate multiple Objects when only one is functionally necessary.
When an Animation should be displayed at a fixed offset from the Object Position, however, "_With_Offset" should be avoided, and the effect should instead by accomplished by using the Draw Offset Properties for those Sprite Frames.