Enemy Leader appear one after another

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.
Post Reply
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Enemy Leader appear one after another

Post by Kal_Ultor »

Hi,
How can I do the following:
All enemy Leader appear one after another. So: Player 1(human) kills Player 2, than Player 3 appears, after that is killed Player 4 and so on.

Code: Select all

#textdomain wesnoth-orc_campaign
[scenario]
    id=try_outs
    next_scenario=null
    name=_"Try Outs"
    map_data="{~add-ons/orc_campaign/maps/try_outs_map.map}"
    turns=30
    [side]
        side=1
        controller=human
        team_name="good"
        user_team_name= _ "My Team"
        id=MyLeader
        name= _ "Sabo"
        type="Orcish Leader"
        unrenamable=yes
        canrecruit=yes
        recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman, Naga Fighter"
        gold=150
    [/side]
    [side]
       side=2
       controller=ai
       team_name="bad2"
       user_team_name= _ "Bad Guys 2"
       id=EnemyLeader2
       name= _ "Pragdush"
       type= "Orcish Leader"
       unrenamable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=50
    [/side]
    [side]
       side=3
       controller=ai
       team_name="bad3"
       user_team_name= _ "Bad Guys 3"
       id=EnemyLeader3
       name= _ "Rigro"
       type= "Goblin Knight"
       unrenamable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=50
    [/side]
    [side]
       side=4
       controller=ai
       team_name="bad4"
       user_team_name= _ "Bad Guys 4"
       id=EnemyLeader4
       name= _ "Domag"
       type= "Orcish Slayer"
       unrenamable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=50
    [/side]
    [side]
       side=5
       controller=ai
       team_name="bad5"
       user_team_name= _ "Bad Guys 5"
       id=EnemyLeader5
       name= _ "Azgo"
       type= "Orcish Crossbowman"
       unrenamable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=50
    [/side]
    [side]
       side=6
       controller=ai
       team_name="bad6"
       user_team_name= _ "Bad Guys 6"
       id=EnemyLeader6
       name= _ "Vunu"
       type= "Orcish Warrior"
       unrenamable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=50
    [/side]
    [side]
       side=7
       controller=ai
       team_name="bad7"
       user_team_name= _ "Bad Guys 7"
       id=EnemyLeader7
       name= _ "Xasal"
       type= "Naga Myrmidon"
       unrenamable=yes
       canrecruit=yes
       recruit="Naga Fighter"
       gold=50
    [/side]
    [event]
        name=start
        [message]
            speaker=MyLeader
            message= _ "I will prove myself worthy!"
        [/message]
        [message]
            speaker=EnemyLeader2
            message= _ "Grrrr!"
        [/message]
        [objectives]
            [objective]
                description= _ "Defeat the enemy leader"
                condition="win"
            [/objective]
            [objective]
                description= _ "Death of your leader"
                condition="lose"
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition="lose"
             [/objective]
        [/objectives]
    [/event]
[/scenario]
Attachments
Try_outs.png
User avatar
Straff
Posts: 86
Joined: September 27th, 2020, 2:53 pm

Re: Enemy Leader appear one after another

Post by Straff »

Use no_leader=yes
The side definitions for all your sides that should appear later should look like:

Code: Select all

    [side]
       side=3
       controller=ai
       no_leader=yes
       team_name="bad3"
       user_team_name= _ "Bad Guys 3"
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=50
    [/side]
Then add an die [event] that creates the next leader when the first enemy-leader dies:

Code: Select all

       [event]
            name=die

            [filter]
                id=EnemyLeader2
            [/filter]

            [unit]
               id=EnemyLeader3
               name= _ "Rigro"
               type= "Goblin Knight"
               unrenamable=yes
               canrecruit=yes
               side=3
               x=
               y=   # add coordinates here
            [/unit]
        [/event]
Of course you have to do that for all sides.

Edit: added missing side=3
Last edited by Straff on April 29th, 2023, 6:40 am, edited 1 time in total.
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Re: Enemy Leader appear one after another

Post by Kal_Ultor »

