Victory objective: defeating all enemy units

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
User avatar
SpookyTree
Posts: 1
Joined: June 6th, 2015, 11:21 pm

Victory objective: defeating all enemy units

Post by SpookyTree »

Hi all, first post :D

I'm working on a scenario for a campaign where the objective is kill all enemy units (wolves and other critters and such). The enemy has no leader and all of the units that need to be killed are placed on the map in the prestart event. The scenario runs properly but when I run through the scenario and kill all of the units the victory event doesn't fire. My event code is

Code: Select all

[event]
    name=die
    [filter]
        side=2
    [/filter]
    [if]
        [not]
            [have_unit]
                side=2
            [/have_unit]
            [then]
                [endlevel]
                    result=victory
                [/endlevel]
            [/then]
        [/not]
    [/if]
[/event]
The enemy (side 2) doesn't have a leader. My side code is

Code: Select all

[side]
no_leader=yes
side=2
controller=ai
{GOLD 0 0 0}
income=0
team_name="Wolves"
user_team_name="Wolves"
[/side]
Any assistance is appreciated. Thanks in advance!
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: Victory objective: defeating all enemy units

Post by tekelili »

I am just guessing, but may be unit is still alive for filter proposes in event name=die

Try this code if you want, but I am not really sure that is the problem

Code: Select all

            [have_unit]
                side=2
                [not]
                    x,y=$x1,$y1
                [/not]
            [/have_unit]
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Victory objective: defeating all enemy units

Post by Ravana »

This event also needs first_time_only=no.

However the conditional itself seems strange. [then] needs to be after the condition, not within it.

Code: Select all

[event]
    name=die
	first_time_only=no
    [filter]
        side=2
    [/filter]
    [if]
        [not]
            [have_unit]
                side=2
            [/have_unit]
		[/not]
		[then]
			[endlevel]
				result=victory
			[/endlevel]
		[/then]
    [/if]
[/event]
User avatar
Iris
Site Administrator
Posts: 6798
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: Victory objective: defeating all enemy units

Post by Iris »

SpookyTree wrote:

Code: Select all

{GOLD 0 0 0}
You can just use gold=0 if the difficulty setting is irrelevant.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
User avatar
tamanegi
Posts: 161
Joined: August 25th, 2014, 11:38 am
Location: Japan

Re: Victory objective: defeating all enemy units

Post by tamanegi »

Adding

Code: Select all

defeat_condition=no_units_left
to side 2 definition might be a simple alternative for your purpose.
Discord: @tamanegi
It is true that we cannot be free from bugs, but at least let our bugs not always the same...
A Group in a War: my first campaign, An Independence War: and the sequel
Post Reply