In this section, we are going to create a simple Monster step-by-step.
All you need is to have your Text Editor open and follow the steps below:
Open your Text Editor and Create a new file.
Hit the "Save as" option and save your file as "Tutorial_First_Monster_XML.xml".
By saving the file in .xml, your Editor should recognize the language and apply the appropriate color coding to your script!
<Object type="0x000" id="Test Monster">
<DisplayId>Oryx the Mad God</DisplayId>
</Object>
You have now created a new Object called "Test Monster" and assigned a type to it.
We have also created a <DisplayId> which is the name that players will see, whereas in the code the monster Id is "Test Monster".
NOTE: As you can in the above syntax, we have opened <Object>
and closed </Object>
. We also did the same with <DisplayId>
and </DisplayId>
. You must ALWAYS close your tags after opening them or your XML will not work.
NOTE 2: both the type
and id
need to be unique and the id
needs to be easily identifiable, but that is not important for our tutorial. So don't worry about that just yet!
<Object type="0x000" id="Test Monster">
<DisplayId>Oryx the Mad God</DisplayId>
<Enemy/>
<Class>Character</Class>
<Texture><File>lofiChar8x8</File><Index>0xcd</Index></Texture>
<HitSound>monster/chicken_hit</HitSound>
<DeathSound>monster/chicken_death</DeathSound>
</Object>
You now defined:
<Enemy/>
).<HitSound>)
and when it dies (<DeathSound>
).<Object type="0x000" id="Test Monster">
<DisplayId>Oryx the Mad God</DisplayId>
<Enemy/>
<Class>Character</Class>
<Texture><File>lofiChar8x8</File><Index>0xcd</Index></Texture>
<HitSound>monster/chicken_hit</HitSound>
<DeathSound>monster/chicken_death</DeathSound>
<Size>100</Size>
<MaxHitPoints>100</MaxHitPoints>
<Defense>0</Defense>
<XpMult>0.0</XpMult>
</Object>
You now defined:
<XpMult>
value. If set to 0.0, our current Test Monster would grant 0XP, 1.0 would grant 100XP and 2.0 would grant 200XP (etc...).<Projectile id="1">
</Projectile>
The projectile ID will be used only by this monster, so you can add projectiles "1", "2" and "3" to as many Monsters as you want. However, to be able to identify what projectile is what, it is better to define better IDs (like "Shotgun bullet" or "Slow bullet").
<Projectile id="1">
<ObjectId>Yellow Star</ObjectId>
<Speed>80</Speed>
<Damage>50</Damage>
<LifetimeMS>2000</LifetimeMS>
</Projectile>
You now added the projectile properties:
Now, integrate that projectile into the XML:
<Object type="0x000" id="Test Monster">
<DisplayId>Oryx the Mad God</DisplayId>
<Enemy/>
<Class>Character</Class>
<Texture><File>lofiChar8x8</File><Index>0xcd</Index></Texture>
<HitSound>monster/chicken_hit</HitSound>
<DeathSound>monster/chicken_death</DeathSound>
<Size>100</Size>
<MaxHitPoints>100</MaxHitPoints>
<Defense>0</Defense>
<XpMult>0.0</XpMult>
<Projectile id="1">
<ObjectId>Yellow Star</ObjectId>
<Speed>80</Speed>
<Damage>50</Damage>
<LifetimeMS>2000</LifetimeMS>
</Projectile>
</Object>
Our Monster is now created, has basic properties and attributes and also has one projectile type.
Now we need to make it move and shoot!
<Behavior projectileId="1" range="7">Shoot</Behavior>
<Behavior bucket="movement" range="6" speed="0.6">Follow</Behavior>
<Behavior bucket="movement" speed="0.4">Wander</Behavior>
Make the Monster shoot:
<Behavior projectileId="1" range="7">Shoot</Behavior>
We have created our first behavior: the monster will Shoot our projectile (based on the id we defined earlier) when a player enters a range of 7 tiles.
Make the Monster move:
<Behavior bucket="movement" range="6" speed="0.6">Follow</Behavior>
<Behavior bucket="movement" speed="0.4">Wander</Behavior>
We have created our first two movement behaviors:
Let's integrate that into our XML:
<Object type="0x000" id="Test Monster">
<DisplayId>Oryx the Mad God</DisplayId>
<Enemy/>
<Class>Character</Class>
<Texture><File>lofiChar8x8</File><Index>0xcd</Index></Texture>
<HitSound>monster/chicken_hit</HitSound>
<DeathSound>monster/chicken_death</DeathSound>
<Size>100</Size>
<MaxHitPoints>100</MaxHitPoints>
<Defense>0</Defense>
<XpMult>0.0</XpMult>
<Projectile id="1">
<ObjectId>Yellow Star</ObjectId>
<Speed>80</Speed>
<Damage>50</Damage>
<LifetimeMS>2000</LifetimeMS>
</Projectile>
<Behavior projectileId="1" range="7">Shoot</Behavior>
<Behavior bucket="movement" range="6" speed="0.6">Follow</Behavior>
<Behavior bucket="movement" speed="0.4">Wander</Behavior>
</Object>
It has attributes such as life and defense, it moves and it shoots. More importantly, players can destroy it!
The next sections of this website will go more in depths on how to create the complex monsters that populate the Realm of the Mad God.
Is something described here not clear or do you have ideas on how to improve the documentation? Let us know!