Topic: Portable TeeUniverse Map
I've create a small modification for TeeWorlds to allow server to read "Portable TeeUniverse" maps. PTU maps are pure vanilla maps, but that contains two invisible special groups: "#Entities" and "#Zones".
The concept of zones and entities comes from TeeUniverse and PTU maps are designed to facilitate the integration of maps made with TeeUniverse on existing mods.
A zone is a tile layer or a quad layer that define area in the map with special properties. Typically, "death tile" are a kind of zone, but here, it's also possible to define "death quads". Ultimately, it will be possible to animate those quads and create moving death elements. I will implement this part once the animation tools are done in TeeUniverse. The adventages of zones is that you can define as many zone as you want. You can even create multiple time the same type of zone, the server will take the last non-zero index of all zone of this type. It's much more flexible than the vanilla tile system.
An entity is a point that the server detect to create an in-game entity such armor or gun. In vanilla, entities are added using tiles, but in fact, there is no reason to align them on a grid (except for the sake of beauty, but this should be the decision of the map maker). In PTU maps, entities are represented by quads and then can be located in any part of the map.
Here is the code to read PTU maps: https://github.com/teeuniverse/teeworlds-ptum
Tutorial
Entities:
To create an entity, you must have a group called "#Entities". In this group (please enable clipping so players will not see it), create a quad layer called "twHealth". Any quads in this layer will create a heart in game, where the center of the heart is given by the position of the pivot. Vanilla entities are twSpawn, twSpawnRed, twSpawnBlue, twFlagStandRed, twFlagStandBlue, twShotgun, twRifle, twGrenade and twNinja. You can also create you own entity. Just change the name of the quad layer, and in your server, in the function "OnEntity()", check the name of the entity:
if(str_comp(pName, "myEntity") == 0)
{
//Create something at the position "Pos"
}
Zones:
To create a zone, you must have a group called "#Zones". In this group (please enable clipping so players will not see it), create a quad layer called "twDeath". Any quads in this layer will create a death zone in game. However you must setup the index of this quad (like for tiles). Set the ColorTO value to "1" to make it a death zone. You can also create a tilelayer called "twDeath". Any tiles with the index "1" will be a death zone.
Once again, you can create your own zones by changing the name of the layer and set one of 128 possible index values. In your code, you must first create a handle to the type of zone in the function CGameContext::OnInit
m_ZoneHandle_MyZone = m_Collision.GetZoneHandle("myZone"); //m_ZoneHandle_MyZone is a public variable of CGameContext
Then, you can check this position in your code using this function:
int Index = GameServer()->Collision()->GetZoneValueAt(GameServer()->m_ZoneHandle_MyZone, x, y)
PTU maps are designed to be fully compatible with vanilla editor, without any modification. However, it's not simple to make them because the editor is not made for this. TeeUniverse is of course preferred to do this, and the upcoming version 0.2 will suport import/export of PTU maps. But now, there is no reason to not use them In addition, if all mods use the appropriate names for layers, a single maps will be able to run on several mods without collision with indices.