Thank you for your answer!
I must have made some mistake inserting the code. It starts correctly with me and the first enemy leader but after he is killed, I win instead of the next enemy leader being summend.
My code:

Code: Select all

#textdomain wesnoth-orc_campaign
[scenario]
    id=try_outs
    next_scenario=null
    name=_"Try Outs"
    map_data="{~add-ons/orc_campaign/maps/try_outs_map.map}"
    turns=100
    [side]
        side=1
        controller=human
        team_name="good"
        user_team_name= _ "My Team"
        id=MyLeader
        name= _ "Sabo"
        type="Orcish Leader"
        unrenamable=yes
        canrecruit=yes
        recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman, Naga Fighter"
        gold=1000
    [/side]
    [side]
       side=2
       controller=ai
       team_name="bad2"
       user_team_name= _ "Bad Guys 2"
       id=EnemyLeader2
       name= _ "Pragdush"
       type= "Orcish Leader"
       unrenamable=yes
       canrecruit=yes
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=10
    [/side]
        [event]
            name=die

            [filter]
                id=EnemyLeader2
            [/filter]

            [unit]
               id=EnemyLeader3
               name= _ "Rigro"
               type= "Goblin Knight"
               unrenamable=yes
               canrecruit=yes
               x=38
               y=24
            [/unit]
        [/event]
    [side]
       side=3
       controller=ai
       no_leader=yes
       team_name="bad3"
       user_team_name= _ "Bad Guys 3"
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=10
    [/side]
[event]
            name=die

            [filter]
                id=EnemyLeader3
            [/filter]

            [unit]
               id=EnemyLeader4
               name= _ "Domag"
               type= "Orcish Slayer"
               unrenamable=yes
               canrecruit=yes
               x=41
               y=15
            [/unit]
        [/event]
    [side]
       side=4
       controller=ai
       no_leader=yes
       team_name="bad3"
       user_team_name= _ "Bad Guys 4"
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=10
    [/side]
[event]
            name=die

            [filter]
                id=EnemyLeader4
            [/filter]

            [unit]
               id=EnemyLeader5
               name= _ "azgo"
               type= "Orcish Crossbowman"
               unrenamable=yes
               canrecruit=yes
               x=40
               y=3
            [/unit]
        [/event]
    [side]
       side=5
       controller=ai
       no_leader=yes
       team_name="bad3"
       user_team_name= _ "Bad Guys 5"
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=10
    [/side]
      [event]
            name=die

            [filter]
                id=EnemyLeader5
            [/filter]

            [unit]
               id=EnemyLeader6
               name= _ "Vunu"
               type= "Orcish Warrior"
               unrenamable=yes
               canrecruit=yes
               x=6
               y=4
            [/unit]
        [/event]
    [side]
       side=6
       controller=ai
       no_leader=yes
       team_name="bad3"
       user_team_name= _ "Bad Guys 6"
       recruit="Orcish Grunt, Orcish Archer, Orcish Assassin, Wolf Rider, Goblin Spearman"
       gold=10
    [/side]
      [event]
            name=die

            [filter]
                id=EnemyLeader6
            [/filter]

            [unit]
               id=EnemyLeader7
               name= _ "Xasal"
               type= "Naga Myrmidon"
               unrenamable=yes
               canrecruit=yes
               x=6
               y=30
            [/unit]
        [/event]
    [side]
       side=7
       controller=ai
       no_leader=yes
       team_name="bad3"
       user_team_name= _ "Bad Guys 7"
       recruit="Naga Fighter"
       gold=10
    [/side]
    [event]
        name=start
        [message]
            speaker=MyLeader
            message= _ "I will prove myself worthy!"
        [/message]
        [message]
            speaker=EnemyLeader2
            message= _ "Grrrr!"
        [/message]
        [objectives]
            [objective]
                description= _ "Defeat the enemy leader"
                condition="win"
            [/objective]
            [objective]
                description= _ "Death of your leader"
                condition="lose"
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition="lose"
             [/objective]
        [/objectives]
    [/event]
[/scenario]
User avatar
Straff
Posts: 86
Joined: September 27th, 2020, 2:53 pm

Re: Enemy Leader appear one after another

Post by Straff »

