How to make leadership apply only to mages
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.
-
- Posts: 7
- Joined: December 19th, 2022, 8:42 pm
How to make leadership apply only to mages
Hi everyone,
I am trying to make an leadership ability where the damage bonus only applies to adjacent mages of a lower level. However, it doesn’t work; no unit gets a damage bonus, regardless of whether that unit is a mage or not. Would anyone be able to help?
I am trying to make an leadership ability where the damage bonus only applies to adjacent mages of a lower level. However, it doesn’t work; no unit gets a damage bonus, regardless of whether that unit is a mage or not. Would anyone be able to help?
Code: Select all
#define ABILITY_MAGICAL_LEADERSHIP
[leadership]
id=magical_leadership
name=_"magical leadership"
description=_"This unit provides a damage bonus to adjacent lower-level units that are mages."
affect_self=no
value="(25 * (level - other.level))"
[filter_student]
[filter_weapon]
special_id=magical
[/filter_weapon]
[/filter_student]
[/leadership]
#enddef
Re: How to make leadership apply only to mages
[filter_weapon] is not recognized tag of https://wiki.wesnoth.org/StandardUnitFilter. Perhaps you mean [has_attack].
-
- Posts: 7
- Joined: December 19th, 2022, 8:42 pm
Re: How to make leadership apply only to mages
Well-spotted. But changing it to [has_attack] does not fix the problem unfortunately. I noticed that in Wesnoth's code, the leadership macro uses [affect_adjacent] so I tried that. Without affect_adjacent, it does nothing. With affect_adjacent, it works just like normal leadership (no filtering is applied) so I am guessing something is wrong with the filtering code?Ravana wrote: ↑February 10th, 2023, 10:43 am [filter_weapon] is not recognized tag of https://wiki.wesnoth.org/StandardUnitFilter. Perhaps you mean [has_attack].
EDIT: so the [filter_student] filter does not work. Either this is a bug or I am just using it wrong. It works fine when using the standard [filter] tag.
This does not work:
Code: Select all
#define ABILITY_MAGICAL_LEADERSHIP
[leadership]
id=magical_leadership
name=_"magical leadership"
description=_"This unit provides a damage bonus to adjacent lower-level units that are mages."
affect_self=no
value="(25 * (level - other.level))"
[affect_adjacent]
[filter_student]
[has_attack]
special_id=magical
[/has_attack]
[/filter_student]
[/affect_adjacent]
[/leadership]
#enddef
Code: Select all
#define ABILITY_MAGICAL_LEADERSHIP
[leadership]
id=magical_leadership
name=_"magical leadership"
description=_"This unit provides a damage bonus to adjacent lower-level units that are mages."
affect_self=no
value="(25 * (level - other.level))"
[affect_adjacent]
[filter]
[has_attack]
special_id=magical
[/has_attack]
[/filter]
[/affect_adjacent]
[/leadership]
#enddef
- Spannerbag
- Posts: 539
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: How to make leadership apply only to mages
Weird.Alex_Stargazer wrote: ↑February 10th, 2023, 11:55 am EDIT: so the [filter_student] filter does not work. Either this is a bug or I am just using it wrong. It works fine when using the standard [filter] tag.
I have this macro that works:
Code: Select all
#define ABILITY_PEASANT_LEADER
[leadership]
id=peasant_leader
value="(25 * level)"
cumulative=no
name= _ "peasant leader"
female_name= _ "female^peasant leader"
description= _ "This unit has significant military experience and by using encouragment and practical advice raises the morale of adjacent untrained combatants (peasantry) of the same side so they inflict more damage."
special_note=_"This unit inspires adjacent zero level units of the same side to deal more damage in combat."
affect_self=yes
[affect_adjacent]
[filter_student]
# type=Peasant
level=0
[/filter_student]
[/affect_adjacent]
[/leadership]#enddef
Leader Leader not adjacent Leader adjacent Leader correctly adds +50% damage (leader is L2).
I can only guess that as I don't use
other.level
(peasants are L0) then maybe with the student filter you need student.level
?EDIT: I know the wiki says otherwise but it might be worth trying anyway?
Just a thought, hope it helps.
Cheers!
-- Spannerbag
-
- Posts: 7
- Joined: December 19th, 2022, 8:42 pm
Re: How to make leadership apply only to mages
It’s nice to see a working example. The difference between my code and your code is that I am using [has_attack] which for some reason does not work with [filter_student] but does work with the standard [filter]. I guess filter_student is not a StandardUnitFilter but something else. Anyway, I was able to get it working with just the normal filter, but thanks for the input!Spannerbag wrote: ↑February 10th, 2023, 12:32 pmWeird.Alex_Stargazer wrote: ↑February 10th, 2023, 11:55 am EDIT: so the [filter_student] filter does not work. Either this is a bug or I am just using it wrong. It works fine when using the standard [filter] tag.
I have this macro that works:
Screen dumps:Code: Select all
#define ABILITY_PEASANT_LEADER [leadership] id=peasant_leader value="(25 * level)" cumulative=no name= _ "peasant leader" female_name= _ "female^peasant leader" description= _ "This unit has significant military experience and by using encouragment and practical advice raises the morale of adjacent untrained combatants (peasantry) of the same side so they inflict more damage." special_note=_"This unit inspires adjacent zero level units of the same side to deal more damage in combat." affect_self=yes [affect_adjacent] [filter_student] # type=Peasant level=0 [/filter_student] [/affect_adjacent] [/leadership]#enddef
LeaderPL.png
Leader not adjacent
PL1.png
Leader adjacent
PL2.png
Leader correctly adds +50% damage (leader is L2).
I can only guess that as I don't useother.level
(peasants are L0) then maybe with the student filter you needstudent.level
?
EDIT: I know the wiki says otherwise but it might be worth trying anyway?
Just a thought, hope it helps.
Cheers!
-- Spannerbag
- Celtic_Minstrel
- Developer
- Posts: 2238
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to make leadership apply only to mages
Yes,
[filter_student]
is not part of StandardUnitFilter. It's something only supported in a leadership-like ability, which means it can't be placed in [affect_adjacent]
but can be placed beside [affect_adjacent]
.-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: How to make leadership apply only to mages
try that:
[filter_student] replace [filter_self] from weaponspecials when they are encoded in [abilities] tag but for [leadership] or [resistance] you must use directly [filter_weapon] or [filter_second_weapon]
Code: Select all
#define ABILITY_MAGICAL_LEADERSHIP
[leadership]
id=magical_leadership
name=_"magical leadership"
description=_"This unit provides a damage bonus to adjacent lower-level units that are mages."
affect_self=no
value="(25 * (level - other.level))"
[filter_weapon]
special_id_active=magical
[/filter_weapon]
[affect_adjacent]
[/affect_adjacent]
[/leadership]
#enddef
-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: How to make leadership apply only to mages
and for peasant his is
Code: Select all
#define ABILITY_PEASANT_LEADER
[leadership]
id=peasant_leader
value="(25 * level)"
cumulative=no
name= _ "peasant leader"
female_name= _ "female^peasant leader"
description= _ "This unit has significant military experience and by using encouragment and practical advice raises the morale of adjacent untrained combatants (peasantry) of the same side so they inflict more damage."
special_note=_"This unit inspires adjacent zero level units of the same side to deal more damage in combat."
affect_self=yes
[affect_adjacent]
[filter]
# type=Peasant
level=0
[/filter]
[/affect_adjacent]
[/leadership]
#enddef
Re: How to make leadership apply only to mages
This is cool, I'm always stunned what I ideas there are out there for new abilities. Really cool.
@newfrenchy83
One question about your code:
[filter_weapon]
special_id_active=magical
[/filter_weapon]
[affect_adjacent]
[/affect_adjacent]
As far as I understand this code will not effect adjacent units, but all units with the special-id?
@newfrenchy83
One question about your code:
[filter_weapon]
special_id_active=magical
[/filter_weapon]
[affect_adjacent]
[/affect_adjacent]
As far as I understand this code will not effect adjacent units, but all units with the special-id?
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: How to make leadership apply only to mages
And[filter_weapon]: If present, the leadership ability only takes effect when the owner of the ability uses a matching weapon.
Code: Select all
[affect_adjacent]
[/affect_adjacent]
Code: Select all
[affect_adjacent]
adjacent=n,ne,se,s,sw,nw
[/affect_adjacent]
So I think the error is in [filter_weapon] It should be:
[affect_adjacent] [filter] [has_attack] special_id_active=magical
instead-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: How to make leadership apply only to mages
the abilities affect all adjacent units of same side of owner who use weapon with special magical active, if you want affect all allies addd affect_allies=yes and affect_enemies =yes for enemies
-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: How to make leadership apply only to mages
if you want aplied to mage same when use non magical attack then filter_weapon not good idea, if you want applied to magical attack only, yes.
Re: How to make leadership apply only to mages
Doesn'tnewfrenchy83 wrote: ↑February 14th, 2023, 6:46 pm if you want aplied to mage same when use non magical attack then filter_weapon not good idea, if you want applied to magical attack only, yes.
special_id_active
already do the work, which only matches if the weapon uses magical ability?-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: How to make leadership apply only to mages
i want said special_id_active in [filter_weapon], and yes, only if weapn use special_ability(somespecial don't ever active)