From The Mana World
(removed obsolete implementation proposals)
m (Move page script moved page Dev:Animations to Development:Animations: Rename Dev: to Development: so the miraheze import works)
 
(30 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Status_yellow}}
{{Category_programming}}
{{Category_art}}
{{Status_green}}


Each animation will be defined by an xml document, here follows an example:
TMW follows the same conventions as laid out by the client [http://manaplus.org/ manaplus]


<pre>
== 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"?>
<sprite name="player" action="stand">
<sprite name="player" action="stand">


Line 10: Line 17:
<action name="stand" imageset="base">
<action name="stand" imageset="base">
<animation direction="down">
<animation direction="down">
  <frame index="0" />
<frame index="0" />
</animation>
</animation>
<animation direction="left">
<animation direction="left">
  <frame index="18" />
<frame index="18" />
</animation>
</animation>
<animation direction="up">
<animation direction="up">
  <frame index="36" />
<frame index="36" />
</animation>
</animation>
<animation direction="right">
<animation direction="right">
  <frame index="54" />
<frame index="54" />
</animation>
</animation>
</action>
</action>
Line 25: Line 32:
<action name="walk" imageset="base">
<action name="walk" imageset="base">
<animation direction="down">
<animation direction="down">
<frame index="1" delay="50" />
<frame index="1" delay="75" />
<frame index="2" delay="50" />
<frame index="2" delay="75" />
<frame index="3" delay="50" />
<frame index="3" delay="75" />
<frame index="4" delay="50" />
<frame index="4" delay="75" />
<frame index="5" delay="50" />
<frame index="5" delay="75" />
<frame index="6" delay="50" />
<frame index="6" delay="75" />
</animation>
</animation>
<animation direction="left">
<animation direction="left">
<sequence start="19" end="24" delay="50" />
<sequence start="19" end="24" delay="75" />
</animation>
</animation>
<animation direction="up">
<animation direction="up">
<sequence start="37" end="42" delay="50" />
<sequence start="37" end="42" delay="75" />
</animation>
</animation>
<animation direction="right">
<animation direction="right">
<sequence start="55" end="60" delay="50" />
<sequence start="55" end="60" delay="75" />
</animation>
</action>
 
<action name="sit" imageset="base">
<animation direction="down">
<frame index="7" />
</animation>
<animation direction="left">
<frame index="25" />
</animation>
<animation direction="up">
<frame index="43" />
</animation>
<animation direction="right">
<frame index="61" />
</animation>
</action>
 
<action name="dead" imageset="base">
<animation direction="down">
  <frame index="8" />
</animation>
<animation direction="left">
  <frame index="26" />
</animation>
<animation direction="up">
  <frame index="44" />
</animation>
<animation direction="right">
  <frame index="62" />
</animation>
</animation>
</action>
</action>
Line 75: Line 52:
<action name="attack" imageset="base">
<action name="attack" imageset="base">
<animation direction="down">
<animation direction="down">
<sequence start="9" end="12" delay="100" />
<sequence start="9" end="12" delay="75" />
<end />
</animation>
</animation>
<animation direction="left">
<animation direction="left">
<sequence start="27" end="30" delay="100" />
<sequence start="27" end="30" delay="75" />
<end />
</animation>
</animation>
<animation direction="up">
<animation direction="up">
<sequence start="45" end="48" delay="100" />
<sequence start="45" end="48" delay="75" />
<end />
</animation>
</animation>
<animation direction="right">
<animation direction="right">
<sequence start="63" end="66" delay="100" />
<sequence start="63" end="66" delay="75" />
<end />
</animation>
</animation>
</action>
</action>


</sprite>
</sprite>
</pre>
</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.
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.
Line 96: Line 77:


=== &lt;sprite&gt; ===
=== &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 got 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. <code>variants</code> defines the number of variants in the spriteset and <code>variant_offset</code> 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 wants anotherone.
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; ===
=== &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.  
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.  


possible names:
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 [https://trello.com/b/rNnx513z/art-development art trello]
 
The action type matches the item.xml:
<pre>
<pre>
              use-item
    <item id="522"
                  |
        image="equipment/weapon/dagger-sharpknife.png"
  attack-bow  cast-magic
        name="Sharp Knife"
      |          |
        description="A really sharp knife. Don't hurt yourself!"
attack-stab  attack-throw
        effect="Damage +10"
        \    /      
        type="equip-1hand"
run  attack-swing  sleeping  dead
        weapon-type="knife"
|          |          |        |
        attack-action="attack"
walk     attack        sit      hurt
        weight="150">
  \        \          /         /
        <sprite>weapon-dagger.xml</sprite>
              stand
        <sound event="strike">weapons/knives/sharpknife-miss1.ogg</sound>
                |
     </item>
        (no name attribute)
</pre>
</pre>
 
Would use attack from the sprite sheets or default if attack is not declared.
this table also specifies the substitution precedence. when a specific name is requested but it is not defined the next lower name is used instead.


=== &lt;animation&gt; ===
=== &lt;animation&gt; ===
Line 129: Line 120:
left
left
right
right
default
</pre>
</pre>


when a specific direction isn't provided, the first defined direction is used instead. this can be overridden by defining an animation with the direction "default" for this action.
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.
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; ===
=== &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>.
each of them defines one frame of the animation. the required properties are <code>index</code> and optional <code>offsetX</code>, <code>offsetY</code> and <code>delay</code>.


<code>index</code> defines the index of the graphic on the spriteset.  
<code>index</code> defines the index of the graphic on the spriteset.  


an optional property is <code>delay</code>. every frame is displayed for <code>delay</code> millisecounds and then replaced by the next frame in sequence. when the last frame is reached the sequence starts with the first frame again. when no delay is specified (or specified as "0") the animation doesn't continue when this <code>frame</code> is reached.
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.


Each <code>frame</code> element can optionally have the 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.
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; ===
=== &lt;sequence&gt; ===
<code>sequence</code> tag does not only define one animation phase but multiple phases. Its properties are <code>delay</code>, <code>start</code> and <code>end</code> which are all required. The delay is the delay in ms between each phase. the properties <code>start</code> and <code>end</code> define the first and the last index of the animation sequence on the spritesheet.
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.


== Suggested additions ==
=== &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.


=== multiple delays in a &lt;frame&gt; with start and end attribute ===
=== &lt;include&gt; ===
in the bow animation I've chosen a shortcut to specify different delays for different frames. I am undecided yet whether this is a nice feature or whether it'll be better to require multiple <code>frame</code> elements in such cases.


=== &lt;random&gt; childtag for &lt;animation&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:
Also, it includes an experimental suggestion on specifying that a random frame should be chosen. This should also have an exclude_current_frame thingy, to make sure a frame isn't shown twice or more in a row. Sometimes this may be wanted though.


=== sequences based on default sequences ===
<syntaxhighlight lang="xml">
After reflecting on this idea (and the above suggestion) I think a first issue to solve is to reduce the amount of duplicated definitions. For example, at the moment every monster uses the exact same frame size and animation frames. Hence, it would be interesting if the defined sprite could take the actual imageset it uses as a parameter instead of specifying this on its own. This way we can define a monster like:
<sprite>
 
<imageset name="base" .../>
<pre>
<include file="other-sprite-file.xml"/>
<sprite name="monster-walking-default">
<!-- possibly override or introduce new actions -->
<imageset name="base" />
...
</sprite>
</sprite>
</syntaxhighlight>


<being name="Scorpion">
=== hairstyles ===
<sprite ref="monster-walking-default">
  <with-imageset name="base" src="scorpion-base.png" width="60" height="60" />
</sprite>
</being>
 
<being name="Red Scorpion">
<sprite ref="monster-walking-default">
  <with-imageset name="base" src="scorpion-red-base.png" width="60" height="60" />
</sprite>
</being>
</pre>
 
Defining an empty imageset (without <code>src</code> attribute) will make the engine require this imageset to be passed as a parameter whenever the spriteset is referenced.
 
I'm not convinced yet that the <code>name</code> attribute of the <code>sprite</code> element is really necessary. I think I would prefer each sprite to be defined in its own file. However it could be attractive to define multiple things in the same file, but in that case I think we will have to read everything when the client is launched, and only graphics and imagesets can be created lazily (only when necessary). Because the other data consists of just numbers and strings, this should not be really a problem.
 
== Implementation proposal of hairstyles by Modanung ==
 
I think the current system with an xml file for every hairstyle with an index and offset defined for every frame is a bit too much. It also takes a lot of work to correct small errors and to add new hairstyles that may have a different frame size and with it a different offset.
I suggest we split hairstyles up in three catagories:
* Static hairstyles
* Standard animated hairstyles
* Special case hairstyles
===Static hairstyles===
These are hairstyles which only have one frame for each direction and death, so five. All current hairstyles would be static hairstyles. Every individual static hairstyle needs nothing more to be defined then their bitmap, their size and their offset for each direction.
The offset for each seperate frame would be defined in a shared file (say hairoffsets.xml), this summed with the individual hairstyle's offset is the offset for that single frame with that hairstyle.
<pre>
hairstyle1.xml
<offsetfile="hairoffsets.xml", framefile="static_hairstyles_frames.xml">
<sprite variants="10" variant_offset="5">


<imageset name="base" src="graphics/sprites/hairstyle1.png" width="40" height="40" />
Most hairstyles which only have one frame for each direction and death, so five frames.
<offsetX="0" offsetY ="0" />
The offset for the hairstyles is standard to either haristlye01.xml or hairstyle13.xml


End of file
Currently the hairsprites follow the [http://manaplus.org/items.xml hairsprite convetion]
</pre>


<pre>
{{Template:Content XML}}
hairoffsets.xml
[[Category:Development]]
 
<action name="stand" imageset="base">
<animation direction="down">
  <offsetX="0" offsetY ="-29" />
</animation>
<animation direction="left">
  <offsetX="-1" offsetY ="-29"/>
</animation>
<animation direction="up">
  <offsetX="-1" offsetY ="-25"/>
</animation>
<animation direction="right">
  <offsetX="1" offsetY ="-29"/>
</animation>
</action>
 
<action name="walk" imageset="base">
<animation direction="down">
  <offsetX="0" offsetY ="-28" delay="75"/>
  <offsetX="0" offsetY ="-29" delay="75" />
  <offsetX="0" offsetY ="-29" delay="75" />
  <offsetX="0" offsetY ="-28" delay="75" />
  <offsetX="0" offsetY ="-29" delay="75" />
  <offsetX="0" offsetY ="-29" delay="75" />
</animation>
...etc...
</pre>
<pre>
static_hairstyles_frames.xml
 
<animation direction="down">
  <frame index="0" />
</animation>
<animation direction="left">
  <frame index="1" />
</animation>
<animation direction="up">
  <frame index="2" />
</animation>
<animation direction="right">
  <frame index="3" />
</animation>
<action name="dead" imageset="base">
<animation direction="default">
<frame index="4"/>
</animation>
End of file
</pre>
===Standard animated hairstyles===
These are hairstyles that can be compared with hair in SoM or Chrono Trigger, they move as you walk and attack. They have three frames for each direction and death, so thirteen frames all together. These three frames can be devided in a relaxed frame and two extremes. Those two extremes either being up and down or left and right, depending on the hair style. A heavily greased Evil look would wobble up and down as you walk and a pony talk would wave from left to right.
Standard animated hairstyles hairstyles use the same offset as static ones only they have a different file for defining the frames.
<pre>
hairstyle2.xml
<offsetfile="hairoffsets.xml", framefile="animated_hairstyles_frames.xml">
<sprite variants="10" variant_offset="13">
 
<imageset name="base" src="graphics/sprites/hairstyle2.png" width="40" height="40" />
<offsetX="0" offsetY ="0" />
 
End of file
</pre>
<pre>
animated_hairstyles_frames.xml
 
<action name="stand" imageset="base">
<animation direction="down">
  <frame index="0" />
</animation>
<animation direction="left">
  <frame index="3" />
</animation>
<animation direction="up">
  <frame index="6" />
</animation>
<animation direction="right">
  <frame index="9" />
</animation>
</action>
 
<action name="walk" imageset="base">
<animation direction="down">
  <frame index="0" delay="75"/>
  <frame index="1" delay="75" />
  <frame index="1" delay="75" />
  <frame index="0" delay="75" />
  <frame index="2" delay="75" />
  <frame index="2" delay="75" />
</animation>
...etc...
</pre>
===Special case hairstyles===
And then there are the odd ones, the hairstyles that need a little more freedom. Hairstyles that people want to make wave in the wind, even when the player stands still. Or a birdnest hairstyle with nestlings that constantly open and close their mouth in a random frequency nomatter what you do. I'll take as example a Medusa hairstyle.
<pre>
hairstyle3.xml
<offsetfile="hairoffsets.xml", framefile=0>
<sprite variants="10" variant_offset="13">
<imageset name="base" src="graphics/sprites/hairstyle3.png" width="50" height="60" />
<offsetX="-5" offsetY ="-10" />
 
<animation direction="down">
  <frame index="0" delay="100"/>
  <frame index="1" delay="100"/>
  <frame index="2" delay="100"/>
</animation>
<animation direction="left">
  <frame index="3" delay="100"/>
  <frame index="4" delay="100"/>
  <frame index="5" delay="100"/>
</animation>
<animation direction="up">
  <frame index="6" delay="100"/>
  <frame index="7" delay="100"/>
  <frame index="8" delay="100"/>
</animation>
<animation direction="right">
  <frame index="9" delay="100"/>
  <frame index="10" delay="100"/>
  <frame index="11" delay="100"/>
</animation>
<action name="dead" imageset="base">
<animation direction="default">
<frame index="12"/>
</animation>
 
End of file
</pre>
This hairstyle showes a bunch of snakes on your head that always wave 'n wobble unless you're dead. The animation rolls asychronusly with the attack and walking animations and it also moves when you stand still. But the offsets are in sync. Special hairstyles might also use their own offsets ofcourse
I think this pretty much finished my proposal.

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