Map layering question

Content and general development discussion, including maps, quests, and server code from the development team.
Post Reply
nmaligec
Novice
Novice
Posts: 253
Joined: 08 Apr 2010, 02:55

Map layering question

Post by nmaligec » 13 Nov 2010, 11:45

Ok well to my knowledge there are three different ways to get graphics to show up on a map cell.
1. Map tiles in the .tmx file
2. An npc.
3. A particle

Also a particle can be added in different ways:
4. Direclty into the xml of the .tmx map file.
5. As part of an npc xml definition (or a monster)
6. A call to specialeffect script command.

So what is the layering priorities for 1-3 when drawing a cell?
Does 4-6 affect particle layering position?

So far from what I can tell particles are drawn under everything else on the same tile as them.
Map tiles depend on what layer they are drawn on.
Npc's I am uncertain of, I guess they appear over anything except a map tile designated as 'over'.

Can anyone who understands how the layers are drawn give good explanation/clarification? A link to a wiki article or related forum post would be helpful too.


My goal would be to play a specialeffect (using the particle engine) OVER some map tiles (besides the ground/floor tile layer).
User avatar
Gotcha
Peon
Peon
Posts: 84
Joined: 29 Jul 2010, 16:16

Re: Map layering question

Post by Gotcha » 13 Nov 2010, 14:45

hi!

in tiled, you have these layers in this order:
Number Layer Description
4 Object Objectlayer for Warps, Spawnareas, NPCs etc.
3 Collision Collisiontiles
2 Over Thing above the player
1 Fringe Everything that stands on the ground(trees, stones etc)
0 Ground The groundtiles like grass or sand.

make sure to always have the right layer selected.
Regarding the Collision layer, you will need this red semitransparent tile from exampledata
to cover unwalkable areas like obstacles.
there is an excellent guide here, but it is in german: http://wiki.invertika.org/Mapping_Tutorial

hope that helps a little bit.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Map layering question

Post by Crush » 14 Nov 2010, 01:42

The particles are always drawn on the fringe map layer together with the other sprites.

But to understand how the drawing order on the fringe layer works, you first have to understand one thing: the particle engine is 3-dimensional.

While all normal sprites have just two coordinates in the world, x (west->east) and y (north->south), particles also have a z (down->up) coordinate.

So how does this affect drawing order?

The drawing priority of normal sprites (including NPCs) is equal to their y coordinate in pixels, while the drawing priority of particles is y + z - 64. Why the -64? This is to compensate for the fact that most sprites are drawn relative to the center of their feet while particles are drawn relative to their overall center.

When you have fringe tiles which are supposed to act like a floor tile the particles engine treats them like standing signs. So particles which are supposed to be on the floor (z=0) are drawn behind these tiles. For that reason it is now discouraged to put any kind of floor decoration on the fringe layer. Use a second floor layer instead (Gotchas info above is outdated - you can have any number of floor- and over layers).

So how do you create particles which are drawn in front of all other things? You can cheat by placing the emitters some pixels lower and the same number of pixels higher in their particle effect xml file. This will result in them being placed on the same screen position but they will be drawn after sprites on the same position.


It does not matter how a particle effect is created. All particles are treated equally regarding drawing order. A long-term goal is to have particle effects which live on other map layer than the fringe layer and particle effects on the GUI, but this won't happen so soon.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
nmaligec
Novice
Novice
Posts: 253
Joined: 08 Apr 2010, 02:55

Root particle x, y

Post by nmaligec » 15 Nov 2010, 03:54

Crush, thanks for the reply. I have been able to move particles around so that the draw in the desired layer order.

I have run into a few problems when trying to use particle effects from the scripting command specialeffect. When invoked this way, the x, and y coords of the root particle are ignored! Changing z still has an effect. It seems like its x,y are always centered on the calling npc. (This also seems to be the case for particles attached to mobs in monsters.xml).

I can get around this by moving the animation tags inside of an emitter and setting coords there. The problem with this is that I only want 1 particle to appear not several. I can prevent multiple frames from showing at once by setting output-pause to the total # of frames, but then I have to wait some time for even the first particle to appear.

It was suggested that setting lifetime of the root particle to 1 would only let 1 particle spawn but I did not get that result. It seems like the emitter keeps doing its own thing, emitting more particles.

I have tried everything I could, so any help would be much appreciated.

Reguarging floor layers in tiled: How to set up more than 1 floor layer? Do you have to give it a special name or property? Similarly for multiple over layers which draw on top of players. Do you just have to place ground/ fringe/over layers in the correct order??
User avatar
Gotcha
Peon
Peon
Posts: 84
Joined: 29 Jul 2010, 16:16

Re: Map layering question

Post by Gotcha » 15 Nov 2010, 12:24

hi and thx Crush for the info.
i'm sure the additional ground and over layers have to have the correct names but i am clueless about this.
did you set up manaserv or eathena? with manaserv, there comes exampledata for a firegoblin that is particlemonster, so this
could help(you find it outside first town in the desert)
important to know would be the reserved id ranges for different types of objects like monsters and npcs, they do need a right id or it wont show up.
(i also used the info from invertica for this, but after some updates their ids don't seem to fit with the manaworld ones)
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Root particle x, y

Post by Crush » 15 Nov 2010, 14:46

nmaligec, can you please describe what exactly you want to do? Maybe I can suggest a workaround then.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
nmaligec
Novice
Novice
Posts: 253
Joined: 08 Apr 2010, 02:55

Re: Map layering question

Post by nmaligec » 16 Nov 2010, 05:29

First off, I am using tA/eA with the 0.0.29.1 client for testing.

What I want to do:
1. Create interactive objects that play an animation sequence based on the action taken. Right now I just want to make a gate that displays a closed frame until the player interacts with it, and picks the open gate menu choice. When it is 'opened', remove the closed gate and play the opening animation. I have a sloppy implementation of this that looks great, but I am not too proud of.(2 npc entries in npcs.xml + two extra permanent npcs placed in the map + 1 entry in effects.xml)

2. Create a trap that activates an animation when the player steps on it. I got the interactions done. The animation consists of a layer under the player and a layer over the player. As mentioned earlier, I was able to do this but the implementation is messy (using emitters to adjust for layering).

3. Create the layered whip animation required for the new weapon discussed in:

http://forums.themanaworld.org/viewtopi ... =8&t=11189

From what I heard, the main stumbling block was getting the whip behind the player for some animations and in front for others. Simply cutting out pixels from the whip didn't work as it still overlaps certain equipment. I haven't tried yet, but I would split the behind frames from the in front frames and use the particle layering techniques you described (question: can you add 2+ particle effects to a weapon entry??).

edit:
an addendum to #2: creating any animated particles to be displayed over a map tile. Example: animated blood pools to be displayed over empty basin tiles.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Map layering question

Post by Crush » 16 Nov 2010, 07:21

I wouldn't suggest to use the particle engine for any of these purposes.

Regarding the gate animation: doing this with particle effects would be an even nastier hack than doing it with NPCs. The NPCs are at least synchronized on the server.

(On Manaserv we plan to implement "map paching" - the ability to persistently exchange whole parts of the map from a script. But this won't help you much on tA, of course.)

Regarding the whip animation: I didn't even know that it is already possible to attach particle effects to melee weapons (at the moment I am not reading every single commit). But using them in that way is certainly not a good idea. Ask the artist to redesign the animation taking the layering precedence of player sprites into account would be the best solution. When you really must solve this with a background animation implemented as a particle effect, use a normal spriteset for the front and a particle effect for the back.

Regarding the pool animation: This can be done much easier. The client already supports animated tiles. It's explained in the mapping tutorial and the cave where the mana seed is in has an example (water dropping from walls).
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
nmaligec
Novice
Novice
Posts: 253
Joined: 08 Apr 2010, 02:55

Re: Map layering question

Post by nmaligec » 16 Nov 2010, 09:50

Hah, you were right. I thought there was an entry with a particle but it was a missile-particle property instead. Oh well no cool whip, I guess it will have to be redone so that it doesn't go behind the player in any frames.

re animated tiles: thanks I totally missed that part of the tutorial first time through.

edit:
How would you suggest adding candle flames to the candle fringe tiles below?
candles.png
candles.png (7.37 KiB) Viewed 1153 times
I was thinking of making a an animated particle and placing several versions of it with pixel offsets to match the candles (since each one is at a different hight). The other possibility would be to make a candle tilesheet with all the animation frames on it and follow the animated tile mapping procedure.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Map layering question

Post by Crush » 16 Nov 2010, 11:26

Creating particle effects with different offsets for the candles is unnecessary. You can place particle effects with pixel accuracy on the map (I am not sure if Tiled can do this, but when it can't you can edit the tmx file with a text editor afterwards).

But depending on how you want the flames to look, animated tiles might be a better choice. When a particle effect would end up with a single animated particle which just stays in place, it is unnecessary to do it as a particle effect. But when you don't want to hand-pixel the flame animation but create it procedurally instead, the particle engine might help.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
Post Reply