How to force IA factions to start playing when spotted?

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.
User avatar
Ravana
Forum Moderator
Posts: 2948
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How to force IA factions to start playing when spotted?

Post by Ravana »

If you mean leader death, in filter use canrecruit=yes. If you mean last unit of side, then it probably needs to be [have_unit] check for units of that side.

Instead of team_name, filter by side.

filter means unit who dies, filter_second means unit who kills.
User avatar
Alopex95
Posts: 22
Joined: April 3rd, 2020, 12:14 pm

Re: How to force IA factions to start playing when spotted?

Post by Alopex95 »

Ravana wrote: November 28th, 2022, 11:13 am If you mean leader death, in filter use canrecruit=yes. If you mean last unit of side, then it probably needs to be [have_unit] check for units of that side.

Instead of team_name, filter by side.

filter means unit who dies, filter_second means unit who kills.
Well, I want this event to fire after all bandits team units die. Regarding the defeat condition, is something I already did setting defeat_condition=no_units_left to all these sides.
Returning to the event, following your suggestion, I tried to do something like this:

Code: Select all

[event]
        name=die
        [filter]
            side=3
            side=4
            side=5
        [/filter]
	# what has to happen...
[/event]
but I didn't achieve my goal yet (Actually I 'm not sure if the filter can have more than one condition).
Oh, and for the filter and filter_second keywords, thanks for the clarification! I completely misunderstand this concept. :doh:
User avatar
Spannerbag
Posts: 505
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: How to force IA factions to start playing when spotted?

Post by Spannerbag »

Alopex95 wrote: November 28th, 2022, 11:04 am ... I'm trying to implement a condition when the bandits team is defeated because the scenario has to continue ...
Have you looked at setting victory_when_enemies_defeated=no in [scenario]?

Code: Select all

[scenario]
  id=my_scenario
  name=_"my_scenario"
  next_scenario=my_next_scenario
  map_file=my_scenario.map
  {TURNS easy_turn_limit normal_turn_limit hard_turn_limit}
  victory_when_enemies_defeated=no
  ... WML ...
[/scenario]
For example if you want victory to occur when all enemy units are defeated you'd need to do the above otherwise the scenario will end when the last enemy leader dies, even if other enemy units are on the map.
A simple way to catch the victory condition (no enemies left) would be to do what Ravana mentioned: have a condition that fires when no enemy units remain on the map.

So if your enemy sides were, say, 3,4 and 5 then you could use:

Code: Select all

[event]
    name=die
    [filter]
        side=3,4,5
    [/filter]
    [filter_condition]
        [have_unit]
            side=3,4,5
            count=0                # Does not count the dying-but-not-yet-dead unit caught by [filter]
        [/have_unit]
    [/filter_condition]
... WML ...
[/event]
Of course there are lots of other things you can do such as test each turn if there are no enemies on the map (I've used this once or twice for slightly unusual situations).

Hope this helps!

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Alopex95
Posts: 22
Joined: April 3rd, 2020, 12:14 pm

Re: How to force IA factions to start playing when spotted?

Post by Alopex95 »

Spannerbag wrote: November 28th, 2022, 1:58 pm
Alopex95 wrote: November 28th, 2022, 11:04 am ... I'm trying to implement a condition when the bandits team is defeated because the scenario has to continue ...
Have you looked at setting victory_when_enemies_defeated=no in [scenario]?

Code: Select all

[scenario]
  id=my_scenario
  name=_"my_scenario"
  next_scenario=my_next_scenario
  map_file=my_scenario.map
  {TURNS easy_turn_limit normal_turn_limit hard_turn_limit}
  victory_when_enemies_defeated=no
  ... WML ...
[/scenario]
For example if you want victory to occur when all enemy units are defeated you'd need to do the above otherwise the scenario will end when the last enemy leader dies, even if other enemy units are on the map.
A simple way to catch the victory condition (no enemies left) would be to do what Ravana mentioned: have a condition that fires when no enemy units remain on the map.

So if your enemy sides were, say, 3,4 and 5 then you could use:

Code: Select all

[event]
    name=die
    [filter]
        side=3,4,5
    [/filter]
    [filter_condition]
        [have_unit]
            side=3,4,5
            count=0                # Does not count the dying-but-not-yet-dead unit caught by [filter]
        [/have_unit]
    [/filter_condition]
... WML ...
[/event]
Of course there are lots of other things you can do such as test each turn if there are no enemies on the map (I've used this once or twice for slightly unusual situations).

Hope this helps!

Cheers!
-- Spannerbag
It works perfectly! Thanks again for all the support!

Cheers!
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to force IA factions to start playing when spotted?

Post by Helmet »

Spannerbag wrote: November 28th, 2022, 1:58 pm Have you looked at setting victory_when_enemies_defeated=no in [scenario]?
I love it when I think I have to write a lot of code that may or may not work, and then I learn that WML already has a tag or key that completely addresses whatever it is I'm trying to do. :)
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
lhybrideur
Posts: 357
Joined: July 9th, 2019, 1:46 pm

Re: How to force IA factions to start playing when spotted?

Post by lhybrideur »

Alopex95 wrote: November 28th, 2022, 11:04 am Hey, everyone!
Just another (and last, I promise! :) ) little query I'm wondering while finalizing my scenario: I'm trying to implement a condition when the bandits team is defeated because the scenario has to continue after our hero frees the city from them.
Here's what I've tried so far, but without any great results:
First, I tried with a name=die event with a filter team_name="bandits";
Second, I tried with the same event but putting a filter with id=OneBandit and a filter_second with id=AnotherBandit (despite the bandit's leaders being three, but I was doing some tests).
I think that the die event can be applied only to single units, so is this maybe the problem in my code?
So, how can I set an event which will be fired after the defeat of a particular team?

Thanks always for your precious pieces of advice!

P.S.: I can open a new thread for this question if using this is against the forum rules. :)
I am not sure if I understood your question right, but if you are trying to set up a victory if the "bandits" are defeated, I see two main ways.

- victory_when_enemies_defeated=yes and a name=victory event
- last_breath event with side=3,4,5 in [filter] and a

Code: Select all

[if]
[not]
[have_unit]
side=3,4,5
can_recruit=yes
[/have_unit]
[/not]
[/if]
Post Reply