Cancelling [avoid] in the side [ai].

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
BajMic
Posts: 42
Joined: January 24th, 2023, 1:22 am

Cancelling [avoid] in the side [ai].

Post by BajMic »

According to wiki, new [avoid] input should replace the previous one. It did not work on my case. Could you please help me understand how it works? Is is possible to retract the [avoid] without this facet/path thing?

The initial setup:

Code: Select all

		[ai]
			aggression=1
			grouping=no
			[avoid]
				x=20-49
				y=7-25
			[/avoid]
			[goal]
				name=target_location
				[criteria]
					x=32,33,34
					y=16-17,16-18,16-17
				[/criteria]
				value=5
			[/goal]
		[/ai]
Later in the scenario:

Code: Select all

		[modify_ai]
			side=2
			[ai]
				aggression=1
				grouping=no
				[avoid]
					x=29,30-31
					y=1-4,1-14
				[/avoid]
				[goal]
					name=target_location
					[criteria]
						x=32,33,34
						y=16-17,16-18,16-17
					[/criteria]
					value=5
				[/goal]
			[/ai]
		[/modify_ai]
It doesn't seem to work, i.e., units are still avoiding the initially defined area at the top.
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Cancelling [avoid] in the side [ai].

Post by beetlenaut »

BajMic wrote: May 28th, 2023, 11:55 pm Is is possible to retract the [avoid] without this facet/path thing?
I don't think so, but you can just change it to something unreachable anyway like 0,0 or 99,99.
BajMic wrote: May 28th, 2023, 11:55 pm It doesn't seem to work, i.e., units are still avoiding the initially defined area at the top.
You are using the format for [modify_side] inside a [modify_ai] tag. Changing it to [modify_side] should fix the problem.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
BajMic
Posts: 42
Joined: January 24th, 2023, 1:22 am

Re: Cancelling [avoid] in the side [ai].

Post by BajMic »

Yes, it worked. Thank you.
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Cancelling [avoid] in the side [ai].

Post by Celtic_Minstrel »

beetlenaut wrote: May 29th, 2023, 8:18 pm
BajMic wrote: May 28th, 2023, 11:55 pm Is is possible to retract the [avoid] without this facet/path thing?
I don't think so, but you can just change it to something unreachable anyway like 0,0 or 99,99.
It's totally possible to remove an arbitrary `[avoid]`.

Code: Select all

[modify_ai]
	action=delete
	path=aspect[avoid].facet[0]
[/modify_ai]
That removes the first `[avoid]` tag that had been defined. Increase the number to remove a different one, or replace with * to remove all of them. The only problem with this approach is that there's no way to specifically remove the last one – you need to know exactly how many there are if you want to do that.

The second way is by ID. If you define your `[avoid]` a bit differently:

Code: Select all

[avoid]
	id=my_avoid
	[value]
		# put your filter here
	[/value]
[/avoid]
Then you can remove it like this:

Code: Select all

[modify_ai]
	action=delete
	path=aspect[avoid].facet[my_avoid]
[/modify_ai]
However, there's no actual need to remove the old `[avoid]`, as only the most-recently-added one takes effect – unless you add conditions, for example like this:

Code: Select all

[avoid]
	# some filter
[/avoid]
[avoid]
	time_of_day=twilight
	[value]
		# some other filter
	[/value]
[/avoid]
Or alternatively like this:

Code: Select all

[ai]
	[avoid]
		# some filter
	[/avoid]
[/ai]
[ai]
	time_of_day=twilight
	[avoid]
		# some other filter
	[/avoid]
[/ai]
In either of those examples, it uses the last one during the twilight hour, but falls back to the next-to-last one at any other time of day.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply