View Single Post
Old 24-11-06, 16:52   #4
Titak's Avatar
Join Date: Jul 2003
Location: Drenthe, The Netherlands
Posts: 32,226

StateID and stateID changes
By SSJ6Wolf

A stateID is a number that the game engine uses to determine what a given object is doing. For example, for Lara this number decides what buttons the player can press, how Lara reacts to the environment, and how objects react to Lara. Each animation has its own stateID assigned to it, and each object has its own set of stateIDs.

StateID changes
These reactions are often stateID changes. A stateID change is when a new stateID is generated by the engine, either by a button press or an environmental change (or for baddies, the AI makes a decision). When these changes occur and to what animation they go, is determined by the stateID change editor. The editor is set up as a series of five numbers, each in a column:

StateID, low frame, high frame, next animation, next frame.

1. StateID is the new number that the engine has generated.
2 and 3. Low frame and High frame set the boundaries for when the change occurs. For example if low frame is 4 and high frame is 6, then the change will only occur between frames 4 and 6.
4. Next animation is the new animation the object will go to.
5. Next frame is the starting frame within the new animation.

When making custom animations, it is important to remember that you can only change between stateIDs if the change already occurs; you cannot make up your own. For example you cannot have the jump button do anything during Lara's monkeyswing because that stateID change was never put into the engine. It is very important that you investigate the existing animations and compare them to the new ones you are to make. What stateIDs are used? Which ones do they use to get to new animations?

Also, stateIDs have some hardcoded effects as well. For example, stateID 3 which is Lara's foward jump, lets the player use left and right to rotate her, and this will also apply to any custom animations with stateID 3.

Moving an object about
Now, about moving the object about. I'll use Lara for simplicity's sake.
There are three ways that Lara can move in the game:

1. Using the speed and acceleration fields at the bottom of the editor will move Lara forward or backward in a given animation. Positive numbers typically move her foward, but some stateIDs use negative numbers to move her foward...just test your animation in-game and you'll see if you got it right or not. This is used typically for running animations.

Speed = the initial speed of the animation. Without acceleration, it sets the constant speed. 47 is running pace and 87 is sprinting pace, to give you an idea of what number to use.

Acceleration = the value that is added to the current speed, each frame. For example if the speed is 1 and acceleration is 2, then each frame Lara will go from 1, to 3, to 5, etc. until the animation ends.

NOTE: Do NOT use acceleration for looping animations, because Lara will drop back to the initial speed each time the animation starts over, which looks and feels very bad to the player.

2. When an animation has Lara end at a different spot (like one square to the left), a set position command can be used to shift her over to that spot. This command can be set in the animcommands window. Set position commands occur AFTER the animation finishes. Set position uses coordinates (x, y, z) with 1000 being a tile. (so 250 is one click, etc.) Negative numbers may be used. The Y axis is upside-down here. Use negative numbers to move her up and vise-versa.

NOTE: The "move" function in the editor uses these same values except divided by 1000. So 1 is a tile, 0.25 is 1 click, etc. Knowing this will let you move Lara precisely.

3. When Lara jumps, a grab position command forms a parabolic path for her to fly through, also set in the animcommands window. The grab position command also occurs AFTER the animation finishes. Its coordinates are (y,z) and check with the original animations for the values, and experiment with them. For example animation 76 sets the command for Lara's standing forward jump. You need a stateID that is used for a jump (3, 25, 26, or 27). The y value should always be negative and the z value should always be positive no matter which stateID is being used, unless you truly want the opposite effect to occur.

NOTE: As far as I know, only the Lara object uses this command.

Command 3
Also, I should mention Command 3. If, after a certain animation, Lara has trouble doing a mid-air grab, or crawling, or drawing her guns, place command 3 in the animation and the problem should be fixed.

Play effect 12
If you play effect 12 during an animation, it serves the same purpose as command 3 except that Lara will be able to draw her guns during the animation, starting at the frame when the effect is played. This is used typically for pull-up animations.

NOTE: Effect 12 does not appear in the drop-down menu for effects. Instead of using the drop-down menu, just type in 12 instead.

Addition by Titak:
StateID 89
When you have created a custom animation for Lara (a new move or a cutscene animation) you can add StateID 89 to the animation to disable Lara control. Lara won't do anything during the animation, no matter what button you press, includign the look button.
This way you'll make sure that the animation won't get interrupted, even if you are already using a flyby sequence with look button disabled.
If it walks like a duck and if it quacks like a duck, it is a duck.

Last edited by Titak; 24-11-06 at 17:15.
Titak is offline