AI script for explicitly sending wounded units to infirmary.

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

AI script for explicitly sending wounded units to infirmary.

Post by BajMic »

Hello. I have a problem with the following script. It is supposed to designate upt to 4 wounded Ruffians to head for villages. The reason I want to do it like that is because (a) even with large caution/retreat values, the AI is suiciding its units and (b) I want to create a zone of wounded Ruffians for scenario purposes.

Code: Select all

	[event]
		name=side 4 turn
		first_time_only=no
		[micro_ai]
			side=6
			ai_type=goto
			action=add
			[filter_location]
				x=20,22,23,26
				y=16,18,22,18
			[/filter_location]
			[filter]
				type=Ruffian
				hitpoints=1,2,3,4,5,6,7,8,9
			[/filter]
			release_unit_at_goal=yes
			remove_movement=no
			unique_goals=yes
		[/micro_ai]
	[/event]
The problem is that all freshly recuited Ruffians immidiately head to sit on villages, even when the their Leader is under attack.

The general AI is the following. I am trying to set it in such a way that units don't run into the open, but instead prefer to stick to forest tiles.

Code: Select all

	[ai]
		advancements=Poacher, Thug
		aggression=0.2
		caution=1.5
		retreat_factor=0.5
		village_value=2
	[/ai]
What am I doing wrong here?
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: AI script for explicitly sending wounded units to infirmary.

Post by Toranks »

hitpoints=1,2,3,4,5,6,7,8,9 isn't a valid StandardUnitFilter

Instead, use:
formula=hitpoints < 10
BajMic
Posts: 44
Joined: January 24th, 2023, 1:22 am

Re: AI script for explicitly sending wounded units to infirmary.

Post by BajMic »

Thank you, Toranks.

This leaves me with another question, though. I have specified 4 hexes in the LocationFilter and set unique_goals to yes, so why did all the Ruffians go to the villages and not just 4?
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2365
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: AI script for explicitly sending wounded units to infirmary.

Post by Lord-Knightmare »

This leaves me with another question, though. I have specified 4 hexes in the LocationFilter and set unique_goals to yes, so why did all the Ruffians go to the villages and not just 4?
The MAI will apply to the [filter]. That is, it applied to every Ruffian, not just "4". Each Ruffian will be assigned one of the 4 villages to go.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
BajMic
Posts: 44
Joined: January 24th, 2023, 1:22 am

Re: AI script for explicitly sending wounded units to infirmary.

Post by BajMic »

According to the documentation here, https://wiki.wesnoth.org/Micro_Ais#Gene ... .3Dgoto.29 :
unique_goals=no: (boolean) If set to 'yes', each unit will be sent to a different goal location. Note that the best goals are recalculated each turn, so a unit might choose a different goal this turn from what it was heading for during the previous turn if the situation on the map has changed. Also note that if there are more units than goal locations, the left over units will not be handled by the Goto MAI but follow default behavior instead.
So has anything changed since then? Is this not what I should expect?
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2365
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: AI script for explicitly sending wounded units to infirmary.

Post by Lord-Knightmare »

Nothing has changed for this MAI.
Also, when have release_unit_at_goal=yes which means once any of the filtered units reach the goal, the MAI stops affecting them, so this would allow and has allowed all Ruffians to go to 4 villages.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
BajMic
Posts: 44
Joined: January 24th, 2023, 1:22 am

Re: AI script for explicitly sending wounded units to infirmary.

Post by BajMic »

I will have to test it, but according to the documentation, release_unit_at_goal=yes works at the beginning of the next turn after reaching the goal. That should not result in 20+ Ruffians clogging the village area.
Post Reply