Adding a filterable 'flag' to units during object effects.
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.
Adding a filterable 'flag' to units during object effects.
Hello everyone, and apologies for the title, it's rather difficult to explain my issue in one sentence.
So, here's the state of play:
I have a menu item added to the right-click menu, with several options within it.
Each option adds different weapon specials and abilities to the unit (for a price), this is all working fine.
However, I want to make sure that each unit may only have one of these bonuses applied to it. I *could* simply use the "replace" variant of the "apply_to" effect, or remove existing specials/abilities all together...However, that would also strip the unit of its natural abilities.
The ideal solution would be to add some kind of flag to the unit whenever a bonus is applied, that I could use as a filter to restrict any other bonuses being applied in future. My issue is that I can't find any overlap between what I can modify, and what I can filter, that *doesn't* affect the unit directly (such as level or side)
So in summary, how can I apply a 'mark' to a unit that will cause it to fail standard unit filter checks, without affecting its statistics at all?
Thanks in advance if anyone figures out quite what I was talking about.
So, here's the state of play:
I have a menu item added to the right-click menu, with several options within it.
Each option adds different weapon specials and abilities to the unit (for a price), this is all working fine.
However, I want to make sure that each unit may only have one of these bonuses applied to it. I *could* simply use the "replace" variant of the "apply_to" effect, or remove existing specials/abilities all together...However, that would also strip the unit of its natural abilities.
The ideal solution would be to add some kind of flag to the unit whenever a bonus is applied, that I could use as a filter to restrict any other bonuses being applied in future. My issue is that I can't find any overlap between what I can modify, and what I can filter, that *doesn't* affect the unit directly (such as level or side)
So in summary, how can I apply a 'mark' to a unit that will cause it to fail standard unit filter checks, without affecting its statistics at all?
Thanks in advance if anyone figures out quite what I was talking about.
Re: Adding a filterable 'flag' to units during object effect
If you're using [object]s, then you can add extra keys to your [object] and then filter for those with [filter_wml].
For example, you could add a name= attribute:
And then filter for whether a unit has that [object]:
It's not the world's most convenient method, but it works.
For example, you could add a name= attribute:
Code: Select all
[object]
name=foobar
...
[/object]
Code: Select all
side=1
canrecruit=yes
[filter_wml]
[modifications]
[object]
name=foobar
[/object]
[/modifications]
[/filter_wml]
Re: Adding a filterable 'flag' to units during object effect
Ah, I didn't realise you could name the object itself. I added the same name to all my objects, and put an [and][not] filter on the menu item's [filter_location] tag to pick out anything with that object name. That seems to work; once a unit has been upgraded, the upgrade menu no longer appears for that unit. Success!
Cheers, zookeeper.
Cheers, zookeeper.