Hints wanted for Wesnoth Markup Language (WML).

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.
pedros
Posts: 15
Joined: April 19th, 2018, 4:12 am

Hints wanted for Wesnoth Markup Language (WML).

Post by pedros » April 19th, 2018, 4:23 am

Hints wanted for Wesnoth Markup Language (WML).
I have linux, debian 9.3, which has Battle for Wesnoth v1.12.6. I start campaign play at difficulty level 1. At the end of the campaign, I have many good units. I would like to replay the campaign at difficulty level 2, using the units left over from difficulty level 1. Then I would like to replay the campaign at difficulty level 3, using the units left over from difficulty level 2. I am trying to adjust the game code to do this.

And there are some logical storyline problems, like units swithcing sides and terrain changing. Maybe I can simply omit those scenarios.
Specifically, I am working on the campaign Heir_To_The_Throne.

wesnoth.org has this tutorial, it is not complete. I tried it. WML for Complete Beginners - The Battle for Wesnoth Wiki.html. For my purpose, I think it is better to adjust the published code, rather than program everything from scratch. And as the tutorial is not complete, I would have to refer to the published code anyway.

I tried this as a test. It works. Replace "next_scenario=02_Blackwater_Port" with "next_scenario=03_The_Isle_of_Alduin". Then restore the text.

I tried this as a test. It does not work. Rename 23_Test_of_the_Clans.cfg to 03_The_Isle_of_Alduin.cfg. After I played Blackwater_Port, error general: Unknown scenario: '03_The_Isle_of_Alduin'

And that is as far as I got, at the time of this writing. Has someone tried this before? Hints and help are appreciated.
I have another thread related to this project, Command line examples wanted.

User avatar
The_Gnat
Posts: 1529
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by The_Gnat » April 19th, 2018, 6:41 am

I don't exactly understand what you are trying to do so perhaps you could be more specific on what your goal is?

If you rename a scenario you must also change the id as well in order for it to work properly.

For example:

Code: Select all

id=03_The_Isle_of_Alduin

-> CHANGE ->

id=23_Test_of_the_Clans.cfg
In order to replay a campaign with old units the fastest way may instead be to copy your units.

1. First go into your preferences > advanced > compress saved games and set it to NO.

2. Go to your old campaign (with the units) and save it again (now uncompressed)

3. Then restart the campaign with difficulty level 2 and save the restarted campaign

4. Then go find your saved game (in windows it is under Documents/My Games/Wesnoth/Saves/)

5. Then open your old saved game (with the units) with a text editor and find the code [side] and then make sure it is side=1 (it should say that nearby)

6. Then find your units. They will be somewhere after the [side] and before the code [/side]. They will say [unit]. Copy all of the units (which is all the code after the line [unit])

7. Paste all the units into the new saved game after the [side] code for your side (side=1)

Hopefully this helps! :D


pedros
Posts: 15
Joined: April 19th, 2018, 4:12 am

How to hard code the difficulty level into each file?

Post by pedros » April 19th, 2018, 10:33 pm

I followed this hint from The_Gnat. From the origional install, I renamed the file 23_Test_of_the_Clans.cfg to 03_The_Isle_of_Alduin.cfg. Then I changed the line from id=23_Test_of_the_Clans.cfg to id=03_The_Isle_of_Alduin. So the file name should be similar to that line of text inside the file. It now works. Thank you.

The campaign Heir_To_The_Throne has 25 scenarios. By copying and renaming the files, and assigning difficulty levels to each, that should do what I want. 25x3=75. That sounds direct and easy. Or is there a way to loop back to a scenario, and assign another difficulty level with each loop?

Using this method, I see 4 things to change in each file:
Filename.
The line of text: id=01_The_Elves_Besieged
The line of text: next_scenario=02_Blackwater_Port
Hard code the difficulty level into each file. (how to do?)
Then there are the logical storyline problems I mentioned, and the ending credits.

The_Gnat also gave me 7 steps to manually edit the saved files. Thank you for the steps, but for now I will try my hard code idea.

