Victory Condition: Enemies Killed?

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.
Post Reply
User avatar
HudsonWolf
Posts: 2
Joined: August 2nd, 2009, 2:58 am

Victory Condition: Enemies Killed?

Post by HudsonWolf »

In my campaign that I've been working on, I was planning to have a level in which you had to kill a certain number of enemies in order to win. I tried using a combination of variables and filtered death triggers, but, to put it bluntly, it failed. (To put it less bluntly, I gave up on my campaign for a month because when I tried to load it it claimed my _main couldn't be loaded because of nonexistent errors in EoM. But that's another story entirely.) Once I figured out that it was causing the problem, I changed it around so that there are a set number of enemies already on the map and you just have to kill them all. However, the best way I could find to do that was just to make them all leaders, meaning they all have the gold crowns. Which looks kind of stupid. So, what I want to know is this: is there a better way to code it so that you have to kill all enemy units, and/or is there a way to make the crowns not visible?

Also, is there a good way to trigger victory when a certain number of enemies have been killed? As I might want to use that later on...
I may contradict myself a lot, but at least I'm not a hypocrite.

User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Victory Condition: Enemies Killed?

Post by SkyOne »

HudsonWolf wrote:I was planning to have a level in which you had to kill a certain number of enemies in order to win. I tried using a combination of variables and filtered death triggers, but, to put it bluntly, it failed.
I have seen a similar case on 1.4 campaign, "The Unstoppable Legion" by Chris NS on scenario 03_A Test_of Valour.cfg. It is not exactly the same thing that you would like to do, but I hope that it is helpful for you. (I have also seen it on something other campaign, but I cannot remember it, sorry.)
Attachments
03_A_Test_of_Valour.cfg
from: The Unstoppable Legion by Chris NS
(18.37 KiB) Downloaded 73 times
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server

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

Re: Victory Condition: Enemies Killed?

Post by zookeeper »

Use victory_when_enemies_defeated=no so you don't have to have any enemy leaders, and then use a simple event like this to check after each enemy death whether there are any more left:

Code: Select all

[event]
    name=die
    first_time_only=no

    [filter]
        side=2,3,4 # or whatever the enemy sides are
    [/filter]

    [if]
        [have_unit]
            side=2,3,4

            [not]
                x,y=$x1,$y1
            [/not]
        [/have_unit]

        [else]
            [endlevel]
                result=victory
            [/endlevel]
        [/else]
    [/if]
[/event]

Post Reply