Victory when last enemy unit dies
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.
Victory when last enemy unit dies
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...
... 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
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]
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
- MoonyDragon
- Posts: 149
- Joined: November 29th, 2017, 5:46 pm
Re: Victory when last enemy unit dies
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
I'm looking forward to see your campaign on the add-on server ^^
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!
Re: Victory when last enemy unit dies
Hey MoonyDragon,
How could I miss that? I already dicovered the 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
How could I miss that? I already dicovered the
Code: Select all
defeat_condition
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