Ravana gave me a link that is relavant to this topic. I like it, but for now I will try my hard code idea.
From that link, Dugi says
take veterans from one campaign and start another campaign with them. I've coded it and published it to the add-ons server.
Jabie says
There are a couple of places where this would be great. Taking Konrad from the tutorial straight into the first scenario of Heir to the Throne is a pretty obvious one and wouldn't be unbalancing.
Here is some documentation I found. But what code should I insert?
https://wiki.wesnoth.org/CampaignWML https://wiki.wesnoth.org/SavefileWML difficulties: The symbols EASY, NORMAL, and HARD are usually used, This key has been deprecated in favor of [difficulty] define=. difficulty_descriptions: the menu of difficulties;

User avatar
zookeeper
WML Wizard
Posts: 9717
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by zookeeper » April 19th, 2018, 11:05 pm

You don't need to rename files. Filenames usually have no significance.

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

Re: How to hard code the difficulty level into each file?

Post by beetlenaut » April 20th, 2018, 12:43 am

pedros wrote:
April 19th, 2018, 10:33 pm
Hard code the difficulty level into each file. (how to do?)
You can't really. The difficulty levels are used to select values to put in the save file when it is first created. (Values like gold, turn limit, enemy types, AI parameters, etc.) You would have to change all of them, which is not really practical.

The_Gnat's instructions take care of that as well as the story line problems, and you only have to modify one file. I recommend following them. (But I would add: step 8: reset "preferences > advanced > compress saved games" to its original value.)
pedros wrote:
April 19th, 2018, 10:33 pm
The symbols EASY, NORMAL, and HARD are usually used, This key has been deprecated in favor of [difficulty] define=. difficulty_descriptions
This is not relevant for a save file.
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

pedros
Posts: 15
Joined: April 19th, 2018, 4:12 am

Almost done.

Post by pedros » April 20th, 2018, 2:24 pm

Thank you all for your hints. Using them, I created a bash file to make 2 copies of each senario, and rename the files. I like this method because everything is easily set up before the game starts. I tested it by playing the first senerio, and entering the next senerio. I ignore difficulity level for now. In theory, the campain can be played through, then played a second time, using vetrain units from the first time. And with a little more programing, do it again. Bash file is wbash2.txt, I will try to upload it as attachment. It currently only works for my system, but can probably be adjusted.

To zookeeper. For my method, I do need to rename the files, because I have more files than the origional amount.
One request. Can someone file a bug report about incorrect documentation? That process seems too involved for me.
One question. How to mark this thread as solved? But not quite yet.
I tried to upload, but could not. If anyone wants the bash file, please tell me how to upload it.

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

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by beetlenaut » April 20th, 2018, 7:30 pm

pedros wrote:
April 20th, 2018, 2:24 pm
Can someone file a bug report about incorrect documentation?
What documentation is incorrect?
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

pedros
Posts: 15
Joined: April 19th, 2018, 4:12 am

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by pedros » April 21st, 2018, 3:43 pm

In the link Ravana gave me, "Move units between campaigns", Dugi says
I've coded it and published it to the add-ons server.
So I went to "Wesnoth 1.12 Add-ons List". I would like to download everything from that page. How? In there, which is the work from Dugi?

For discussion about the documentation problem, see the thread "Command line examples wanted." technical support. https://forums.wesnoth.org/viewtopic.php?f=4&t=48009

This project is going well. I am now ready to edit the senerio files to mimic difficulity levels. beetlenaut says
The difficulty levels are used to select values to put in the save file
Please give me details. For each difficulity level, What values are changed to what? I think some of this would be easy to do with a debian bash file. And I do not need to be exact.

To The_Gnat. I am not going in the direction you suggested, but thank you for your input. My goal is to edit the senerio files before the game starts. And with your help, I have done that. I am now trying to make more detailed changes to the files. I run a debian bash file to make all these changes.

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

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by beetlenaut » April 21st, 2018, 6:32 pm

pedros wrote:
April 21st, 2018, 3:43 pm
Please give me details. For each difficulity level, What values are changed to what?
I can't tell you that because there is no system or pattern. The scenario author can make any changes for any difficulty level. The only way to know is to inspect the original scenario file (not the save file) and see what it says. Here are just a few examples of what the relevant lines might look like. None of this is visible in the save file. Only the final values chosen by these macros and commands are visible.

Code: Select all

