Learning to add Terrain to the game

The place to post your WML questions and answers.

Moderator: Forum Moderators

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.
rubberduck
Posts: 40
Joined: August 25th, 2013, 12:50 pm

Learning to add Terrain to the game

Post by rubberduck »

i want to learn how to add self-made terrain into the game, how to code it, where can i find something that shows how to do this

which files do i need for this
i made some graphics and i want to see, how it looks in the game, but i don't know how i can add them
User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Learning to add Terrain to the game

Post by Dugi »

I coded some terrains (some ice caves, but they didn't look as good as yours, I think I'll use your instead) by copying the macros than generate them from core/terrain_graphics.cfg and the defining WML from core/terrain.cfg. It worked quite well in most cases.

The macros that are used to create them appeared extremely complex to me, so I didn't go much into depth of the code for terrain graphics.
rubberduck
Posts: 40
Joined: August 25th, 2013, 12:50 pm

Re: Learning to add Terrain to the game

Post by rubberduck »

how easy is it to code terrain (with good transitions)
how much time does it take to learn coding
and what are the macros exactly for
User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Learning to add Terrain to the game

Post by Dugi »

I found it extremely complicated to understand the macros for terrain graphics, and additionally I learned that they are put together by a python script, making them almost unreadable for humans. So, I strongly suggest you not to try to understand it.
But learning to use these macros is relatively easy, you just find how is a similar terrain coded (for example cave terrain's code name is Xu, so find all mentions of the Xu terrain in core/terrain_graphics.cfg), copy it and alter it to fit your terrain, changing the name of the terrain and name of images. It's quite easy. Coding the terrain function itself is trivial (self-explanatory in core/terrain.cfg).

I am not perfectly sure what did you mean with how much time does it take to learn coding, do you mean that you don't know to code wesnoth stuff at all or that you want to learn to code terrains?
rubberduck
Posts: 40
Joined: August 25th, 2013, 12:50 pm

Re: Learning to add Terrain to the game

Post by rubberduck »

i mean only coding terrain-graphics
User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Learning to add Terrain to the game

Post by Dugi »

Okay, that's better. Learning it to depth seems hard to me, but basic usage isn't hard. I learned it in the way I described above, I don't know to define terrains with absolutely new kinds of transitions, but I can make a terrain behaving similarly than some other terrain (and you seem to want this).
User avatar
Pentarctagon
Project Manager
Posts: 4510
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Learning to add Terrain to the game

Post by Pentarctagon »

Moved to the WML Workshop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
rubberduck
Posts: 40
Joined: August 25th, 2013, 12:50 pm

Re: Learning to add Terrain to the game

Post by rubberduck »

in the first step i want to learn more about the terrain.cfg and the terrainWML
i read http://wiki.wesnoth.org/TerrainWML and i have some questions

which use has the aliasof key, what , what does the + and - here
what happens when i use a graphic that uses the same string-value that is used by an other (installed) addon
User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Learning to add Terrain to the game

Post by Dugi »

Aliasof key represents what type of terrain it is, like impassable, flat, etc. Use _bas if it is supposed to be no terrain (like an overlay with no effect on the terrain).
The + and - signs tell how will the defences stack, + means that the better of the two defences applies, for example a village in cave gives 60% defence to elves and not 30% defence that cave gives normally to elves, and - means that the worse of the two defences applies, like merman villages that give only 20% defence (the defence in shallow water) to humans, even if they normally get 60% defence in villages. The + sign is more common.
If a string has the same string value as another terrain in another add-on, it chooses one of them, but I am not sure which one, all I know is that both IftU and AtS had some common custom terrains, and it just threw a warning into stderr.txt.
User avatar
Heindal
Posts: 1071
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Learning to add Terrain to the game

Post by Heindal »

I personally found it easy to create terrain, once you created a single piece - the rest is a lot of copy and paste but there are also some dead ends/problems you have to look for.

These two threads should tell you everything that you need to know. You could also check examples - any of my campaigns (except for trapped) or World of Wesnoth.

http://forums.wesnoth.org/viewtopic.php?f=21&t=21333

http://forums.wesnoth.org/viewtopic.php?f=21&t=39155

I still have to look into the coding of animated terrain, but it is possible too.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses
rubberduck
Posts: 40
Joined: August 25th, 2013, 12:50 pm

Re: Learning to add Terrain to the game

Post by rubberduck »

i made the first steps for adding graphics into the game, now i have my first terrain in the editor, i can select it and i see an image in the editor, but when i want to add the new terrain into the map, i can't see anything.

what could i do now?

and i have a small question:
in http://forums.wesnoth.org/viewtopic.php?f=21&t=39155 i read something like this
{TERRAIN_BASE Ymm terrain/mine}

what does TERRAIN_BASE mean, which use has it?
Attachments
Testgraphics1.tar.gz
(20.05 KiB) Downloaded 81 times
Wussel
Posts: 623
Joined: July 28th, 2012, 5:58 am

Re: Learning to add Terrain to the game

Post by Wussel »

Talking from memory.

There are 2 things terrain.cfg defines the terrain i.e. alias of and grouping for editor and such (you got this one right). terrain graphics.cfg displays the terrain i.e. rules about layers and transitions (you might have missed this one).

terrain base is for terrains graphics which use an overlay i.e. bridge on water or village on grass. The base is the lower "standard" terrain.
rubberduck
Posts: 40
Joined: August 25th, 2013, 12:50 pm

Re: Learning to add Terrain to the game

Post by rubberduck »

in my first step i wanted to add the terrain to the selectable terrain in the sidebar, now i want to learn, how to make them appear in the game and to add transitions
User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Learning to add Terrain to the game

Post by Dugi »

Making them appear in the game is easy, just make it load not only in the case if EDITOR is defined, but also when your campaign's define is defined.

Adding transititions is very hard. Here you can learn it, but because I don't know it, I can't assure you if there is everything you need.
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Learning to add Terrain to the game

Post by 8680 »

Alarantalara’s Custom Terrain Tutorial may be helpful, though it’s a bit old.
Post Reply