How do I bring AI factions to recruit only every 3rd turn?

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
Jagr
Posts: 10
Joined: April 11th, 2025, 11:19 am

How do I bring AI factions to recruit only every 3rd turn?

Post by Jagr »

Any ideas how I could do that?

Its for a very large, campaign-like mp scenario, that is foremost meant to be single player.

The constant recruiting of AI sides leads to a trickle or stream of single units, very noticable on large maps.

While a player bunches up his troops and also recruits them in a bunch to send them out together, ai doesn't.

That leads to a lot of outnumbered battles in favour of the player, just hacking down ai troops one by one. Larger battles occur only on chokepoints.

If I could bring ai to be recruitment-blocked for 2 turns, it would spend the acumulated money in the 3rd turn resulting in a bunch of troops being recruited at the same time and marching out together.

Given different movement speeds they still might stretch out on distance, but it still would be a huge improvement gameplaywise.

Just have no idea how to even script that (and Ima WML noob). With the recruitment lists? Via the keeps? Controlling the movement of ai leaders so they are not on keeps for 2 turns?

Thankful for any ideas! =)
User avatar
Ravana
Forum Moderator
Posts: 3294
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do I bring AI factions to recruit only every 3rd turn?

Post by Ravana »

Gold change would be easiest way.
Jagr
Posts: 10
Joined: April 11th, 2025, 11:19 am

Re: How do I bring AI factions to recruit only every 3rd turn?

Post by Jagr »

Ravana wrote: April 17th, 2025, 9:20 pm Gold change would be easiest way.
Would that be so easy if I want AI economy still to work normal?
ie ai gains gold... it accumulates normal depending of no of villages, base income and upkeep over several rounds and ai can recruit
Wouldn't that get lost when you take ai's gold away?

In was just looking at [disallow_recruit] https://wiki.wesnoth.org/DirectActionsW ... recruit.5D
and maybe under sides
[filter_side]
controller=ai
[/filter_side]
?
Jagr
Posts: 10
Joined: April 11th, 2025, 11:19 am

Re: How do I bring AI factions to recruit only every 3rd turn?

Post by Jagr »

you mean like ai -1000gold each round
and then in the 3rd round +3000gold?
would that work correctly?
User avatar
Celtic_Minstrel
Developer
Posts: 2369
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: How do I bring AI factions to recruit only every 3rd turn?

Post by Celtic_Minstrel »

You can probably do this with a recruitment facet.

Something like this in the side's [ai] tag, perhaps (untested):

Code: Select all

[recruitment_instructions]
	# This instructs the AI to recruit normally on the 1st turn and every 3rd turn thereafter
	# You can extend this if it's not enough for your turn limit.
	# Note that, due to the second recruitment_instructions tag below, the AI will never recruit again after the last turn listed here.
	turns=1,4,7,10,13,16,19
	[value]
		[recruit]
			# If you're using a recruitment_pattern, put it here instead.
			# Otherwise, you can leave this [recruit] tag empty (ie delete the next 2 lines).
			type="your,recruitment,pattern"
			pattern=yes
		[/recruit]
	[/value]
[/recruitment_instructions]
[recruitment_instructions]
	# This instructs the AI to recruit nothing at all.
	# It only applies on turns not listed in the above tag.
	[value]
		[recruit]
			number=0
		[/recruit]
	[/value]
[/recruitment_instructions]
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
tsunami_
Posts: 8
Joined: June 22nd, 2024, 2:07 am
Location: Pacific

Re: How do I bring AI factions to recruit only every 3rd turn?

Post by tsunami_ »

There is something a bit like this in Son of the Black Eye: Saving Inarix.
The AI stops recruiting once the gold falls below a certain amount (until turn 8).
Here is the code for the event:

Code: Select all

    [event]
        name=recruit
        first_time_only=no

        [filter]
            side=2,3
        [/filter]

        [store_side]
            side=$unit.side
        [/store_side]

        [if]
            [variable]
                name=side.gold
                {QUANTITY less_than 300 350 400}  # Starting gold is +100 per difficulty level, so this is correct in this order
            [/variable]
            [variable]
                name=turn_number
                less_than=8
            [/variable]
            [then]
                [disallow_recruit]
                    side=$unit.side
                    type=$side.recruit
                [/disallow_recruit]
            [/then]
        [/if]

        {CLEAR_VARIABLE side}
    [/event]
    
For turn 8 there is a "re-allow recruit" event:

Code: Select all

    [event]
        name=side 2 turn 8
        [message]
            speaker=Thelarion
            message= _ "This isn’t working. Mobilize all our troops and send these creatures back to hell."
        [/message]
        [message]
            speaker=Darstang
            message= _ "It won’t be said that Elves were braver than us, everyone attack!"
        [/message]

        [allow_recruit]
            side=2
            type=Elvish Fighter, Elvish Archer, Elvish Shaman, Elvish Scout
        [/allow_recruit]
        [allow_recruit]
            side=3
            type=Dwarvish Fighter, Dwarvish Thunderer, Dwarvish Scout, Footpad, Bandit
        [/allow_recruit]
    [/event]
If you slightly edit these events, then you can make the AI recruit only on certain turns, or once it has stockpiled a certain amount of gold.

-
Post Reply