{TURNS 32 29 25}

{GOLD 230 190 110}

    [set_variable]
        name=number_of_spiders
#ifdef EASY
            value=4
#endif
#ifdef NORMAL
            value=5
#endif
#ifdef HARD
            value=6
#endif
    [/set_variable]

#ifndef HARD
    [terrain]
        x,y=28,7
        terrain=Xu
    [/terrain]
#endif

#ifdef EASY
    {LIMIT_CONTEMPORANEOUS_RECRUITS 2,3 (Orcish Crossbowman) 4}
#endif

    [unit]
#ifdef EASY
        type=Naga Fighter
#else
        type=Naga Warrior
#endif
        id=Xnamas
        name= _ "Xnamas"
        x,y=2,10
        side=2
    [/unit]

#ifdef EASY
        recruit=Skeleton,Revenant,Blood Bat,Ghost,Bone Shooter
#endif
#ifdef NORMAL
        recruit=Skeleton,Revenant,Chocobone,Blood Bat,Wraith,Bone Shooter,Dark Adept
#endif
#ifdef HARD
        recruit=Skeleton,Revenant,Chocobone,Wraith,Bone Shooter,Dark Adept
#endif
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

Shiki
Developer
Posts: 194
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by Shiki » April 26th, 2018, 4:31 pm

Similar to The_Gnats explanation you could:
- change the next_scenario key in the savefile.
- finish the scenario, start the next, then open the load game dialogue to load the freshly created start of scenario save, but check the change difficulty option.

It will probably still lead to issues if you and the enemy has a Li'sar, you can change the id key of one of the units to overcome that.
When editing savefiles, nearly the half of the file is for the savegame data, and an equally big part for the replay data - edit the right place.
Maintainer of Era of Myths.

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

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by gfgtdf » April 26th, 2018, 5:32 pm

You can also change next_scenario directly in the start of scenario save
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.

pedros
Posts: 15
Joined: April 19th, 2018, 4:12 am

Done. Thank you.

Post by pedros » May 12th, 2018, 2:46 am

I did this. rpl is the command to replace text.

Code: Select all

rpl "next_scenario=25_HttT_Epilogue" "next_scenario=01_The_Elves_Besieged" /usr/share/games/wesnoth/1.12/data/campaigns/Heir_To_The_Throne/24_Battle_for_Wesnoth.cfg
rpl "carryover_report=no" "" /usr/share/games/wesnoth/1.12/data/campaigns/Heir_To_The_Throne/24_Battle_for_Wesnoth.cfg
rpl "save=no" "" /usr/share/games/wesnoth/1.12/data/campaigns/Heir_To_The_Throne/24_Battle_for_Wesnoth.cfg
This makes the campaign repeat itself. In other words, After the end of the last secerio, the first senerio starts again. And all units are carried over.
Here are some side effects. When a new unit is automatically introduced to be under full user control, everything about the old unit is deleted. Li'sar, after being obtained, can be recalled anytime, even when the enemy Li'sar is present.
Simple. Only 3 lines are changed. I ignore difficulity levels. I do not copy or rename files.
Thank you, that was educational. I repeat one question. How to download everything from "Wesnoth 1.12 Add-ons List"? I would like one zip file, if not too big.

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

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by beetlenaut » May 12th, 2018, 5:45 am

pedros wrote:
May 12th, 2018, 2:46 am
I repeat one question. How to download everything from "Wesnoth 1.12 Add-ons List"?
The game doesn't provide a way to do that, but the add-ons are available at http://addons.wesnoth.org/1.12. You could use a download manager to download every link on that page that goes to a bz2 file. However, you should probably use 1.14 now because that is the current version, and some of the 1.12 content won't work with it. I don't know how big all of the add-ons would be together, but probably huge.
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

pedros
Posts: 15
Joined: April 19th, 2018, 4:12 am

Re: Hints wanted for Wesnoth Markup Language (WML).

Post by pedros » May 12th, 2018, 3:43 pm

Now going off topic. I have two computers. One with internet connection, the other one to play wesnoth offline, against AI. I moved my mouse over the page at http://addons.wesnoth.org/1.12., but could not find any links. I remember using a program named wget. Will that work?

Post Reply