Graziani WML Questions

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
Graziani
Posts: 96
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Hello guys,

I'm finishing my 23 lvl troll campaign and i'm stuck on 2 important points, i would like some assistance.

I) : Veteran problem

First, because it's a long campaign and a lot of different events happen to the player leader, from the level 17 to the end of the campaign, the player is UNABLE to recall veteran units. It's possible from the level 18 to recruit the new veterans born in the 17, but all veterans from lvl 1 to 16 just disapeard.

So, in my story, in the level 16, the player leader unit change. And i'm sure everything come from this.

In LVL 16, a secondary character, Crolog, is in charge of the player army. He is able to recruit, and in the following level he come back to his normal hero status. No problem about that. During this time, the leader from lvl 1 is set aside with another hero character (Godug and Darlasan).

Godug is the main leader unit from the begining of the campaign.

I wrote like this :


Code: Select all


[side]
id=Godug
side=1
team_name=1
facing=sw
canrecruit=yes
controller=human
recruit=FRAB Troll Whelp,FRAB Troll Bowler,FRAB Troll Initiate,FRAB Troserker
team_name=trolls
user_team_name=_"Great United Clan"
gold=200
shroud=yes
fog=yes
{INCOME 7 7 7}

[/side]


Code: Select all

       
            
     [event]

name=start

#dialogue starts

        [modify_unit]
        [filter]
id=Crolog
[/filter]
canrecruit=yes
        {IS_HERO}
        [/modify_unit]

        [store_unit]
            [filter]
                id=Darlasan
            [/filter]
            kill=yes
            animate=no
            variable=stored_Darlasan
        [/store_unit]

        [store_unit]
            [filter]
                id=Godug
            [/filter]
            kill=yes
            animate=no
            variable=stored_Godug
        [/store_unit]
        
        
So I stored Godug and Darlasan in the start event.

Code: Select all



[event]

name=victory


        [modify_unit]
        [filter]
id=Crolog
[/filter]
canrecruit=no
        {IS_HERO}
        [/modify_unit]

        [store_unit]
            [filter]
                id=Crolog
            [/filter]
            kill=yes
            animate=no
            variable=stored_Crolog
        [/store_unit]

        [store_unit]
            [filter]
                id=Firag
            [/filter]
            kill=yes
            animate=no
            variable=stored_Firag
        [/store_unit]


        [unstore_unit]
variable=stored_Godug
                    x,y=52,21
        [/unstore_unit]

        {CLEAR_VARIABLE stored_Godug}

        [unstore_unit]
variable=stored_Darlasan
x,y=51,21
        [/unstore_unit]

        {CLEAR_VARIABLE stored_Darlasan}


        [unstore_unit]
variable=stored_Crolog
                    find_vacant=no
        [/unstore_unit]

        {CLEAR_VARIABLE stored_Crolog}

        [unstore_unit]
variable=stored_Firag
                    find_vacant=no
        [/unstore_unit]

        {CLEAR_VARIABLE stored_Firag}




[endlevel]
result=victory
bonus=yes
{NEW_GOLD_CARRYOVER 40}
[/endlevel]


[/event]

And i remove the leader status from Crolog to Godug in the victory event. I make Godug appear somewhere in a non viewable part of the map.

So, i think my code is pretty messy... And in the end Godug cannot recruit his past veterans in the following level. They are all gone in the void.



II) Veterans again !

In the level 22, the player is supposed to be unable to recruit units. BUT he is still supposed to call back veterans that are following him from the beginning of the campaign.

But the problem is that it doesn't work. Player can recruit new and veteran units.

So , to fix it, i tried :

in the side tag, i wrote this :

Code: Select all

canrecruit=yes

(But i didn't wrote what the leader can recruit. i just didn't wrote this line.)

I even wrote this to check what happen :

Code: Select all

[modify_unit]
            [filter]
                id=Godug
            [/filter]
canrecruit=no
[/modify_unit]

But it changed nothing.

Voilà voilà !

Thank you in advance for your precious help.
Currently on goblin campaign "A goblin adventure" (available) and troll campaign "From Rocks and Blood"(not available yet)

User avatar
octalot
Developer
Posts: 457
Joined: July 17th, 2010, 7:40 pm

Re: Graziani WML Questions

Post by octalot »

A persistent side doesn't need to appear in all scenarios, so you can have two sides and swap between them. SideWML uses the save_id, which defaults to the leader's id. Take the most recently added campaign (SotA) as an example; as it's the most recently added I'm assuming it has the cleanest code, and SotA's code is nicely commented.

