Action

From EDukeWiki
Revision as of 05:45, 9 January 2021 by Doom64hunter (talk | contribs) (Restructured the article to make it nicer, using Fox' code template)
Jump to navigation Jump to search

The command action refers to both the declarative statement that defines the animation for an actor, and to the statement that changes the animation of an actor at runtime.

Declarative Statement

action <name> <startframe> <frames> <viewtype> <incvalue> <delay>

This statement must be placed outside of any code blocks.

Arguments

  • <name>: Defines the name of the action, to be used with the runtime statement.
  • <startframe>: Defines the starting frame number (relative to the main sprite of the actor).
  • <frames>: Defines the total number of frames in the animation, after which it will loop. Must be at least 1.
  • <viewtype>: Defines the number of sides drawn for the actor. Prior to 3D models, this method was used to simulate a 3D appearance for sprites. Valid values are:
1 - The sprite will appear the same regardless of the angle at which it is viewed.
3 - The sprite will have 16 angles built from only 4 art tiles. A new frame is drawn every 22.5 degrees in a clockwise pattern beginning with the front of the sprite.
The pattern is as follows, with 1, 2, 3, and 4 being the order of the four tiles used, and M denoting that the tile is mirrored: 1M, 2M, 3M, 4M, 4, 3, 2, 1, 1M, 2M, 3M, 4M, 4, 3, 2, 1
5 - The sprite will have 8 angles constructed from 5 art tiles, three of which are mirrored. A new frame is drawn every 45 degrees in a clockwise pattern beginning with the front of the sprite.
The pattern is as follows: 1, 2, 3, 4, 5, 4M, 3M, 2M
7 - The sprite will have 12 angles constructed from 7 art tiles, five of which are mirrored. A new frame is drawn every 30 degrees in a clockwise pattern beginning with the front of the sprite.
The pattern is as follows: 1, 2, 3, 4, 5, 6, 7, 6M, 5M, 4M, 3M, 2M
8 - The sprite will have 8 angles constructed from 8 art tiles. A new frame is drawn every 45 degrees in a clockwise pattern beginning with the front of the sprite.
In this case it uses a simple pattern: 1, 2, 3, 4, 5, 6, 7, 8
View type 1 is generally used for pickups and environmental objects like fire hydrants.
View type 3 is useful only for very symmetrical actors but it does give the most angles.
View types 5 and 7 are for actors which have a single axis of symmetry and which need to face directions other than directly towards the player.
View type 8 is for objects with little in the way of symmetry.
  • <incvalue>: Defines by how many frames the animation should advance in each step. If negative, the animation will play in reverse.
Note that it is possible to define increments greater than 1 or smaller than -1.
  • <delay> : Defines the delay between frames, where the value needs to be a multiple of 4. Any values inbetween result in the same delay as the nearest multiple rounded down.
The delay is not proportional to the value, i.e. a delay of 16 does not result in double the time between frames as a delay of 8.
Much rather, the calculation is as follows:
  • [0,3] is the minimum delay, equal to the tic counter.
  • [4,7] is 1/2 of the tic counter delay
  • [8,11] is 1/3 of the tic counter delay
  • [12,15] is 1/4; [16,19] is 1/5; etc.

Runtime Statement

action <name>

Changes the actor's current action when called from within the actor code. Note that calling this statement from within an event has no effect.

Note: Every frame advance adds 1 to actioncount. To reset an animation, either call the action again or use resetactioncount. Starting a new animation will also reset actioncount to 0.