Modification : victory_when_enemies_defeated [Solve]
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.
Modification : victory_when_enemies_defeated [Solve]
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 :
Dont works, idem for
How can i do that ?
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]
Code: Select all
[event]
[filter]
turn = X
[/filter]
victory_when_enemies_defeated=yes
[/event]
Last edited by Cluric on October 14th, 2012, 5:39 pm, edited 1 time in total.
Re: Modification : victory_when_enemies_defeated
You can use the die event with endlevel tag.
other things you can put in endlevel
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]
Oh, I'm sorry, did I break your concentration?
- 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
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.
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
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Modification : victory_when_enemies_defeated
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.
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.
Re: Modification : victory_when_enemies_defeated
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
Re: Modification : victory_when_enemies_defeated
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 !
Thanks to all of you for your answer, I hope soon I'll capable to help other as effectively as you !
- 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
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
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- Elvish_Hunter
- Posts: 1600
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Modification : victory_when_enemies_defeated
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)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: Modification : victory_when_enemies_defeated
@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.
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.
- Elvish_Hunter
- Posts: 1600
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Modification : victory_when_enemies_defeated
Whoops. I completely missed that bit:
In that case, if you want to check if there are enemy leaders alive after creating them...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.
My bad!Cluric wrote:My problem is that there is NO ennemy leader (just standard units).

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]
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)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Modification : victory_when_enemies_defeated
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.Dugi wrote:@Elvish_Hunter As far as I know, if victory_when_enemies_defeated is set to no, enemies defeated event does not fire.
Friendly,
HowTos: WML filtering, WML variables