Managing the recruit list

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
User avatar
SFault
Posts: 483
Joined: November 10th, 2009, 2:21 pm
Location: Esbo, Finland

Managing the recruit list

Post by SFault »

In the campaign I have defined the recruit list in the first scenario and in later scenario dwarvish fighters should be added to the list. It seems that with [set_recruit] I define the whole list from scratch and that is not what I want*. I assumed that set_extra_recruit does the trick but it doesn't seem to work. The basic list seems to carry on nicely but this addition doesn't.

This is what I have in the event when opponent leader is killed and then the scenario ends. Idea is that after this the dwarves are added to the recruit list among the previous units.

Code: Select all

[message]
    speaker=narrator
    message= _ "You can recruit Dwarvish Fighters now."
    image=units/dwarves/fighter.png
[/message]
[set_extra_recruit]
	extra_recruit=Dwarvish Fighter
[/set_extra_recruit]
On another note, is it possible to read and store the recruit list into a variable? Do I need to store the whole side to do this?

* the scenarios come in various order and I don't know if the recruit list is already altered. I could keep a boolean variable to track if some unit should be included into recruit list, but this doesn't seem good way because I'm scaling up into several recruitable units and having the list altered in various scenarios.
segmentation fault
EBfW, GtR, Art, Old art
User avatar
James_The_Invisible
Posts: 536
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: Managing the recruit list

Post by James_The_Invisible »

There is allow_recruit which allows you to add new unit types to recruit list.
For reading/storing recruit list, see this example: https://github.com/konecnyjakub/For_Pow ... fg#L80-L84.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Managing the recruit list

Post by beetlenaut »

The reason [set_extra_recruit] didn't work is that you didn't specify which leader should get the extra recruit. That's what the standard unit filter (mentioned in the wiki) is for. [allow_recruit] works for a side instead of a leader.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
SFault
Posts: 483
Joined: November 10th, 2009, 2:21 pm
Location: Esbo, Finland

Re: Managing the recruit list

Post by SFault »

Ah, thanks for both. I really should read the API doc more carefully. :doh:
(Although, the descriptions could also be bit more clear. Or perhaps the tags could be set_side_recruit & set_leader_recruit...)
beetlenaut wrote:The reason [set_extra_recruit] didn't work is that you didn't specify which leader should get the extra recruit. That's what the standard unit filter (mentioned in the wiki) is for. [allow_recruit] works for a side instead of a leader.
So, if I would have two leader, e.g. elf and dwarf, I could use this so that the elf leader could recruit only elf units and dwarf only dwarves? Interesting.
segmentation fault
EBfW, GtR, Art, Old art
Post Reply