From The Mana World
(→‎Comments: unit of delay property)
m (Move page script moved page Dev:Animations to Development:Animations: Rename Dev: to Development: so the miraheze import works)
 
(55 intermediate revisions by 11 users not shown)
Line 1: Line 1:
This is a first attempt at defining a new animation system which should improve the current behaviour of beings, especially the player.
{{Category_programming}}
The general idea is to have an xml document defining everything about an animation. Here follows an example of what I'm talking about.
{{Category_art}}
{{Status_green}}


<pre>
TMW follows the same conventions as laid out by the client [http://manaplus.org/ manaplus]
 
== Example of a sprite definition ==
 
The animations of all sprites are defined by xml documents. Here follows an example:
 
<syntaxhighlight lang="xml">
<?xml version="1.0"?>
<?xml version="1.0"?>
<animation name="player">
<sprite name="player" action="stand">
<images>
 
  <image id="0" name="misc" file="player-male-misc.png" width="64" height="64"/>
<imageset name="base" src="graphics/sprites/player_male_base.png" width="64" height="64" />
  <image id="1" name="stab" file="player-male-stab.png" width="64" height="64"/>
 
  <image id="2" name="bow" file="player-male-bow.png" width="64" height="64"/>
<action name="stand" imageset="base">
</images>
<animation direction="down">
<actions>
<frame index="0" />
  <action name="stand" image="0" frames="1"/>
</animation>
  <action name="walk" image="0" frames="6">
<animation direction="left">
  <frame delay="20">
<frame index="18" />
  <frame delay="20">
</animation>
  <frame delay="20">
<animation direction="up">
  <frame delay="20">
<frame index="36" />
  <frame delay="20">
</animation>
  <frame delay="20">
<animation direction="right">
  </action>
<frame index="54" />
  <action name="sit" image="0" frames="1"/>
</animation>
  <action name="die" image="0" frames="1"/>
</action>
  <action name="stab" image="1" frames="4">
 
  <frame delay="20">
<action name="walk" imageset="base">
  <frame delay="30">
<animation direction="down">
  <frame delay="20">
<frame index="1" delay="75" />
  <frame delay="20">
<frame index="2" delay="75" />
  </action>
<frame index="3" delay="75" />
  <action name="bow" image="2" frames="5">
<frame index="4" delay="75" />
  <frame delay="10">
<frame index="5" delay="75" />
  <frame delay="10">
<frame index="6" delay="75" />
  <frame delay="40">
</animation>
  <frame delay="20">
<animation direction="left">
  <frame delay="20"
<sequence start="19" end="24" delay="75" />
  </action>
</animation>
</actions>
<animation direction="up">
</animation>
<sequence start="37" end="42" delay="75" />
</pre>
</animation>
<animation direction="right">
<sequence start="55" end="60" delay="75" />
</animation>
</action>
 
<action name="attack" imageset="base">
<animation direction="down">
<sequence start="9" end="12" delay="75" />
<end />
</animation>
<animation direction="left">
<sequence start="27" end="30" delay="75" />
<end />
</animation>
<animation direction="up">
<sequence start="45" end="48" delay="75" />
<end />
</animation>
<animation direction="right">
<sequence start="63" end="66" delay="75" />
<end />
</animation>
</action>
 
</sprite>
</syntaxhighlight>
 
So if you want to load the playerset you just load player.xml and it takes care of loading all related images. Of course delays are defined in milliseconds.
 
== Specifications ==
 
=== &lt;sprite&gt; ===
A sprite is an object which can carry several animations, hence we call the root element the <code>sprite</code>. The sprite tag has two optional properties <code>variants</code> and <code>variant_offset</code>. These are required when there are multiple very similar versions of a sprite in one spriteset. One example for this are the hairset spritesets. The <code>variants</code> property defines the number of variants in the spriteset and the <code>variant_offset</code> property how many sprites are between the first sprites of the variants. When defining multiple variants you only define the animation sequences of the first variant. the engine then shifts the index parameters when it needs another.
 
=== &lt;action&gt; ===
collection of the animation in different directions that belong to an action the character can perform. the properties are the imageset the animation phases are taken from and the name of the action.
 
Current actions as defined in the base sprite 1.0:
Default
Walk
sit
dead
attack
attack_bow
Directions: NSEW


So if you want to load the playerset you just load player.xml and it takes care of loading all related images.  
New actions/directions will be added as the sprite progresses.
Reuse of frames should also be considered, so we could specify the exact frames sequence. Just take the bat as an example. The standing animation as well as the walking one require 4 frames. A bat can hardly stay in flight without flapping his wings as it does now. And in the spritesheet the first 2 rows are identical suggesting one of them could be removed.
Sprite 1.5 work can be seen here [https://trello.com/b/rNnx513z/art-development art trello]


The action type matches the item.xml:
<pre>
<pre>
<?xml version="1.0"?>
    <item id="522"
<animation name="bat">
        image="equipment/weapon/dagger-sharpknife.png"
<images>
        name="Sharp Knife"
  <image id="0" name="misc" file="monster15.png" width="60" height="60"/>
        description="A really sharp knife. Don't hurt yourself!"
</images>
        effect="Damage +10"
<actions>
        type="equip-1hand"
  <action name="stand" image="0" frames="4"/>
        weapon-type="knife"
  <frame delay="20" frame="0">
        attack-action="attack"
  <frame delay="20" frame="1">
        weight="150">
  <frame delay="20" frame="2">
        <sprite>weapon-dagger.xml</sprite>
  <frame delay="20" frame="3">
        <sound event="strike">weapons/knives/sharpknife-miss1.ogg</sound>
  <action name="walk" image="0" frames="4"/>
    </item>
  <frame delay="20" frame="0">
  <frame delay="20" frame="1">
  <frame delay="20" frame="2">
  <frame delay="20" frame="3">
  </action>
  <action name="die" image="0" frames="1"/>
</actions>
</animation>
</pre>
</pre>
Would use attack from the sprite sheets or default if attack is not declared.


== Comments ==
=== &lt;animation&gt; ===
Defines an animation sequence that should be displayed when the sprite object faces in a specific direction (attribute "direction").


Maybe the <frame> tags should define the spriteset id and the number of the sprite inside the spriteset. That way a single animation could consist of frames from different spritesets and any combination inside the spriteset. then i don't see the reason why the number of frames has to be in the <action> tag. isn't it possible to just count the child <frame>'s?
the possible directions are:
a walk animation where the middle animation phase is used twice would look that way:
<pre>
<pre>
  <action name="walk">
up
  <frame number="0" delay="20" spriteset="0" image="4" />
down
  <frame number="1" delay="20" spriteset="0" image="5" />
left
  <frame number="2" delay="20" spriteset="0" image="6" />
right
  <frame number="3" delay="20" spriteset="0" image="5" />
default
  </action>
</pre>
</pre>
--[[User:Crush|Crush]] 16:37, 12 March 2006 (CET)


Oh, and something else: it isn't mentioned what exactly the unit of the delay property is. i think the delays should be defined as milliseconds, not frames. that way the animation speed would be independent from the framerate. --[[User:Crush|Crush]] 16:56, 12 March 2006 (CET)
when a specific direction isn't provided, the default direction is used instead. When no default direction is defined, the first defined direction is used.
 
Every <code><animation></code> has one or more <code>frame</code> or <code>sequence</code> child elements and an optional <code><end></code> element.
 
=== &lt;frame&gt; ===
Defines one frame of the animation. The only required property is <code>index</code>.  Optional properties include <code>offsetX</code>, <code>offsetY</code> and <code>delay</code>.
 
<code>index</code> defines the index of the graphic on the spriteset.
 
The <code>delay</code> property specifies the number of milliseconds the frame is displayed before it is replaced by the next frame in the sequence. The sequence restarts when the last frame is finished. When no delay is specified (or specified as "0") the animation doesn't continue when this <code>frame</code> is reached.
 
The <code>frame</code> element has the optional properties <code>offsetX</code> and <code>offsetY</code> to specify an offset from the default drawing position for that frame. This allows the animation of for example the hairset (or any equipment) to reuse the same frames with different offsets.
 
=== &lt;sequence&gt; ===
The <code>sequence</code> tag defines one or more phases of animation. It has the required properties <code>delay</code>, <code>start</code>, and <code>end</code>. The <code>delay</code> property specifies the delay in milliseconds between each phase. The <code>start</code> and <code>end</code> properties define the first and the last indexes of the animation sequence on the spritesheet.
 
=== &lt;end&gt; ===
When the animation sequence reaches an <code>end</code> tag, the animation stops and the sprite animation is returned to the "stand" state. This can be used for one time action sequences like attacking. This tag has no properties.
 
=== &lt;include&gt; ===
 
Can be used to include another sprite definition file. If you want to override the images, you need to specify them ''before'' the include element. If you want to override any animations, you have to do so ''after'' the include element. Example:
 
<syntaxhighlight lang="xml">
<sprite>
<imageset name="base" .../>
<include file="other-sprite-file.xml"/>
<!-- possibly override or introduce new actions -->
</sprite>
</syntaxhighlight>
 
=== hairstyles ===
 
Most hairstyles which only have one frame for each direction and death, so five frames.
The offset for the hairstyles is standard to either haristlye01.xml or hairstyle13.xml
 
Currently the hairsprites follow the [http://manaplus.org/items.xml hairsprite convetion]
 
{{Template:Content XML}}
[[Category:Development]]

Latest revision as of 03:56, 27 March 2024

This article contains information for Programmers working or interested in working for The Mana World

This article contains information for Artists working or interested in working for The Mana World

This article is for reference purpose

The features described in this article are already implemented in the game. The article should describe how a certain aspect of the game currently works. You may of course edit this article to improve the description of the circumstances. Your opinions or improvement suggestions about the described aspects themself are of course appreciated, too. But please put these on the discussion page of this article to keep facts and fiction separated.


TMW follows the same conventions as laid out by the client manaplus

Example of a sprite definition

The animations of all sprites are defined by xml documents. Here follows an example:

<?xml version="1.0"?>
<sprite name="player" action="stand">

	<imageset name="base" src="graphics/sprites/player_male_base.png" width="64" height="64" />

	<action name="stand" imageset="base">
		<animation direction="down">
			<frame index="0" />
		</animation>
		<animation direction="left">
			<frame index="18" />
		</animation>
		<animation direction="up">
			<frame index="36" />
		</animation>
		<animation direction="right">
			<frame index="54" />
		</animation>
	</action>

	<action name="walk" imageset="base">
		<animation direction="down">
			<frame index="1" delay="75" />
			<frame index="2" delay="75" />
			<frame index="3" delay="75" />
			<frame index="4" delay="75" />
			<frame index="5" delay="75" />
			<frame index="6" delay="75" />
		</animation>
		<animation direction="left">
			<sequence start="19" end="24" delay="75" />
		</animation>
		<animation direction="up">
			<sequence start="37" end="42" delay="75" />
		</animation>
		<animation direction="right">
			<sequence start="55" end="60" delay="75" />
		</animation>
	</action>

	<action name="attack" imageset="base">
		<animation direction="down">
			<sequence start="9" end="12" delay="75" />
			<end />
		</animation>
		<animation direction="left">
			<sequence start="27" end="30" delay="75" />
			<end />
		</animation>
		<animation direction="up">
			<sequence start="45" end="48" delay="75" />
			<end />
		</animation>
		<animation direction="right">
			<sequence start="63" end="66" delay="75" />
			<end />
		</animation>
	</action>

</sprite>

So if you want to load the playerset you just load player.xml and it takes care of loading all related images. Of course delays are defined in milliseconds.

Specifications

<sprite>

A sprite is an object which can carry several animations, hence we call the root element the sprite. The sprite tag has two optional properties variants and variant_offset. These are required when there are multiple very similar versions of a sprite in one spriteset. One example for this are the hairset spritesets. The variants property defines the number of variants in the spriteset and the variant_offset property how many sprites are between the first sprites of the variants. When defining multiple variants you only define the animation sequences of the first variant. the engine then shifts the index parameters when it needs another.

<action>

collection of the animation in different directions that belong to an action the character can perform. the properties are the imageset the animation phases are taken from and the name of the action.

Current actions as defined in the base sprite 1.0: Default Walk sit dead attack attack_bow Directions: NSEW

New actions/directions will be added as the sprite progresses. Sprite 1.5 work can be seen here art trello

The action type matches the item.xml:

    <item id="522"
        image="equipment/weapon/dagger-sharpknife.png"
        name="Sharp Knife"
        description="A really sharp knife. Don't hurt yourself!"
        effect="Damage +10"
        type="equip-1hand"
        weapon-type="knife"
        attack-action="attack"
        weight="150">
        <sprite>weapon-dagger.xml</sprite>
        <sound event="strike">weapons/knives/sharpknife-miss1.ogg</sound>
    </item>

Would use attack from the sprite sheets or default if attack is not declared.

<animation>

Defines an animation sequence that should be displayed when the sprite object faces in a specific direction (attribute "direction").

the possible directions are:

up
down
left
right
default

when a specific direction isn't provided, the default direction is used instead. When no default direction is defined, the first defined direction is used.

Every <animation> has one or more frame or sequence child elements and an optional <end> element.

<frame>

Defines one frame of the animation. The only required property is index. Optional properties include offsetX, offsetY and delay.

index defines the index of the graphic on the spriteset.

The delay property specifies the number of milliseconds the frame is displayed before it is replaced by the next frame in the sequence. The sequence restarts when the last frame is finished. When no delay is specified (or specified as "0") the animation doesn't continue when this frame is reached.

The frame element has the optional properties offsetX and offsetY to specify an offset from the default drawing position for that frame. This allows the animation of for example the hairset (or any equipment) to reuse the same frames with different offsets.

<sequence>

The sequence tag defines one or more phases of animation. It has the required properties delay, start, and end. The delay property specifies the delay in milliseconds between each phase. The start and end properties define the first and the last indexes of the animation sequence on the spritesheet.

<end>

When the animation sequence reaches an end tag, the animation stops and the sprite animation is returned to the "stand" state. This can be used for one time action sequences like attacking. This tag has no properties.

<include>

Can be used to include another sprite definition file. If you want to override the images, you need to specify them before the include element. If you want to override any animations, you have to do so after the include element. Example:

<sprite>
	<imageset name="base" .../>
	<include file="other-sprite-file.xml"/>
	<!-- possibly override or introduce new actions -->
</sprite>

hairstyles

Most hairstyles which only have one frame for each direction and death, so five frames. The offset for the hairstyles is standard to either haristlye01.xml or hairstyle13.xml

Currently the hairsprites follow the hairsprite convetion

Content XML files

Databases

effects.xml | emotes.xml | hair.xml | items.xml | monsters.xml | maps.xml | npcs.xml | runes.xml | skills.xml | status-effects.xml

Filetypes

Particle XML files | Animation XML files | GUI window skin XML files