How can I instruct AI not to recruit? A piece of code from Wiki seems not working

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
dwarftough
Posts: 484
Joined: August 4th, 2019, 5:27 pm

How can I instruct AI not to recruit? A piece of code from Wiki seems not working

Post by dwarftough »

https://wiki.wesnoth.org/AI_Recruitment ... structions has some interesting examples of code, one of them is "Don't recruit on turn 4". I tried using this code but it doesn't work for some reason

So I added

Code: Select all

[ai]
  [aspect]
    id=recruitment_instructions
    [facet]
      turns=1-4
      [value] 
        [recruit]
          importance=1
          number=0
        [/recruit]
      [/value]
    [/facet]
  [/aspect]
[/ai]
to the AI side definition and it didn't work: recruited a full keep immediately, inspect shows no special ai recruit instructions, just default AI.

But if I use this (almost the same code)

Code: Select all

[ai]
  [aspect]
    id=recruitment_instructions
    [facet]
      turns=1-4
      [value] 
        [recruit]
          importance=1
          number=1
        [/recruit]
      [/value]
    [/facet]
  [/aspect]
[/ai]
it works fine! AI recruits just one unit even if it has gold for more. And inspect shows the instructions.

So it seems number=0 instruction ignored somehow. How then do I instruct AI not to recruit? And maybe we may update the wiki page with a new solution?
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How can I instruct AI not to recruit? A piece of code from Wiki seems not working

Post by beetlenaut »

Is there a reason you need to do it this way? This seems needlessly complex. You could just not define any recruits for the AI, then add them in a turn 4 [event] using [modify_side].

If the point is that you may have discovered a bug, then yes, I would report this on the bug tracker.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
dwarftough
Posts: 484
Joined: August 4th, 2019, 5:27 pm

Re: How can I instruct AI not to recruit? A piece of code from Wiki seems not working

Post by dwarftough »

beetlenaut wrote: January 8th, 2024, 7:13 am Is there a reason you need to do it this way? This seems needlessly complex.
You think it's needlessly complex? The scenario in question has a lot of nuanced AI settings, including recruitment_instructions, so I thought disabling and enabling recruitment in events would be an inconsistent approach, instead of adding another recruitment_instruction. But ofc as a workaround I will have to do something of this kind.
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Post Reply