AI script for explicitly sending wounded units to infirmary.
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.
AI script for explicitly sending wounded units to infirmary.
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.
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.
What am I doing wrong here?
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 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]
Re: AI script for explicitly sending wounded units to infirmary.
hitpoints=1,2,3,4,5,6,7,8,9
isn't a valid StandardUnitFilterInstead, use:
formula=hitpoints < 10
Re: AI script for explicitly sending wounded units to infirmary.
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?
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?
- 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.
The MAI will apply to theThis 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?
[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
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: AI script for explicitly sending wounded units to infirmary.
According to the documentation here, https://wiki.wesnoth.org/Micro_Ais#Gene ... .3Dgoto.29 :
So has anything changed since then? Is this not what I should expect?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.
- 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.
Nothing has changed for this MAI.
Also, when have
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
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: AI script for explicitly sending wounded units to infirmary.
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.