Start with utils/sota-utils.cfg. Scenarios 1-7 use SIDE_1_ARDONNA (or the _EARLY version), scenarios 8-10 use SIDE_1_RAS-TABAHN, scenarios 11-12 use SIDE_1_ARDONNA and scenario 13 uses SIDE_1_BOTH. SIDE_1_BOTH uses the same save_id as SIDE_1_ARDONNA.

The veterans from Ras-Tabahn's scenarios are stored in scenario 10's "enemies defeated", and then put on to Ardonna's recall list in scenario 13's "prestart".

Edit: I'd written side_id instead of save_id.
Last edited by octalot on May 24th, 2019, 7:24 pm, edited 1 time in total.

User avatar
sergey
Posts: 439
Joined: January 9th, 2015, 9:25 pm

Re: Graziani WML Questions

Post by sergey »

octalot, by side_id you meant save_id?

Graziani take a look at save_id documentation here https://wiki.wesnoth.org/SideWML
Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.

User avatar
Graziani
Posts: 96
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

A persistent side doesn't need to appear in all scenarios, so you can have two sides and swap between them. SideWML uses the side_id, which defaults to the leader's id. Take the most recently added campaign (SotA) as an example; as it's the most recently added I'm assuming it has the cleanest code, and SotA's code is nicely commented.

Start with utils/sota-utils.cfg. Scenarios 1-7 use SIDE_1_ARDONNA (or the _EARLY version), scenarios 8-10 use SIDE_1_RAS-TABAHN, scenarios 11-12 use SIDE_1_ARDONNA and scenario 13 uses SIDE_1_BOTH. SIDE_1_BOTH uses the same side_id as SIDE_1_ARDONNA.

The veterans from Ras-Tabahn's scenarios are stored in scenario 10's "enemies defeated", and then put on to Ardonna's recall list in scenario 13's "prestart".
Graziani take a look at save_id documentation here https://wiki.wesnoth.org/SideWML
Ok it's perfect for me i'm gonna work with SotA code and i'll let you know how i progress. Thanks for that.

And about my second problem, i don't think i can fix it by using the same code ? I think it's a simple code to use but i cannot figure what is wrong in my situation.
In the level 22, the player is supposed to be unable to recruit units. BUT he is still supposed to call back veterans that are following him from the beginning of the campaign.

But the problem is that it doesn't work. Player can recruit new and veteran units.
How can i disallow the possibility to recruit new units and keep recruiting veterans in same time ?
Currently on goblin campaign "A goblin adventure" (available) and troll campaign "From Rocks and Blood"(not available yet)

User avatar
Ravana
Forum Moderator
Posts: 2312
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Graziani WML Questions

Post by Ravana »

Edit recruitable unit types list.

User avatar
Graziani
Posts: 96
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

And about my second problem, i don't think i can fix it by using the same code ? I think it's a simple code to use but i cannot figure what is wrong in my situation.
In the level 22, the player is supposed to be unable to recruit units. BUT he is still supposed to call back veterans that are following him from the beginning of the campaign.

But the problem is that it doesn't work. Player can recruit new and veteran units.
How can i disallow the possibility to recruit new units and keep recruiting veterans in same time ?
Actually, i think i can fix all these problems thanks to the wiki page. Sorry for that and thanks again
Currently on goblin campaign "A goblin adventure" (available) and troll campaign "From Rocks and Blood"(not available yet)

User avatar
sergey
Posts: 439
Joined: January 9th, 2015, 9:25 pm

Re: Graziani WML Questions

Post by sergey »

recruit key under the side tag doesn't override the recruit list, it only adds new available unit types. In order to clear the recruit list put this command in the prestart event https://wiki.wesnoth.org/DirectActionsW ... recruit.5D

For example, this code completely clears the recruit list for side 1.

Code: Select all

[disallow_recruit]
  side=1
[/disallow_recruit]
P.S.
Detailed explanation of "recruit key under the side tag doesn't override the recruit list"
recruit documentation says: "At the beginning of the scenario, the side gains recruitment of these units."
save_id documentation says: "save_id is used to carry over the side's recall list (including the side's leader), recruitment list, and starting gold from scenario to scenario"
In the other words, side will be able to recruit Unit_Type_X even if it is not listed in recruit key, but was available in the previous scenario for that side (side with the same save_id). If you are not specifying recruit key at all it is the same as empty recruit list. Still the side will be able to recruit all units it was able to recruit in the previous scenario as I described above.
Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.

