Changing recruitment with [modify_ai].
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.
Changing recruitment with [modify_ai].
Hello, I am trying to follow the wiki https://wiki.wesnoth.org/Modifying_AI_C ... _ai.5D_Tag, however there is something I am doing wrong. May I ask for help with the following blocks? I would be very grateful.
The initial AI:
The change that doesn't seem to work:
The initial AI:
Code: Select all
[aspect]
id=recruitment_instructions
[facet]
[value]
[limit]
id=corpse_limit
type=Walking Corpse
max=8
[/limit]
[recruit]
id=Garry_recruitment
importance=0
leader_id=Garry
[/recruit]
[/value]
[/facet]
[/aspect]Code: Select all
[modify_unit]
[filter]
id=Harry
[/filter]
extra_recruit=Skeleton
[/modify_unit]
[modify_ai]
side=2
action=delete
path=aspect[recruitment_instructions].recruit[corpse_limit]
[/modify_ai]
[modify_ai]
side=2
action=add
path=aspect[recruitment_instructions].recruit[Harry_recruitment]
[facet]
[value]
[recruit]
#id=Harry_recruitment
importance=2
type=Skeleton
blocker=no
[/recruit]
[/value]
[/facet]
[/modify_ai]
[modify_ai]
side=2
action=change
path=aspect[recruitment_instructions].recruit[Garry_recruitment]
[facet]
[value]
[recruit]
#id=Garry_recruitment
importance=1
type=Walking Corpse
blocker=no
[/recruit]
[/value]
[/facet]
[/modify_ai]Re: Changing recruitment with [modify_ai].
I tried to circumvent the problem, by defining the following at the start:
Then later, once conditions were met, activated the following:
And I can't for the sake of it get the Harry to recruit anything no matter how I tweak these blocks. What I am trying to do is make Harry start recruiting only past a certain point during the scenario.
Code: Select all
[aspect]
id=recruitment_instructions
[facet]
[value]
[recruit]
id=Harry_recruitment
importance=2
leader_id=Harry
type=Skeleton
blocker=no
[/recruit]
[recruit]
id=Garry_recruitment
importance=1
leader_id=Garry
type=Walking Corpse
blocker=no
number=8
total=yes
[/recruit]
[/value]
[/facet]
[/aspect]Code: Select all
[modify_unit]
[filter]
id=Harry
[/filter]
extra_recruit=Skeleton
[/modify_unit]Re: Changing recruitment with [modify_ai].
Usually you give a side the ability to recruit something, not a unit. For example:
This can be nested inside an event. Which just triggers if you have a specific unit with a special ability.
In Five Fates I use hidden abilities, that are given by level ups and a chosen advancement path.
After an advancement it checks if a unit has this ability and gives the side the ability to recruit the unit.
Here is the code.
You can also modify a side using modify_side and change the recruit list, or setting new ones with the options in this thread:
https://wiki.wesnoth.org/DirectActionsW ... recruit.5D
Code: Select all
[allow_recruit]
type=unityouget
side=sideofyourleader
[/allow_recruit]
In Five Fates I use hidden abilities, that are given by level ups and a chosen advancement path.
After an advancement it checks if a unit has this ability and gives the side the ability to recruit the unit.
Here is the code.
Code: Select all
[event]
name=post advance
first_time_only=no
[filter]
id=you
ability=ElvishFriend2
[/filter]
[allow_recruit]
type=Elvish Shaman
side=1
[/allow_recruit]
[/event]You can also modify a side using modify_side and change the recruit list, or setting new ones with the options in this thread:
https://wiki.wesnoth.org/DirectActionsW ... recruit.5D
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Changing recruitment with [modify_ai].
Thank you Heindal. The issue is the same side has two leaders on the opposing sides of the map. One should only be able to recruit WC and the other Skeletons. Can't mix it.
- ChaosRider
- Posts: 1415
- Joined: April 15th, 2012, 1:15 pm
Re: Changing recruitment with [modify_ai].
Sometimes its good to use in opened game command line:
"debug"
"inspect"
Then you can check on unit which variable contain recruit list, is it a unit or side.
"debug"
"inspect"
Then you can check on unit which variable contain recruit list, is it a unit or side.
Creator of WOTG (+6400 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
Re: Changing recruitment with [modify_ai].
According to the debug mode, Harry can recruit Skeletons as intended. I also replaced the tag with the one suggested by Ravana, but he still is not recruiting. I am worried that there may be some clash between [ai] being setup while Harry was still unable to recruit Skeletons. Could that be the case anyhow?
I also tend to get the
I already tried all the following:
I also tend to get the
error when trying to tinker with [modify_ai]. Can someone advise me how to write path correctly?missing component definition in [modify_ai]
I already tried all the following:
Code: Select all
path=aspect[recruitment_instructions].facet[value].recruit[Harry_recruitment]
path=aspect[recruitment_instructions].facet[].value[].recruit[Harry_recruitment]
path=aspect[recruitment_instructions].facet[].recruit[Harry_recruitment]
path=aspect[recruitment_instructions].recruit[Harry_recruitment]- beetlenaut
- Developer
- Posts: 2885
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Changing recruitment with [modify_ai].
Replaced? Does that mean you put it inside [modify_ai]? It won't work there. It is a direct action that works inside general command blocks (like [event] or [if][then]). If that is where it is, we need to see the code around it because something else is not working. That is the correct tag.
No.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- Celtic_Minstrel
- Developer
- Posts: 2434
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Changing recruitment with [modify_ai].
I can see at least two issues in the code in your opening post.BajMic wrote: ↑January 29th, 2026, 4:21 pm Hello, I am trying to follow the wiki https://wiki.wesnoth.org/Modifying_AI_C ... _ai.5D_Tag, however there is something I am doing wrong. May I ask for help with the following blocks? I would be very grateful.
- You declare a
[limit]with an ID ofcorpse_limit, but then try to remove a[recruit]with that ID. If you want to remove the limit, it should look like this:Code: Select all
[modify_ai] side=2 action=delete aspect[recruitment_instructions].limit[corpse_limit] [/modify_ai] - When you tried to to add a new
[recruit], instead of providing a[recruit]tag, you provided a[facet]tag. To add a new recruitment instruction, I think you'd want it to look like this:Also notice here that there's no ID passed to the leaf level of theCode: Select all
[modify_ai] side=2 action=add path=aspect[recruitment_instructions].recruit[] [recruit] id=Harry_recruitment importance=2 type=Skeleton blocker=no [/recruit] [/modify_ai]path=when adding a node.
Code: Select all
[modify_unit]
[filter]
id=Harry
[/filter]
extra_recruit=Skeleton
[/modify_unit]
[modify_ai]
side=2
action=delete
path=aspect[recruitment_instructions].limit[corpse_limit]
[/modify_ai]
[modify_ai]
side=2
action=add
path=aspect[recruitment_instructions].recruit[]
[recruit]
id=Harry_recruitment
importance=2
type=Skeleton
blocker=no
[/recruit]
[/modify_ai]
[modify_ai]
side=2
action=change
path=aspect[recruitment_instructions].recruit[Garry_recruitment]
[recruit]
id=Garry_recruitment
importance=1
type=Walking Corpse
blocker=no
[/recruit]
[/modify_ai]Re: Changing recruitment with [modify_ai].
It doesn't work. I am trying to figure it out as we speak. I already tested the blocks individually, tried to remove any other coinciding blocks, etc.
Then I made a single block:
There was no error message, but :inspect showed no change, "Garry_recruitment" was still there, and yet the skeleton started recruiting a turn later... ?
Then I made a single block:
Code: Select all
[modify_ai]
side=2
action=delete
path=aspect[recruitment_instructions].recruit[Garry_recruitment]
[/modify_ai]Code: Select all
advancements: Revenant,Javelineer
aggression: 0.4
allow_ally_villages: no
caution: 0.25
grouping: offensive
leader_aggression: -4
leader_ignores_keep: no
leader_value: 0
passive_leader: yes
passive_leader_shares_keep: no
recruitment_diversity: 2
recruitment_instructions:
----config begin----
[recruit]
blocker = yes
id = Harry_recruitment
importance = 2
pattern = no
total = no
type = Skeleton
[/recruit]
[recruit]
blocker = yes
id = Garry_recruitment
importance = 1
leader_id = Garry
number = 8
pattern = yes
total = yes
type = Walking Corpse
[/recruit]
-----config end-----
recruitment_more:
recruitment_pattern:
recruitment_randomness: 50
recruitment_save_gold:
----config begin----
active = 0
-----config end-----
retreat_enemy_weight: 1
retreat_factor: 0.25
scout_village_targeting: 3
simple_targeting: no
support_villages: no
village_value: 0
villages_per_scout: 4
- Celtic_Minstrel
- Developer
- Posts: 2434
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Changing recruitment with [modify_ai].
Hmm. Thinking about it, the problem is probably that your recruitment instructions aspect is a composite aspect, so a path without a facet won't match. Try something like this:
The definition (the only change is adding an ID to the facet):
The removal function:
Side note: If you wanted, you could shorten the definition a bit:
The definition (the only change is adding an ID to the facet):
Code: Select all
[aspect]
id=recruitment_instructions
[facet]
id=my_recruitment
[value]
[limit]
id=corpse_limit
type=Walking Corpse
max=8
[/limit]
[recruit]
id=Garry_recruitment
importance=0
leader_id=Garry
[/recruit]
[/value]
[/facet]
[/aspect]
Code: Select all
[modify_ai]
side=2
action=delete
path=aspect[recruitment_instructions].facet[my_recruitment].recruit[Garry_recruitment]
[/modify_ai]
Code: Select all
[recruitment_instructions]
id=my_recruitment
[value]
[limit]
id=corpse_limit
type=Walking Corpse
max=8
[/limit]
[recruit]
id=Garry_recruitment
importance=0
leader_id=Garry
[/recruit]
[/value]
[/recruitment_instructions]
Re: Changing recruitment with [modify_ai].
Sorry for responding so late, I could only check now.
It finally worked, thank you Celtic Minstrel.
I started with:
Changed to:
Inspect:
Next, I edited the starting block:
And it worked, too.
Thank you for your patience.
It finally worked, thank you Celtic Minstrel.
I started with:
Code: Select all
[aspect]
id=recruitment_instructions
[facet]
id=my_recruitment
[value]
[recruit]
id=Harry_recruitment
importance=2
#leader_id=Harry
type=Skeleton
blocker=no
[/recruit]
[recruit]
id=Garry_recruitment
importance=1
leader_id=Garry
type=Walking Corpse
#blocker=no
number=8
total=yes
[/recruit]
[/value]
[/facet]
[/aspect]Code: Select all
[modify_ai]
side=2
action=delete
path=aspect[recruitment_instructions].facet[my_recruitment].recruit[Garry_recruitment]
[/modify_ai]Code: Select all
advancements: Revenant,Javelineer
aggression: 0.4
allow_ally_villages: no
caution: 0.25
grouping: offensive
leader_aggression: -4
leader_ignores_keep: no
leader_value: 0
passive_leader: yes
passive_leader_shares_keep: no
recruitment_diversity: 2
recruitment_instructions:
----config begin----
[recruit]
blocker = no
id = Harry_recruitment
importance = 2
pattern = yes
total = no
type = Skeleton
[/recruit]
-----config end-----
recruitment_more:
recruitment_pattern:
recruitment_randomness: 50
recruitment_save_gold:
----config begin----
active = 0
-----config end-----
retreat_enemy_weight: 1
retreat_factor: 0.25
scout_village_targeting: 3
simple_targeting: no
support_villages: no
village_value: 0
villages_per_scout: 4
Code: Select all
[aspect]
id=recruitment_instructions
[value]
[recruit]
id=Harry_recruitment
importance=2
#leader_id=Harry
type=Skeleton
blocker=no
[/recruit]
[recruit]
id=Garry_recruitment
importance=1
leader_id=Garry
type=Walking Corpse
#blocker=no
number=8
total=yes
[/recruit]
[/value]
[/aspect]Thank you for your patience.