Filtering for recruiting-capable locations
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.
Filtering for recruiting-capable locations
Does anyone know if there is a way to use the [filter_location] tag to find all locations where a new unit can be recruited or recalled (i.e. all castles connected to a keep)? While for a simple hexagon-shaped castle this is easy using [filter_adjacent_location], it fails for larger or more complicated structures.
A quick search of the game files didn't turn up any [set_menu_item]s for the recruit and recall commands, but if you can point me to a file where they are defined that would be extremely helpful. If it matters, I'm using the 1.9 releases.
A quick search of the game files didn't turn up any [set_menu_item]s for the recruit and recall commands, but if you can point me to a file where they are defined that would be extremely helpful. If it matters, I'm using the 1.9 releases.
Re: Filtering for recruiting-capable locations
Do you mean all potential recruitable castle hexes or only those with a specific side's leader currently positioned and able to recruit? Don't forget you can also recruit on connected keeps and the hex must be vacant.
Something like this should work:
Something like this should work:
Code: Select all
[filter_location]
[and]
terrain=K*
[filter]
side={SIDE}
canrecruit=yes
[/filter]
radius=400
[filter_radius]
terrain=K*,C*
[/filter_radius]
[/and]
[not]
[filter]
# no unit present
[/filter]
[/not]
[/filter_location]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Filtering for recruiting-capable locations
I think this ought to allow a menu item on any castle or keep hex which is connected to a leader of the current side who must be standing on a keep.
Working on a new campaign? 
Code: Select all
[set_menu_item]
[filter_location]
[filter]
side=$side_number
canrecruit=yes
[filter_location]
terrain=K*
[/filter_location]
[/filter]
radius=99
[filter_radius]
terrain=C*,K*
[/filter_radius]
[/filter_location]

Re: Filtering for recruiting-capable locations
Thanks to both of you! I hadn't fully understood how [filter_radius] worked.
I've gotten back into Wesnoth lately after a several year hiatus, and have started toying around with a new campaign. It's not yet to the point of being worth uploading, however.
I've gotten back into Wesnoth lately after a several year hiatus, and have started toying around with a new campaign. It's not yet to the point of being worth uploading, however.
Re: Filtering for recruiting-capable locations
In case anyone searches for this in the future, my final solution was slightly different from those posted above. I realized that the previous solutions included all the hexes in my castle, but also included every hex adjacent to the castle. The [filter_radius] tag apparently expands one hex outwards from every hex matching its filter, rather than to hexes matching its filter. So the code that worked for me required an additional filter for only matching castle and hex terrain:
I placed all of this inside a [show_menu_item] tag.
Code: Select all
[filter_location]
terrain=C*,K*
[and]
[filter]
side=1
canrecruit=yes
[filter_location]
terrain=K*
[/filter_location]
[/filter]
radius=99
[filter_radius]
terrain=C*,K*
[/filter_radius]
[/and]
[/filter_location]
Re: Filtering for recruiting-capable locations
If that is true, then it is most assuredly a bug.esci wrote:The [filter_radius] tag apparently expands one hex outwards from every hex matching its filter, rather than to hexes matching its filter.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."