[SOLVED] Side filter does not seem to work
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.
[SOLVED] Side filter does not seem to work
In a multiplayer scenario that I'm working on, I want a mechanics inspired by games like Heroes of Might and Magic. Namely, I want the list of units a leader can recruit depend on the type of castle they're currently in. To do it, I'm using moveto and exit_hex events as follows:
This works almost as expected, except the filter does not seem to work. Event seems to be triggered by all sides, not only 1-4. Also the effect seems to apply to all sides, not only to the current side. How can I make it work only for sides 1-4 and to apply only to the side which triggered the event?
Code: Select all
# recruiting elves
[event]
name=moveto
first_time_only=no
[filter]
side=$unit.side
side=1,2,3,4
canrecruit=yes
x,y=70,41
[/filter]
[set_recruit]
side=$side_number
recruit=Elvish Archer,Elvish Fighter,Elvish Scout,Elvish Shaman,Wose,Mage
[/set_recruit]
[/event]
[event]
name=exit_hex
first_time_only=no
[filter]
side=$unit.side
side=1,2,3,4
canrecruit=yes
x,y=70,41
[/filter]
[set_recruit]
side=$side_number
recruit=Peasant,Spearman,Bowman,Mage,Cavalryman,Horseman,Heavy Infantryman,Fencer,Footpad,Thug,Sergeant,Thief,Woodsman,Poacher
[/set_recruit]
[/event]
Last edited by Sventimir on August 14th, 2023, 7:38 am, edited 1 time in total.
- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Side filter does not seem to work
This probably isn't your problem, but you should remove
Beyond that, I'm not sure what to tell you. As far as I can tell, the code you posted should do exactly what you want it to do. Have you verified with
side=$unit.side
as it does nothing. (If that fixes your issue, then I would say that is a bug.)Beyond that, I'm not sure what to tell you. As far as I can tell, the code you posted should do exactly what you want it to do. Have you verified with
:inspect
that other sides are also changing their recruit list at the same time?Re: Side filter does not seem to work
To explain further, `side=$unit.side` does not do anything, because there is also `side=1,2,3,4` and last value of each key applies.
Re: Side filter does not seem to work
Initially I didn't write side=$unit.side, I added it later thinking maybe it'd solve the problem, but it didn't/ Thanks for explanation, anyway.
Not yet. But I observed that other sides' recruitment lists change in a way consistent with what I described above.Have you verified with :inspect that
Re: Side filter does not seem to work
You need to understand whether issue is when to change, or how to change. That would give information which tag to focus on.
Re: Side filter does not seem to work
Okay, I debugged the issue and understood it. The problem was actually not in the piece of code that I have shown, buit in another, handling another type of castle, of which there were multiple instances. The reason for error was my misunderstanding of how
Inspection showed that the two
it works as expected. Thanks everyone for hints!
[or]
tag works. I wrote:Code: Select all
[filter]
side=1,2,3,4
canrecruit=yes
[or]
x,y=44,52
x,y=17,67
[/or]
[/filter]
x,y
conditions are not or-ed, but rather the latter overwrites the first. On top of that or
makes it a condition alternative to the previous ones (this is very unintuitive!). When changed to this:
Code: Select all
[filter]
side=1,2,3,4
canrecruit=yes
[and]
x,y=44,52
[or]
x,y=17,67
[/or]
[/and]
[/filter]
- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [SOLVED] Side filter does not seem to work
I just had the thought that it would technically be more correct to use
[set_extra_recruit]
instead of [set_recruit]
to achieve your stated mechanics. It only makes a difference if a side can have multiple leaders, so maybe it's not relevant to your scenario, but if you wanted to turn this into a modification that works with any scenario, then you should definitely consider it.Re: [SOLVED] Side filter does not seem to work
But
set_extra_recruits
will define additional recruits attached to the leader, right? To achieve what I want I'd need to set the side's standard recruit list to be empty and only use extra recruits. Right?- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact: