A lone unit.

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

A lone unit.

Post by BajMic »

Hi, I need to double check something with you. I am just writing a Lurker Micro AI that takes around 70 lines and my brain starts tripping.

If I want to say "only approach this unit if it is alone, i.e., has no buddies in the radius of 5", would that be correct? Or would it catch the approached (lone) unit in question?

Code: Select all

						[filter_location]
							x=30
							y=26
							[filter_adjacent_location]
								adjacent=s
								[filter]
									side=1
									[filter_location]
										[not]
											[filter]
												side=1
											[/filter]
											radius=5
										[/not]
									[/filter_location]
								[/filter]
							[/filter_adjacent_location]
						[/filter_location]
white_haired_uncle
Posts: 1456
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: A lone unit.

Post by white_haired_uncle »

My brain is jello atm, and I hate nested filters, but a couple thoughts:

1) adjacent=s looks odd. You really only want to look at one hex?
2) You might want to look at [have_unit] which has a 'count' if you want to make sure that exactly one unit from side 1 is <somewhere>
Speak softly, and carry Doombringer.
BajMic
Posts: 72
Joined: January 24th, 2023, 1:22 am

Re: A lone unit.

Post by BajMic »

Thanks.

1) The "s" direction is dictated by the shape of the map. There is a unit zoc-blocking a 3-hex wide entrance (according to a set of rules), but there is a nook on the southern side. The unit is supposed to engage only if there are no other enemy units to bypass it nearby.

2) Yes. If easier solution fails, I will just make two separate micro_ai's dependent on the conditional tags.
User avatar
Celtic_Minstrel
Developer
Posts: 2371
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: A lone unit.

Post by Celtic_Minstrel »

Code: Select all

[filter_location]
							x=30
							y=26
							[filter_adjacent_location]
								adjacent=s
This seems excessively complicated. Can't you just do this:

Code: Select all

[filter_location]
							x=30
							y=27
---------

Code: Select all

								[filter]
									side=1
									[filter_location]
										[not]
											[filter]
												side=1
											[/filter]
											radius=5
										[/not]
									[/filter_location]
								[/filter]
This code in a location filter means "there must be a side 1 unit on this space, and the space the unit is on must not be within 5 spaces of a side 1 unit". So it sounds like it probably does what you want, though I suspect you could move the content of the inner filter_location into an and at the same level as the filter.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply