Creating a campaign

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Creating a campaign

Post by Daniel17022002 » March 22nd, 2017, 8:48 pm

Hey everyone! Sorry if I waste your time with my post but I'm willing to try create my first campaign around here and I don't really know where to start from ( I'm learning C++ currently and I know nothing about the language of coding of wesnoth yet so, well... :mrgreen: ). Any tips?

User avatar
Samonella
Posts: 374
Joined: January 8th, 2016, 5:41 pm
Location: USA

Re: Creating a campaign

Post by Samonella » March 22nd, 2017, 10:28 pm

The very first thing to do would be to find your add-ons directory and look through someone else's add-on (there are a couple simple add-ons designed exactly for this, one is called something like "Campaign-How-To, a simple campaign"). Just explore to get an idea for how things are organized, and glance through some of the .cfg files. They're written in WML, which is really beginner friendly. When that gets boring, copy the whole folder and start changing stuff to make it your own. Start with the file called _main.cfg, then probably the first scenario.

If that approach doesn't work well for you, take a look at the "Create" section of the website, right next to "Forums" on the black bar at the top of this page. It has lots of information about basically everything. Especially useful is ReferenceWML, which is a very good wiki describing just about everything there is to know about WML. I also found this article very useful, not for details on what code to put where, but for big-picture design principles.

And of course, if you run into errors that you can't solve yourself, then you can always post questions here.
The last few months have been nothing but one big, painful reminder that TIMTLTW.

Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 23rd, 2017, 8:27 am

thanks!

Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Re: Creating a campaign

Post by Smok » March 23rd, 2017, 8:39 am

Hey! Is't very simple.
Go to your addon directory and create new folder. In this folder create new text file. Change name of file to _main and extension to .cgf so you have _main.cfg. Now you are set, you have your own addon. WML is not like C++, it's more like HTML, but even simplier. To add something new to game, you just need to create proper tag. If your _main.cfg looks like:

Code: Select all

[campaign]
[/campaign]
your addon adds now new camaping to the game. It's all just that simple. You can customize you campaing by changing default values of keys inside of this tag. Some of this keys, like id, must be set, becouse have no default values (or your addon will crash). Notice that your campaing will aslo need scenarios to work and scenarions will need maps made in wesnoth map editor. If you want split your code to difetent .cfg files, you can add {~add-ons/<your_addon_folder_name>/<rest_of_path_to_file_or_folder_to_load_all_files_in_this_folder>} in yout _main.cfg. Check like things are done in other addons. It will help you a lot. Good luck!

Some documenation links for you:
https://wiki.wesnoth.org/CampaignWML
https://wiki.wesnoth.org/ScenarioWML

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 23rd, 2017, 8:45 am

quick dumb question, what is the .cfg extension as it seems I am unable to open it

edit : nevermind, I guess it is notepad as I learned a little bit of HTML this week ( luckily )

Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Re: Creating a campaign

Post by Smok » March 23rd, 2017, 8:48 am

It's text file. You can open it with any text editor. If you are on windows i recomend notepad++.

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 23rd, 2017, 8:18 pm

I spent an hour and got the campaign to appear on my campaign list, it now also has a name, a description, icon and picture! :D Now I'll have to learn do all the rest :annoyed:

User avatar
UnwiseOwl
Posts: 472
Joined: April 9th, 2010, 4:58 am

Re: Creating a campaign

Post by UnwiseOwl » March 23rd, 2017, 11:33 pm

Stick with it, I'm sure you'll get there. Five years into campaign creating and I'm still hoping that 'the rest' will click into place for me some time!
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 24th, 2017, 6:50 pm

I started from 0 as I want to fully understand everything and I will probably look up for some tutorials and explanations for WML

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 25th, 2017, 9:29 pm

I have a little problem , I seem to not be able to put units for the difficulties? (I tried with official examples from the WML pages but nothing happens, only the text.

Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Re: Creating a campaign

Post by Smok » March 25th, 2017, 11:07 pm

What do you mean by this? Please post your not working code.

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 26th, 2017, 8:48 pm

This is the code( with the things that don't work removed , sorry but I removed them before seeing your post):

Code: Select all

[campaign]
name=_ "Sample"
id=Sample
define=SAMPLE
abbrev="SAM"
first_scenario=01_Template


difficulties=Easy,Normal,Hard
 

icon=data/add-ons/Sample/images/bookshelf-full.png
image=portraits/humans/assassin.png
description=_"My first Campaign!"




[/campaign]
Well, the first scenario sure doesn't work ( I don't know why, guess I need an ifdef or something but I still don't understand that part well) and if you could send me the code for difficulty icons it would be great ( and also where to find the icons' names)

gfgtdf
Developer
Posts: 1190
Joined: February 10th, 2013, 2:25 pm

Re: Creating a campaign

Post by gfgtdf » March 26th, 2017, 9:06 pm

Daniel17022002 wrote:I have a little problem , I seem to not be able to put units for the difficulties? (I tried with official examples from the WML pages but nothing happens, only the text.
Adduming you mean the images for difficulcy descptions, this depends on which wesnoth version you use since the syntax has changed in 1.13.x. So if you develop for wewnoth 1.12 i reccomend not bother learning the old syntax descptions syntax and instead focus on creating an actual playable scenario first.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
beetlenaut
Developer
Posts: 2389
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Creating a campaign

Post by beetlenaut » March 27th, 2017, 7:01 pm

Daniel17022002 wrote:I need an ifdef or something
You should use an #ifdef, but it's actually only necessary for making the campaign play well with others. What you didn't do is tell the game where your scenario is. You need a line like this: {~add-ons/Sample/scenarios} pointing to the folder where you put the scenario .cfg. "~add-ons" is a code that specifies the normal add-ons folder, wherever that is on the system. The curly braces mean "put all this stuff here", which in the context of a _main.cfg basically means "load this". You will eventually need lines like that for other folders too like custom units and macros.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
Daniel17022002
Posts: 53
Joined: November 22nd, 2015, 3:54 pm
Location: Romania,Bucharest

Re: Creating a campaign

Post by Daniel17022002 » March 27th, 2017, 7:22 pm

thanks a ton! now I actually should get learning about the scenario.cfg file, the macros and ifdef :hmm:

Post Reply