Weapon filter not working
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.
Weapon filter not working
I'm trying make a weapon special that multiplies the weapon damage by 3x whenever it defends against an attacker using the charge special on its own weapon:
It's not working, it's behaving in erratic manner against attacks that have nothing to do with the "charge" special. What is wrong with the code? Can you show me the right code?
Code: Select all
#define WEAPON_SPECIAL_SPEARWALL
[damage]
id=spearwall
name= _ "spearwall"
description= _ "This counter attack causes 3x damage against charging attackers"
name_inactive = "spearwall"
description_inactive = "This counter attack causes 3x damage against charging attackers"
multiply=3
active_on=defense
[filter_opponent]
[has_attack]
special_id_active=charge
[/has_attack]
[/filter_attacker]
[/damage]
#enddef
Re: Weapon filter not working
Use [filter_weapon] not [has_attack]. And in my experience special_id_active is not completely reliable, so try without _active too.
Re: Weapon filter not working
Hmm but has_attack should also work, right? I'm quite sure that I have used code like this my addon before.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: Weapon filter not working
filter_weapon checks weapon used in current attack.
Re: Weapon filter not working
Code: Select all
#define WEAPON_SPECIAL_SPEARWALL
[damage]
id=spearwall
name= _ "spearwall"
description= _ "Defender causes 3X the damage against charging attackers"
name_inactive = "spearwall"
description_inactive = "Defender causes 3X the damage charging attackers"
multiply=3
active_on=defense
[filter_attacker]
[filter_weapon]
special_id=charge
[/filter_weapon]
[/filter_attacker]
[/damage]
#enddef
Still not working. It always just multiplies the weapon damage on defense by 3 against any attackers. As if it had no filter at all.
-
- Code Contributor
- Posts: 165
- Joined: October 6th, 2017, 12:57 pm
Re: Weapon filter not working
Have you used 1.14 or 1.15.2 or1.15.3? Because special_id or special_type were implemented in oct 2019 in devellopement branch and no in 1.14 stable branch. If you not used 1.15.2 or 1.15.3 you must replace special_id by old special.
Re: Weapon filter not working
Thanks, that did the jobyou must replace special_id by old special.
Code: Select all
#define WEAPON_SPECIAL_SPEARWALL
[damage]
id=spearwall
name= _ "spearwall"
description= _ "Defender causes 2X the damage against charging opponents"
name_inactive = "spearwall"
description_inactive = "Defender causes 2X the damage charging opponents"
multiply=2
active_on=defense
[filter_attacker]
[filter_weapon]
special=charge
[/filter_weapon]
[/filter_attacker]
[/damage]
#enddef
- Celtic_Minstrel
- Developer
- Posts: 2166
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Weapon filter not working
They both work, but do different things.
- Putting
[has_attack]
in the[filter_opponent]
means it'll match for any enemy that has an attack matching the weapon filter, regardless of whether they're using that weapon in this particular fight. - Using
[filter_weapon]
in the[filter_opponent]
means it'll match only if the attack currently being used by the enemy matches the filter. This is not part of the standard unit filter - it's a special thing used by the weapon special code.
Re: Weapon filter not working
New problem. I wish to make a weapon special that makes the owner harder to hit when he is adjacent to friendly units. Here is my attempt for one adjacent friend:
The filter is not being met for some reason and the special never does anything. What is wrong now?
Code: Select all
#define WEAPON_SPECIAL_DFORMATION1
[chance_to_hit]
id=dformation1
name= _ ""
description= _ "makes 5% harder to hit when next to a friend"
sub=5
apply_to=opponent
[filter_adjacent]
is_enemy=no
count=1
adjacent= "n,ne,se,s,sw,nw"
[/filter_adjacent]
[/chance_to_hit]
#endef
Re: Weapon filter not working
Celtic_Minstrel wrote: ↑April 4th, 2020, 4:24 pm Putting[has_attack]
in the[filter_opponent]
means it'll match for any enemy that has an attack matching the weapon filter, regardless of whether they're using that weapon in this particular fight.
In the general case yes, but if you use special_active and that weapon special itself has a filter, then special_active will only return true for the weapon that is currently used in the combat.
In fact [has_attack] has to be used over [filter_attack] in events that handle wepopn specials, see https://github.com/wesnoth/wesnoth/issues/3317 (this is iirc because [filter_attack] is evalated on a _copy_ of the attack object that was used in combat that has the attack context not set correctly.)
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: Weapon filter not working
It just means that event-based specials must have all filtering inside event.
Re: Weapon filter not working
I dont see how it would mean that
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: Weapon filter not working
I understood your post that _active does not work. And I believe _active is only about conditions defined inside ability. So when all conditions are in event, then it does not matter that _active does not work properly.
Re: Weapon filter not working
well technicially true, but this means that an ability cannot be used with filters, mainline weapon specials like poison can be used with any filter so that for example one unit only poisons unit with a lower level, and other units only poion drakes. puttins all filters in the wepon special implementation removes this flexibility. (and it will show the ability wrongly as active in the attack dialog)
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
-
- Code Contributor
- Posts: 165
- Joined: October 6th, 2017, 12:57 pm
Re: Weapon filter not working
try thisGibimbius wrote: ↑April 4th, 2020, 6:37 pm New problem. I wish to make a weapon special that makes the owner harder to hit when he is adjacent to friendly units. Here is my attempt for one adjacent friend:
The filter is not being met for some reason and the special never does anything. What is wrong now?Code: Select all
#define WEAPON_SPECIAL_DFORMATION1 [chance_to_hit] id=dformation1 name= _ "" description= _ "makes 5% harder to hit when next to a friend" sub=5 apply_to=opponent [filter_adjacent] is_enemy=no count=1 adjacent= "n,ne,se,s,sw,nw" [/filter_adjacent] [/chance_to_hit] #endef
Code: Select all
[chance_to_hit]
id=dformation1
name= _ ""
description= _ "makes 5% harder to hit when next to a friend"
sub=5
apply_to=opponent
[filter_self]
[filter_adjacent]
is_enemy=no
count=1-5
[/filter_adjacent]
[/filter_self]
[/chance_to_hit]