Modification : victory_when_enemies_defeated [Solve]

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
Cluric
Posts: 16
Joined: October 6th, 2012, 7:57 pm

Modification : victory_when_enemies_defeated [Solve]

Post by Cluric »

Hi,

I've an other problem with my campaign.

In a scenario, at the beginning i have "victory_when_enemies_defeated=no" (because at this moment, there is no ennemy on the map)
Next, depending of player choices, ennemy appear and the i want to turn "victory_when_enemies_defeated=yes".

I try some differents things like :

Code: Select all

[side]
    victory_when_enemies_defeated=yes
[/side]
Dont works, idem for

Code: Select all

[event]
    [filter]
        turn = X
    [/filter]
    victory_when_enemies_defeated=yes
[/event]
How can i do that ?
Last edited by Cluric on October 14th, 2012, 5:39 pm, edited 1 time in total.
User avatar
Dunno
Posts: 773
Joined: January 17th, 2010, 4:06 pm
Location: Behind you

Re: Modification : victory_when_enemies_defeated

Post by Dunno »

You can use the die event with endlevel tag.

Code: Select all

[event]
name=die
   [filter]
   #filter for enemy
   [/filter]
   [filter_second]
   #in case it's needed. E.g if there are more than 2 sides and you need to kill the enemy first. If it's standard 1v1 it can be omitted, I think.
   [/filter_second]
   [endlevel]
   result=victory
   [/endlevel]
[/event]
other things you can put in endlevel
Oh, I'm sorry, did I break your concentration?
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2481
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Modification : victory_when_enemies_defeated

Post by Lord-Knightmare »

How many enemy leaders are we talking about?

Suppose x enemy leaders appear. For every enemy leader you kill, a variable count starts. When variable count is x and you have slain the last leader, victory is achieved. All this can be done with victory_when_enemies_defeated=no.
Reply if you want a detailed structure of what I'm referring to.

I think I did this in a scenario of The Legend Begins. Must have been Dead Caves.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Cluric
Posts: 16
Joined: October 6th, 2012, 7:57 pm

Re: Modification : victory_when_enemies_defeated

Post by Cluric »

My problem is that there is NO ennemy leader (just standard units). Its the first mission of my campaign, that's while I only authorize the player to control "good" heros and fight "basic" ennemy.
So i can"t count ennemy's leader dead.

Dunno : im not sure to understand your code : the filter second is used to known who kill the unit in the first filter, right ? However, your code may start the event after only ONE ennemy die ?

My purpose is to use a sort of variable to know when the TOTALITY of the ennemy are dead... but AFTER few turn because there is no ennemy at the turn 1.
User avatar
Adamant14
Posts: 970
Joined: April 24th, 2010, 1:14 pm

Re: Modification : victory_when_enemies_defeated

Post by Adamant14 »

Code: Select all

[event]
        name=turn 5                  ### this prevents the event from triggering before turn 5
    [event]
        name=die
        first_time_only=no
        [filter]
            [not]
                side=1
            [/not]
        [/filter]
        [if]
            [have_unit]
                side=2                 ### I guess the enemy is side 2
                count=0
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
        [/if]
    [/event]
[/event]
Last edited by Adamant14 on October 8th, 2012, 12:56 am, edited 1 time in total.
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
Cluric
Posts: 16
Joined: October 6th, 2012, 7:57 pm

Re: Modification : victory_when_enemies_defeated

Post by Cluric »

Juste one word : PERFECT !

Thanks to all of you for your answer, I hope soon I'll capable to help other as effectively as you !
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2481
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Modification : victory_when_enemies_defeated

Post by Lord-Knightmare »

Actually I was referring to something like this:

Code: Select all

victory_when_enemies_defeated=no

[event]
   name=die
   first_time_only=no
   [filter]
      side=2
    [/filter]
    [if]
       [not]
          [have_unit]
              side=2
          [/have_unit]
      [/not]
      [then]
          {VARIABLE_OP enemy_side_destroyed add 1}
      [/then]
    [/if]
    [if]
      [variable]
          name=enemy_side_destroyed
          equals=3
      [/variable]
      [then]
           [endlevel]
               result=victory
           [/endlevel]
      [/then]   
    [/if]
[/event]

[event]
   name=die
   first_time_only=no
   [filter]
      side=3
    [/filter]
    [if]
       [not]
          [have_unit]
              side=3
          [/have_unit]
      [/not]
      [then]
          {VARIABLE_OP enemy_side_destroyed add 1}
      [/then]
    [/if]
    [if]
      [variable]
          name=enemy_side_destroyed
          equals=3
      [/variable]
      [then]
           [endlevel]
               result=victory
           [/endlevel]
      [/then]   
    [/if]
[/event]

[event]
   name=die
   first_time_only=no
   [filter]
      side=4
    [/filter]
    [if]
       [not]
          [have_unit]
              side=4
          [/have_unit]
      [/not]
      [then]
          {VARIABLE_OP enemy_side_destroyed add 1}
      [/then]
    [/if]
    [if]
      [variable]
          name=enemy_side_destroyed
          equals=3
      [/variable]
      [then]
           [endlevel]
               result=victory
           [/endlevel]
      [/then]   
    [/if]
[/event]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Elvish_Hunter
Posts: 1600
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Modification : victory_when_enemies_defeated

Post by Elvish_Hunter »

What about doing this instead?

Code: Select all

victory_when_enemies_defeated=no

[event]
   name=enemies defeated

   [endlevel]
      result=victory
   [/endlevel]
[/event]
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
Dugi
Posts: 4965
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Modification : victory_when_enemies_defeated

Post by Dugi »

@Elvish_Hunter As far as I know, if victory_when_enemies_defeated is set to no, enemies defeated event does not fire. I was debugging a scenario (that had victory_when_enemies_defeated=no), I had a save file made right before killing the last leader, and when I killed him, the enemies defeated event did not fire. Then I edited the data in the save file to victory_when_enemies_defeated=yes and killing the last leader fired the enemies defeated event.

IMO, the easiest way to solve the problem is to count units with canrecruit=yes killed, and if the count is high enough, the final conversation will happen. This will also allow you to easily make the last leader surrender if the remaining ones were defeated, that is useful to players, because last leader usually means a long travel to the keep, with almost any fight.
User avatar
Elvish_Hunter
Posts: 1600
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Modification : victory_when_enemies_defeated

Post by Elvish_Hunter »

Whoops. I completely missed that bit:
Cluric wrote:My problem is that there is NO ennemy leader (just standard units).
My bad! :oops:
In that case, if you want to check if there are enemy leaders alive after creating them...

Code: Select all

[event]
    name=die
    [filter]
        canrecruit=yes
        [filter_side]
            [enemy_of]
                side=1
            [/enemy_of]
        [/filter_side]
    [/filter]

    [filter_condition]
        [not]
            [have_unit]
                canrecruit=yes
                [filter_side]
                    [enemy_of]
                        side=1
                    [/enemy_of]
                [/filter_side]
            [/have_unit]
        [/not]
    [/filter_condition]
[/event]
That's a possibility. However, if you tell us how many leaders will be created, their sides, and the turn when you'll create them we can be more precise.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: Modification : victory_when_enemies_defeated

Post by pyrophorus »

Dugi wrote:@Elvish_Hunter As far as I know, if victory_when_enemies_defeated is set to no, enemies defeated event does not fire.
It does, on last leader kill. My campaign uses this in more than one place. But, if you have no enemy leader at all from the beginning, of course it will not.
Friendly,
Post Reply