Difference between revisions of "WML for Complete Beginners: Chapter 6"

From The Battle for Wesnoth Wiki
(Useful Links for adding your own Custom Units)
(initial unit_type example)
Line 3: Line 3:
 
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.
 
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.
  
===Creating your Custom Unit's .cfg File===
+
===Creating the Unit .cfg File===
  
Add the custom units .cfg file to my_first_campaign/units
+
Create a new text file in the "units" folder inside the campaign folder. You could name this "my_first_unit.cfg".
  
Example of a .cfg file:
+
As usual, start with the textdomain and toplevel tag:
  
 +
#textdomain wesnoth-my_first_campaign
  
 +
[unit_type]
 +
[/unit_type]
 +
 +
A somewhat minimal set of initial keys might be:
 +
 +
id=
 +
name=
 +
image=
 +
movement=
 +
hitpoints=
 +
 +
"id" and "name" work like usual. "movement" is interesting, because by default a unit will have no movement; quite a boring unit! The same goes for hitpoints; you would have 1 hitpoint if unset.
 +
 +
Filling these out, you might end up with:
 +
 +
#textdomain wesnoth-my_first_campaign
 +
 +
[unit_type]
 +
    id=My First Unit
 +
    name= _ "My First Unit"
 +
    image=
 +
    movement=10
 +
    hitpoints=10
 +
[/unit_type]
  
 
===Creating your Custom Unit's Images===
 
===Creating your Custom Unit's Images===

Revision as of 06:46, 10 October 2018

Chapter 6: Building and Including a Custom Unit

Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.

Creating the Unit .cfg File

Create a new text file in the "units" folder inside the campaign folder. You could name this "my_first_unit.cfg".

As usual, start with the textdomain and toplevel tag:

#textdomain wesnoth-my_first_campaign
[unit_type]
[/unit_type]

A somewhat minimal set of initial keys might be:

id=
name=
image=
movement=
hitpoints=

"id" and "name" work like usual. "movement" is interesting, because by default a unit will have no movement; quite a boring unit! The same goes for hitpoints; you would have 1 hitpoint if unset.

Filling these out, you might end up with:

#textdomain wesnoth-my_first_campaign
[unit_type]
    id=My First Unit
    name= _ "My First Unit"
    image=
    movement=10
    hitpoints=10
[/unit_type]

Creating your Custom Unit's Images

Add the images to my_first_campaign/units

Including the Custom Unit in your Campaign

[+units]
   {~add-ons/my_first_campaign/units}
[/units]

Useful Links for adding your own Custom Units

Editing your Custom Units .cfg file:
http://wiki.wesnoth.org/UnitTypeWML
http://wiki.wesnoth.org/SingleUnitWML

Continue

Next Chapter: WML for Complete Beginners: Chapter 7

Previous Chapter: WML for Complete Beginners: Chapter 5

Return to Main Index: WML for Complete Beginners