Victory when last enemy unit dies

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
Kratoz94
Posts: 2
Joined: July 20th, 2018, 5:45 pm

Victory when last enemy unit dies

Post by Kratoz94 »

Dear everyone,

I am just a novice when it comes to programming code, but recently I have built my own campaign with 13 scenarios sucessfully. E.g. I used the "moveto", "die" or "time over" events as well as the "victory when enemies defeated" key to bring each scenario to an end.
Now I want to create some more content and as I could find more code on the "create" sites, I got stuck with the idea to end a scenario just when there is no enemy unit on the field anymore. Since I cant attach it to a hex field, death of an ID or number of turns, I tried something like this...

Code: Select all


    [event]
        name=exit
        [if]	
	    [not]				
	        side=2
	        [have_unit]
	        [/have_unit]
	    [/not]
	    [then]
	        [message]
            	    speaker=MyLeader
            	    message= _ "We made it!"
                [/message]
	        [endlevel]
	            result=victory
	        [/endlevel]
	    [/then]
        [/if]
    [/event]
    
... to have the engine asking for the number of units of a certain (or various) side(s).
When I testplay, the scenario doesnt end, even if I kill all enemy units. For any kinda help, I would be very greatful.

Cheers,
Kratoz 94
User avatar
MoonyDragon
Posts: 87
Joined: November 29th, 2017, 5:46 pm

Re: Victory when last enemy unit dies

Post by MoonyDragon »

Hi Kratoz94,
The enemies defeated event is sufficient to achieve your goal. It fires when all sides that are not considered "defeated" are allied. The conditions for when a side is considered "defeated" are specified in the [side] tag, defaulting to the loss of all its leaders. To make the enemy defeated event fire when all units of a certain side are killed, add defeat_condition=no_units_left to that side's parent tag.

I'm looking forward to see your campaign on the add-on server ^^
Default L0 Era - Level 1 leaders with level 0 recruits!
Kratoz94
Posts: 2
Joined: July 20th, 2018, 5:45 pm

Re: Victory when last enemy unit dies

Post by Kratoz94 »

Hey MoonyDragon,

How could I miss that? I already dicovered the

Code: Select all

 defeat_condition 
key, but couldnt find how to end the scenario by event then.
Thank you so much!

When its time, I will take a proper look at the "how to share your content" section, translate my strings and put both of my campaigns online.
In the meantime, I might try Palms amid Blue Dunes. Cya

Kratoz94
Post Reply