You need to add

Code: Select all

victory_when_enemies_defeated=no
to the scenario definition. Otherwise you always win when your enemy is defeated, and no other enemy is (already) on the map.

And also you have to trigger victory when the last enemy leader is defeated.

Code: Select all

	# add this in the die event of the last enemy
        [endlevel]
            result=victory
            bonus=no
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
And you should add all events under the side definitions, sot between them, for better readability.

The created enemy leaders have no side defined, you have to add them, otherwise they will always be created as side=1 units
User avatar
Celtic_Minstrel
Developer
Posts: 2214
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Enemy Leader appear one after another

Post by Celtic_Minstrel »

While Straff's answer would work, I'm not sure it's necessary. First of all, did the second leader get spawned despite you getting a victory? If the answer is "no", then that's probably the issue right there, and you need to figure out why the die event didn't trigger. If the answer is "yes", try changing it to name=last breath instead of name=die.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Enemy Leader appear one after another

Post by gfgtdf »

You shouldn't need no_leader=yes, no_leader is iirc only requited in Multiplayer games to prevent the multiplayer engine to add a leader from a multiplayer faction. victory_when_enemies_defeated=no shouldn't be necessary either because the engine only checks for a sides defeat after all events have been fired.

What you need is to specify the side when creating the unit.
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
Celtic_Minstrel
Developer
Posts: 2214
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Enemy Leader appear one after another

Post by Celtic_Minstrel »

You need no_leader=yes when there is no leader specified directly in the side tag, otherwise the game will raise an error or something like that. I think it still works despite the error, but still.

It sounds like gfgtdf spotted the real issue – the die event needs to specify the side of the next leader.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Enemy Leader appear one after another

Post by gfgtdf »

Celtic_Minstrel wrote: April 29th, 2023, 12:15 am You need no_leader=yes when there is no leader specified directly in the side tag, otherwise the game will raise an error
This would be new to me, are you sure this is the case? I'm pretty sure it wasn't the case the last time I worked on that part of the code.


Actually i think no_leader is implemented as just an alias for leader_lock
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
Celtic_Minstrel
Developer
Posts: 2214
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Enemy Leader appear one after another

Post by Celtic_Minstrel »

There are a bunch of places that deal with the no leader flag, but basically you're half right, in that it does set leader_lock to true. I can't find the check I was thinking of though, maybe it was removed? Isn't there a check somewhere about whether [side] has a type key?

There's also a TODO comment that suggests that no_leader should maybe be used more than it is. It actually looks really messy…
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Enemy Leader appear one after another

Post by gfgtdf »

Celtic_Minstrel wrote: April 29th, 2023, 2:05 am There are a bunch of places that deal with the no leader flag, but basically you're half right, in that it does set leader_lock to true. I can't find the check I was thinking of though, maybe it was removed? Isn't there a check somewhere about whether [side] has a type key?
Well there is a check whether it has a type= key and if it has a type attribute ilt creates a unit. (Although i believe we should move towards using [leader] as the usual practice.)

Celtic_Minstrel wrote: April 29th, 2023, 2:05 am There's also a TODO comment that suggests that no_leader should maybe be used more than it is. It actually looks really messy…
Hmm maybe the comment means what I said above (move towards [leader]). Although i would not think it's messy, it's basically "no type attribute"="create no leader", pretty simple to me, and no_leader=leader_lock
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
Celtic_Minstrel
Developer
Posts: 2214
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Enemy Leader appear one after another

Post by Celtic_Minstrel »

gfgtdf wrote: April 29th, 2023, 2:16 am no_leader=leader_lock
Although it is clearly the case at present, this doesn't make sense to me at all.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Enemy Leader appear one after another

Post by gfgtdf »

Hmm well, if you know that all that no_leadsr does it to prevent the mo code from adding a leader then it makes a lot of sense to me. Basically no_leader= "don't change the specified leader (none)"
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.
Kal_Ultor
Posts: 17
Joined: April 28th, 2023, 12:01 pm
Location: Central Europe

Re: Enemy Leader appear one after another

Post by Kal_Ultor »

Thank you all for your help! It worked.
Post Reply