Everything todo with programming goes HERE.
Post Reply
Average Program
Posts: 72
Joined: Tue Aug 10, 2010 1:32 pm


Post by Wik »

Since the svg2aamap tool of CT seems to be broken for quite some time now, and I don't know of another one out there, I tried to build a substitute.
I guess it's halfways bug-free, so... here's how it's supposed to work.

Supported SVG elements:
<line>, <rect>, <polyline>, <polygon>, <circle>, <ellipse>, <path>

Generated map objects:
<Spawn>, <Wall>, <Zone>

The script does not support grouped elements! Ungroup everything before converting.
However, it seems that it does not care very much for layers. Didn't test much more than that.

In the resulting code, walls come first, then zones and spawn points, regardless of what you started drawing with.

To make a spawn point:
Draw a straight line (curves won't work). Either set the object title to "spawn" or give it the stroke-color rgb(255,128,0). Line starting point defines spawn position, line direction defines spawn direction; length of the first line segment *can* define speed.
Does not work with <polyline/gon>. Make sure the "Spawn" option is checked (default).

To make a zone:
Drawing a circle using <circle>, <ellipse> or <path>-arcto will do. Either set the object title or the stroke-color to one of the following:

"win" - rgb(0,192,0)
"death" - rgb(240,0,0)
"fortress" - rgb(0,64,240)
"ball" - rgb(128,128,128)
"flag" - rgb(240,0,240)
"target" - rgb(0,240,240)
"rubber" - rgb(240,192,0)

If it's "rubber", the zone tag will automatically receive an empty rubberVal attribute.
The zone's diameter is calculated as the average of vertical and horizontal diameter. (This means that a skewed circle may look or be positioned differently than what one would expect. I suggest not to skew zones.)

If a path is found to be a zone, all data coming after the arcto values are discarded.

To draw a wall:
Any line that is not a <circle>, <ellipse> or <path>-arcto should become a wall.

Original draft
Original draft
Choosing options
Choosing options
Result: left with fewer, right with more Bezier segments
Result: left with fewer, right with more Bezier segments
As you see in the first pic, I prolonged the spawn point line to make an arrow, so that I remember the direction.

If you want to get rid of rounding inaccuracies like ".000000001" or ".999999998"., try the "Round" option from the previewer.
Note: the previewer removes empty zone growth attributes. Having both options "Zone growth" and "Send result" checked will cancel the former out. Just in case you wonder.

What else... custom DTDs must end with ".dtd". Check for empty attribute values before playing, let me know if you find bugs... and the server sometimes takes long to respond during Euro daytime. Sorry for that.

Post Reply