WML messenger_ai problem
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.
- ZombieKnight
- Posts: 180
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
WML messenger_ai problem
I store some side=7 units into units_to_micro_ai array, hat works fine.
But the [foreach][micro_ai] works unexpected(leader starts moving to 36,7 while units on units_to_micro_ai array keep fighting)
(I'm working on retreat micro-ai for nagas that aren't in water, then I want to add them lurker micro_ai so they'll stay in the water)
Any idea whats wrong?
Is there a better way to do so?
But the [foreach][micro_ai] works unexpected(leader starts moving to 36,7 while units on units_to_micro_ai array keep fighting)
Code: Select all
[store_unit]
[filter]
side=7
[not]
[filter_location]
terrain=W*,S*
[/filter_location]
[/not]
[and]
[not]
[filter_location]
x,y=44,3
radius=3
[/filter_location]
[/not]
[/and]
[/filter]
variable=units_to_micro_ai
[/store_unit]
[foreach]
array=units_to_micro_ai
[do]
[micro_ai]
side=7
ai_type=messenger_escort
action=add
[filter]
id=$units_to_micro_ai[$i].id
[/filter]
waypoint_x=36
waypoint_y=7
[/micro_ai]
[/do]
[/foreach]
Any idea whats wrong?
Is there a better way to do so?
I had saurian in profile before, but I've merged my discord profile with forum one...
- Spannerbag
- Posts: 538
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: WML messenger_ai problem
I've not used that particular micro_ai but you don't need to use a loop.
Instead, inside your
However, if you only store those units purely to associate them with the micro_ai I think you could replace all your code with:
You might even be able to pack it down a bit more by using a single
I think this filter should work the same as the one above:
Hope this works/helps!
Cheers!
-- Spannerbag
Instead, inside your
[micro_ai][filter]
you could just have find_in=units_to_micro_ai
However, if you only store those units purely to associate them with the micro_ai I think you could replace all your code with:
Code: Select all
[micro_ai]
side=7
ai_type=messenger_escort
action=add
[filter]
side=7
[not]
[filter_location]
terrain=W*,S*
[/filter_location]
[/not]
[and]
[not]
[filter_location]
x,y=44,3
radius=3
[/filter_location]
[/not]
[/and]
[/filter]
waypoint_x=36
waypoint_y=7
[/micro_ai]
[filter_location]
with the two locations joined with a logical or
?I think this filter should work the same as the one above:
Code: Select all
[filter]
side=7
[not]
[filter_location]
terrain=W*,S*
[or]
[and]
x,y=44,3
radius=3
[/and]
[/or]
[/filter_location]
[/not]
[/filter]
Cheers!
-- Spannerbag
-
- Posts: 1227
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: WML messenger_ai problem
I think that's quite different. The first looks like "If you're not in the water/swamp or near some location RIGHT NOW you get assigned the mai". The second looks like it assigns everyone to the mai, but it's only effective on them if they're not in the water/etc on a given turn.Spannerbag wrote: ↑April 12th, 2024, 10:15 pm
However, if you only store those units purely to associate them with the micro_ai I think you could replace all your code with:
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 180
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: WML messenger_ai problem
Idk why still doesn't work...
I'm shifting to the goto micro_ai
I'm shifting to the goto micro_ai
I had saurian in profile before, but I've merged my discord profile with forum one...
- Spannerbag
- Posts: 538
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: WML messenger_ai problem
Ah. I'd assumed that the filter would only be referenced when the micro_ai started rather than every turn.white_haired_uncle wrote: ↑April 12th, 2024, 10:59 pmI think that's quite different. The first looks like "If you're not in the water/swamp or near some location RIGHT NOW you get assigned the mai". The second looks like it assigns everyone to the mai, but it's only effective on them if they're not in the water/etc on a given turn.Spannerbag wrote: ↑April 12th, 2024, 10:15 pm
However, if you only store those units purely to associate them with the micro_ai I think you could replace all your code with:
Whenever I've used a micro_ai I've always set it up in
prestart
or start
and assumed everything was only referenced once... but then my filter conditions don't change so I've never had cause to consider/realise that the eligible units are re-evaluated every turn...However it might be worth trying the first (
find_in
) version?If the stored variable isn't changed or deleted that would feed the same units to the micro_ai every turn.
(Even if all of these units killed the code should still work, I imagine.)
If I had the time I'd do some testing but sadly I don't.
![Sad :(](./images/smilies/icon_sad.gif)
Cheers!
-- Spannerbag
- ZombieKnight
- Posts: 180
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: WML messenger_ai problem
Jup find_in + goto works...
Checked ai aspects, it's stored there as it is, so your second suggestion would turn it off, as they'll get there.
Checked ai aspects, it's stored there as it is, so your second suggestion would turn it off, as they'll get there.
I had saurian in profile before, but I've merged my discord profile with forum one...