User avatar
James_The_Invisible
Posts: 519
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: Graziani WML Questions

Post by James_The_Invisible »

sergey wrote:
May 23rd, 2019, 1:05 pm
For example, this code completely clears the recruit list for side 1.

Code: Select all

[disallow_recruit]
  side=1
[/disallow_recruit]
Nope. disallow_recruit tag requires type attribute with list of unit types which the side no longer allowed to recruit. This way you would have to list all unit types which it currently can recruit (or store the side's recruit list to a variable and use that variable).
You should rather use:

Code: Select all

[set_recruit]
    side=1
    recruit=
[/set_recruit]

User avatar
Graziani
Posts: 96
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

[disallow_recruit]
side=1
type=
[/disallow_recruit]
This code is perfect. So simple. My leader is still able to call back veterans. Thanks a lot it worked perfectly

[set_recruit]
side=1
recruit=
[/set_recruit]
Does it have the same effect ?
Currently on goblin campaign "A goblin adventure" (available) and troll campaign "From Rocks and Blood"(not available yet)

User avatar
sergey
Posts: 439
Joined: January 9th, 2015, 9:25 pm

Re: Graziani WML Questions

Post by sergey »

James_The_Invisible wrote:
May 23rd, 2019, 3:49 pm
sergey wrote:
May 23rd, 2019, 1:05 pm
For example, this code completely clears the recruit list for side 1.

Code: Select all

[disallow_recruit]
  side=1
[/disallow_recruit]
Nope. disallow_recruit tag requires type attribute with list of unit types which the side no longer allowed to recruit.
disallow_recruit wiki says:
type: the types of units that the side can no longer recruit. (Version 1.13.0 and later only) If omitted, all recruits for matching sides will be disallowed
My example is correct for version 1.13.0 and higher.
Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.

User avatar
James_The_Invisible
Posts: 519
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: Graziani WML Questions

Post by James_The_Invisible »

Graziani wrote:
May 23rd, 2019, 4:15 pm
[set_recruit]
side=1
recruit=
[/set_recruit]
Does it have the same effect ?
I use it in my campaign and it does forbid the side from recruiting anything.
sergey wrote:
May 23rd, 2019, 5:54 pm
James_The_Invisible wrote:
May 23rd, 2019, 3:49 pm
sergey wrote:
May 23rd, 2019, 1:05 pm
For example, this code completely clears the recruit list for side 1.

Code: Select all

[disallow_recruit]
  side=1
[/disallow_recruit]
Nope. disallow_recruit tag requires type attribute with list of unit types which the side no longer allowed to recruit.
disallow_recruit wiki says:
type: the types of units that the side can no longer recruit. (Version 1.13.0 and later only) If omitted, all recruits for matching sides will be disallowed
My example is correct for version 1.13.0 and higher.
Ah, right, I missed that part about 1.13.0. So at least I offered an alternative in my previous post :).

User avatar
Graziani
Posts: 96
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

So, in my situation, i'm still kinda lost about my first problem.

I give you more details :

lvl 16 : the original leader from lvl 1 is stored in the prestart event of this level. One heroe is in charge of recruitment with a simple [modify_unit] tag. He lose this ability in the [victory] event.

lvl 17: I unstore the original leader in prestart. All recall units from beginning of the game are gone, including all heroes. Leader is alone and his recall list is empty.

I tried to unstore the leader to fix the problem in the end of lvl 16, in the [victory] tag. Same issue.

So i used save_id.
By the way, i'm not sure if i'm using it properly, should i put it only in lvl 16 to be sure to carry my recall list or do i have to put it in the two scenarios?

I did both of these possibilities, with and without quotes, but it doesn't triggered.

Code: Select all

[side]
{SIDE_1_GODUG_LATE}
save_id="Godug"
shroud=yes
fog=yes
[/side]
Or maybe am i going in a really wrong direction and to fix my problem i should give the status of leader to my heroe in lvl 16 ? I don't know if it have really some effect but i'm wondering
Currently on goblin campaign "A goblin adventure" (available) and troll campaign "From Rocks and Blood"(not available yet)

User avatar
octalot
Developer
Posts: 457
Joined: July 17th, 2010, 7:40 pm

Re: Graziani WML Questions

Post by octalot »

If the save_id isn't declared then it will default to the leader's id; so even if you haven't explicitly declared it in the WML then the save_id is still defined.

I'm confused by the most recent post, because that sounds as if it's what was originally requested. What should be different?

User avatar
sergey
Posts: 439
Joined: January 9th, 2015, 9:25 pm

Re: Graziani WML Questions

Post by sergey »

Graziani, approaches that you described should work. Could you attach your scenario files and util files with macroses?
Author of SP scenario Dragon Fight and SP campaign Captured by a Nightmare.
Created The Rise of Wesnoth (alternative mechanics) version of the mainline campaign.

User avatar
Graziani
Posts: 96
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

I'm confused by the most recent post, because that sounds as if it's what was originally requested. What should be different?
Yes i'm asking again because i didn't solve my problem. My second question about disallow recruiting veterans is answered, it was very simple and i'm sorry because i could have find out how to fix my problem thanks to the wiki.
But my first problem seems to be more complicated to me, for several reasons; the main one is that i never used save_id and it's not clear to me how to manipulate it. I tried what was proposed to me, but i couldn't succeed...
Graziani, approaches that you described should work. Could you attach your scenario files and util files with macroses?
Here are parts of the two scenarios (i just cutted all dialogs and moveto or turn events i putted). I will put all if necessary in attached files.



Utils :

Code: Select all

#textdomain wesnoth-frab


#define SIDE_1_GODUG_EARLY
side=1
controller=human
team_name=trolls
user_team_name=_"Trolls"
type=Godug
id=Godug
profile=portraits/godug.png
gender=male
name= _ "Godug"
canrecruit=yes
recruit=FRAB Troll Whelp
#enddef

#define SIDE_1_GODUG_MID
side=1
controller=human
team_name=trolls
user_team_name=_"Great United Clan"
type=Godug
id=Godug
profile=portraits/godug.png
gender=male
name= _ "Godug"
canrecruit=yes
recruit=FRAB Troll Whelp,FRAB Troll Bowler
#enddef

#define SIDE_1_GODUG_LATE
side=1
controller=human
team_name=trolls
user_team_name=_"Great United Clan"
type=Godug
id=Godug
profile=portraits/godug.png
gender=male
name= _ "Godug"
canrecruit=yes
recruit=FRAB Troll Whelp,FRAB Troll Bowler,FRAB Troll Initiate,FRAB Troserker
#enddef



LVL 16 :

Three secondary characters were stored in lvl 15 and are unstored in lvl 16 (Crolog,Eirur and Firag)
In the same time i store my main leader.

Code: Select all


#textdomain wesnoth-frab

[scenario]

id=16_Crevasses
next_scenario=17_Fin
 
name=Les Crevasses Spectrales
map_data="{~add-ons/From_rocks_and_blood/maps/16_Crevasses.map}"
{TURNS 45 40 35}
victory_when_enemies_defeated=no

{INTRO_AND_SCENARIO_MUSIC "loyalists.ogg" "knolls.ogg"}
{EXTRA_SCENARIO_MUSIC "the_city_falls.ogg"}
{EXTRA_SCENARIO_MUSIC "knalgan_theme.ogg"}

{UNDERGROUND}

{STORY_CREVASSES}
 


[side]
{SIDE_1_GODUG_LATE}
x=1
y=1
shroud=yes
save_id="Godug"
fog=yes
#ifdef NORMAL
gold=120
#endif
#ifdef HARD
gold=100
#endif
[/side]


[side]

id=goblin161
type=Goblin Impaler
canrecruit=yes
side=2
controller=ai
shroud=no
fog=no
team_name=gob
user_team_name=_"Goblins"

        [ai]
          recruitment_pattern=archer,fighter,fighter,fighter,fighter
          recruitment_ignore_bad_combat=yes
          recruitment_ignore_bad_movement=yes
        [/ai]


    #ifdef NORMAL
     gold=100
    #endif

    #ifdef HARD
     gold=150
    #endif
    recruit=Goblin Rouser,Goblin Spearman,Goblin Impaler,FRAB Bladesman,FRAB Goblin Archer,Giant Spider

[/side]




[event]

name=prestart


        [store_unit]
            [filter]
                id=Godug
            [/filter]
            kill=yes
            animate=no
            variable=stored_Godug1
        [/store_unit]
        
        		
[recall]
id=Darlasan
{IS_HERO}
x,y=1,1
[/recall]

        [store_unit]
            [filter]
                id=Darlasan
            [/filter]
            kill=yes
            animate=no
            variable=stored_Darlasan1
        [/store_unit]
		
