[solved] Artificial Inteligence more [avoid] tags

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
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

[solved] Artificial Inteligence more [avoid] tags

Post by ZombieKnight »

Hi,
How to make AI units avoid some terrains, while some of them (units with micro_ai goto) could still get on those terrains?

Code: Select all

[micro_ai]
            side=7
            ai_type=goto
            action=add
            ignore_enemy_at_goal=yes
            ca_score=300000
            [filter]
                find_in=side_7_retreat_micro_ai
            [/filter]
            [filter_location]
                x,y=36,7
                radius=2
            [/filter_location]
        [/micro_ai]
Thats my micro_ai, and since [avoid] seems much stronger...
...
This breaks my micro_ai:

Code: Select all

[modify_ai]#BREAKS retreat micro_ai
            side=7
            action=add
            path=aspect[avoid].facet[]
            [facet]
                [value]
                    terrain=U*^*,Cud*^*
                [/value]
            [/facet]
        [/modify_ai]
How to modify [avoid] so it's terrains are only much less preferable, but when theres no non-avoided tiles in range units could move there?
or
How to achieve similar thing without [avoid] tag?
Last edited by ZombieKnight on April 15th, 2024, 3:17 pm, edited 1 time in total.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Artificial Inteligence question

Post by Celtic_Minstrel »

If you want units to avoid certain terrains only when they're not using the Goto MicroAI, that's easy. Set up the avoid tag for the avoided terrains like normal. Then add an empty avoid tag in the Goto Micro AI definition. For MicroAIs that support it, an avoid tag inside their definition overrides the default avoid tag for the side, and an empty avoid tag means to avoid nothing.

Off the top of my head, I'm not sure how to make units step on specific terrains only when there is no other option.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Artificial Inteligence question

Post by ZombieKnight »

Great! I had no idea that I can do that.
Should I put [avoid] tag right inside [micro_ai] tag?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Artificial Inteligence question

Post by ZombieKnight »

Jup I've found it even in documentation.
Has to be: actually

Code: Select all

[avoid]
     [not]
     [/not]
[/avoid]
Thanks for quick and simple answer!!! ^^
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [solved] Artificial Inteligence more [avoid] tags

Post by Celtic_Minstrel »

Yeah, you're right, you need the empty not tag as well.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply