Table of Contents:
Getting Started
At the top level, the Turret XML should look familiar:<?xml version="1.0" ?> <turret> <description> </description> <credits> </credits> </turret>How ever the description element contains some unique things, lets take a look:
<description> <name> Example Turret </name> <sprite> data/maps/ExampleMap/ExampleTurret.png </sprite> <common_script> data/maps/ExampleMap/ExampleTurret.as </common_script> <client_script> data/maps/ExampleMap/ExampleTurretClient.as </client_script> <base_radius value="24.0" /> <levels> </levels> <fire_animation> </fire_animation> <fire_sound> data/common/turrets/sample_fire.ogg </fire_sound> </description>
- name: The in game name of the turret
- sprite: The turrets base sprite. This will be displayed when the player is placing the turret, and when the turret is not firing
- common_script: This is the script which contains all of the gameplay logic. Such what ever effect the turret will have on creeps. Will go into this in more detail later.
- client_script: This script contains All of the logic related to vissual effects for the turret. Such as rotating to track a creep, or fire a bullet. Anything graphical.
- base_radius: This should be the radius of the bottom of the turret. This is the area the turret claims as its own which prevents other turrets from being built on top of it. As well as how close it can be built to a path or other restricted area.
- levels: This is a container element which describes things about the upgrade levels for the turret
- fire_animation: This provides a very simple way to allow for fire animations without the need for scripting. More advanced turrets that handle this in the script can leave this empty.
- fire_sound: This provides a very simple way to allow for fire sounds. It is purely optional though as if not done well, can be very annoying to players.
<levels> <level> <info> Deals 5 damage to Creeps </info> <cost value="100" /> <resale value="50" /> <range value="80.0" /> <interval value="2.0" /> </level> <level> <info> Deals 10 damage to Creeps </info> <cost value="100" /> <resale value="75" /> <range value="110.0" /> <interval value="1.0" /> </level> </levels>Here you can see two levels defined, the first is the level which the turret will start as when built, the second is an optional upgrade that the player can pay for.
Lets take a closer look at the individual level container elements:
- info: Plain text which describes to the player what exactly this level does
- cost: How much it costs to purchase this level
- resale: How much money the player will get from selling the turret while at this level
- range: The maximum distance at which creeps will be fired on
- interval: How long in seconds the turret will wait to fire
<fire_animation> <frame delay="0.5" > data/maps/ExampleMap/ExampleTurret_fire01.png </frame> <frame delay="0.5" > data/maps/ExampleMap/ExampleTurret_fire02.png </frame> <frame delay="0.5" > data/maps/ExampleMap/ExampleTurret_fire03.png </frame> </fire_animation>And lastly, the common credits container element:
<credits> <author> Adam W. Brown </author> <version> 0.1 </version> <created> 28 MAY 2009 </created> </credits>