[recall]
id=Eirur
x,y=1,1
[/recall]

        [store_unit]
            [filter]
                id=Eirur
            [/filter]
            kill=yes
            animate=no
            variable=stored_Eirur1
        [/store_unit]

        [unstore_unit]
variable=stored_Crolog1
            x,y=3,3
        [/unstore_unit]

[redraw]
[/redraw]

{CLEAR_VARIABLE stored_Crolog1}


        [unstore_unit]
variable=stored_Kogue1
            x,y=6,4
        [/unstore_unit]

[redraw]
[/redraw]

{CLEAR_VARIABLE stored_Kogue1}

        [unstore_unit]
variable=stored_Firag1
            x,y=4,2
        [/unstore_unit]

[redraw]
[/redraw]

{CLEAR_VARIABLE stored_Firag1}



[item]
x,y=30,14
image=items/prisonner.png
[/item]

[item]
x,y=28,14
image=items/prisonner1.png
[/item]

[/event]


[event]

name=start


[modify_unit]
[filter]
id=Crolog
[/filter]
canrecruit=yes
{IS_HERO}
[/modify_unit]



[/event]




[event]

name=victory


[modify_unit]
[filter]
id=Crolog
[/filter]
canrecruit=no
{IS_HERO}
[/modify_unit]
		
		
[endlevel]
result=victory
bonus=yes
{NEW_GOLD_CARRYOVER 40}
[/endlevel]


[/event]




[/scenario]

LVL 17 :

And here my Leader appears alone with empty recall list.

Code: Select all


#textdomain wesnoth-frab

[scenario]

id=17_Fin
next_scenario=18_Demons
 
name=La Fin des Gobelins
map_data="{~add-ons/From_rocks_and_blood/maps/17_Fin.map}"
{TURNS 50 45 40}
victory_when_enemies_defeated=yes

{INTRO_AND_SCENARIO_MUSIC "revelation.ogg" "loyalists.ogg"}
{EXTRA_SCENARIO_MUSIC "the_dangerous_symphony.ogg"}
{EXTRA_SCENARIO_MUSIC "casualties_of_war.ogg"}
{EXTRA_SCENARIO_MUSIC "battle-epic.ogg"}
{EXTRA_SCENARIO_MUSIC "weight_of_revenge.ogg"}


{UNDERGROUND}

{STORY_FIN}
 
[side]
{SIDE_1_GODUG_LATE}
x=6
y=25
save_id="Godug"
facing=sw
shroud=yes
fog=yes
#ifdef NORMAL
gold=200
#endif
#ifdef HARD
gold=160
#endif
[/side]

[side]

no_leader=yes
side=2
controller=ai
shroud=no
fog=no
gold=0
income=0
team_name=gob
user_team_name=_"Goblins"

        [ai]
          recruitment_pattern=archer,fighter,fighter,archer,fighter
          recruitment_ignore_bad_combat=yes
          recruitment_ignore_bad_movement=yes
        [/ai]


    #ifdef NORMAL
     gold=250
    #endif

    #ifdef HARD
     gold=300
    #endif
    recruit=Goblin Rouser,Goblin Spearman,Goblin Impaler,FRAB Bladesman,FRAB Goblin Archer,Giant Spider

[/side]




[event]

name=prestart

{VARIABLE standing_count 0}

[unstore_unit]
variable=stored_Godug1
x,y=6,25
[/unstore_unit]

[redraw]
[/redraw]

{CLEAR_VARIABLE stored_Godug1}



[unstore_unit]
variable=stored_Darlasan1
x,y=7,24
[/unstore_unit]

[redraw]
[/redraw]

{CLEAR_VARIABLE stored_Darlasan1}


[unstore_unit]
variable=stored_Eirur1
x,y=10,26
[/unstore_unit]

[redraw]
[/redraw]

{CLEAR_VARIABLE stored_Eirur1}

[recall]
id=Firag
{IS_HERO}
x,y=6,27
facing=sw
[/recall]

[recall]
id=Crolog
{IS_HERO}
x,y=3,25
facing=sw
[/recall]

[recall]
id=Kogue
name= _ "Kogue"
x,y=3,26
facing=sw
[/recall]

[capture_village]
x=27
y=20
side=1
[/capture_village]


[/event]

[/scenario]	
Currently on goblin campaign "A goblin adventure" (available) and troll campaign "From Rocks and Blood"(not available yet)

Post Reply