apply_to=max_attacks negative increase 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.
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
apply_to=max_attacks negative increase not working?
Hi everyone,
I want to create an unit that cannot attack but can defend.
To do so, I apply a modification
This does not work, although the wiki says it should.
However, if I change -1 to 1, it works and the unit has two attacks.
I cannot simply modify the unit, because I want the leveled up unit to still have no attack.
Any idea?
I want to create an unit that cannot attack but can defend.
To do so, I apply a modification
Code: Select all
[modifications]
[object]
[effect]
apply_to=max_attacks
increase=-1
[/effect]
[/object]
[/modifications]
However, if I change -1 to 1, it works and the unit has two attacks.
I cannot simply modify the unit, because I want the leveled up unit to still have no attack.
Any idea?
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: apply_to=max_attacks negative increase not working?
I believe it's possible to have an attack that's enabled on offense and disabled for defense, rather than setting max_attacks to 0 when defending? I'm like 98% sure I've seen that done, but I can't remember how or where at the moment.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Re: apply_to=max_attacks negative increase not working?
Can use this kind of weapon special
Code: Select all
[disable]
id=steppe_attack_only
name=_"attack-only"
description=_"This attack can only be used offensively."
active_on=defense
[/disable]
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
- Lord-Knightmare
- Discord Moderator
- Posts: 2360
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: apply_to=max_attacks negative increase not working?
Steppe Shieldbearer. Steppe Orcs. Extended Era.I want to create an unit that cannot attack but can defend.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: apply_to=max_attacks negative increase not working?
Yes but this is a standard unit (White Mage), who is coming with the hero for its own reasons. He do not want to get involved, so I do not want it to be able to attack.
I solved the problem with a standard max_attacks=0 in the [unit] and in a post advance event.
However, I think the code I posted in the initial message is supposed to work. Otherwise it should be written in the wiki that this cannot reduce max_attacks to 0.
I solved the problem with a standard max_attacks=0 in the [unit] and in a post advance event.
However, I think the code I posted in the initial message is supposed to work. Otherwise it should be written in the wiki that this cannot reduce max_attacks to 0.
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Re: apply_to=max_attacks negative increase not working?
I think in that case of a standard unit the best would belhybrideur wrote: ↑September 24th, 2022, 3:06 pm Yes but this is a standard unit (White Mage), who is coming with the hero for its own reasons. He do not want to get involved, so I do not want it to be able to attack.
Code: Select all
[modifications]
[object]
[effect]
apply_to=attack
[set_specials]
mode=append
[disable]
name=_"attack-only"
description=_"This attack can only be used offensively."
active_on=defense
[/disable]
[/set_specials]
[/effect]
[/object]
[/modifications]
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Re: apply_to=max_attacks negative increase not working?
I think it is useful that it does not go under 1, so I would preserve it in documentation.lhybrideur wrote: ↑September 24th, 2022, 3:06 pm Yes but this is a standard unit (White Mage), who is coming with the hero for its own reasons. He do not want to get involved, so I do not want it to be able to attack.
I solved the problem with a standard max_attacks=0 in the [unit] and in a post advance event.
However, I think the code I posted in the initial message is supposed to work. Otherwise it should be written in the wiki that this cannot reduce max_attacks to 0.
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: apply_to=max_attacks negative increase not working?
Did you try set=0 instead of increase=-1? It seems closer to your intention anyway, since the idea is for the unit to be unable to attack at all. Decreasing max attacks by 1 doesn't do that, it just decreases max attacks by 1, so if it was 2, now the unit can attack twice in a turn.
The code you posted should also work, however. There's probably a bug here.
The code you posted should also work, however. There's probably a bug here.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: apply_to=max_attacks negative increase not working?
There is: The attack is never filtered for. It can't match anything, so it can't be applied. ( EffectWML)Celtic_Minstrel wrote: ↑September 29th, 2022, 4:26 am The code you posted should also work, however. There's probably a bug here.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: apply_to=max_attacks negative increase not working?
From the wiki, I read:
[effect] uses different keys depending on the value of apply_to. apply_to can take the following values:
- attack: find an attack and modify it. All tags from the attack filter construct will be used to match the attack; see FilterWML. After that, the following keys and tags can be used to modify the attack. Note: do not use a [filter] tag. Just put the keys you want to filter on inside the [effect] tag.
- increase_attacks: increases the number of attack strikes. Like increase_damage, it can be positive or negative, or a percentage.
- max_attacks: (Version 1.13.2 and later only) change the unit's maximum attacks per turn
- increase: how much to increase by; can be positive or negative, or a percentage
So there does not seems to be a "set" key for max_attacksCeltic_Minstrel wrote: ↑September 29th, 2022, 4:26 am Did you try set=0 instead of increase=-1? It seems closer to your intention anyway, since the idea is for the unit to be unable to attack at all. Decreasing max attacks by 1 doesn't do that, it just decreases max attacks by 1, so if it was 2, now the unit can attack twice in a turn.
The code you posted should also work, however. There's probably a bug here.
max_attacks is a key of effect not of attacks. Do you mean increase_attacks?beetlenaut wrote: ↑September 29th, 2022, 7:31 amThere is: The attack is never filtered for. It can't match anything, so it can't be applied. ( EffectWML)Celtic_Minstrel wrote: ↑September 29th, 2022, 4:26 am The code you posted should also work, however. There's probably a bug here.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: apply_to=max_attacks negative increase not working?
I don't know what you're asking, but I guess I was not clear. The code I was referring to was, "The code you posted...", where "you" is dwarftough. The comments explain where I think the error is:lhybrideur wrote: ↑September 29th, 2022, 1:15 pm max_attacks is a key of effect not of attacks. Do you mean increase_attacks?
Code: Select all
[modifications]
[object]
[effect]
apply_to=attack
# When you use "apply_to=attack", you also need weapon filters here like:
# range=melee
# type=blade
[set_specials]
mode=append
[disable]
name=_"attack-only"
description=_"This attack can only be used offensively."
active_on=defense
[/disable]
[/set_specials]
[/effect]
[/object]
[/modifications]
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: apply_to=max_attacks negative increase not working?
Code: Select all
attack_weight: helps the AI to choose which attack to use when attacking, setting it to 0 disables the attack on attack. See the note about weights below.
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: apply_to=max_attacks negative increase not working?
Your words do not seem to apply to this situation in the slightest. There is no attack involved in this modification, and the max_attacks effect does not use a filter. If the code shown in the opening post is placed in a place where it has an effect (in this case, abeetlenaut wrote: ↑September 29th, 2022, 7:31 amThere is: The attack is never filtered for. It can't match anything, so it can't be applied. ( EffectWML)Celtic_Minstrel wrote: ↑September 29th, 2022, 4:26 am The code you posted should also work, however. There's probably a bug here.
[unit]
tag or possibly [modify_unit]
), then it should work.Although, maybe that's the issue? Where was that code placed?
Interesting. It could be worth trying anyway in case it exists but is undocumented, though.lhybrideur wrote: ↑September 29th, 2022, 1:15 pm So there does not seems to be a "set" key for max_attacks
Ohhh. I was referring to the code in the opening post. No wonder your response made no sense.beetlenaut wrote: ↑September 29th, 2022, 1:45 pm I don't know what you're asking, but I guess I was not clear. The code I was referring to was, "The code you posted...", where "you" is dwarftough.
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: apply_to=max_attacks negative increase not working?
That is really interesting!!! I will try that.Straff wrote: ↑September 29th, 2022, 2:14 pmhttps://wiki.wesnoth.org/UnitTypeWML#AttacksCode: Select all
attack_weight: helps the AI to choose which attack to use when attacking, setting it to 0 disables the attack on attack. See the note about weights below.
EDIT: I just realized that this would only work with a AI unit, not one controlled by the player, would it?
Yes, it was in an [unit] tag.Celtic_Minstrel wrote: ↑September 30th, 2022, 1:22 amYour words do not seem to apply to this situation in the slightest. There is no attack involved in this modification, and the max_attacks effect does not use a filter. If the code shown in the opening post is placed in a place where it has an effect (in this case, a[unit]
tag or possibly[modify_unit]
), then it should work.
Although, maybe that's the issue? Where was that code placed?
Last edited by lhybrideur on October 2nd, 2022, 6:54 pm, edited 1 time in total.
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: apply_to=max_attacks negative increase not working?
Then yes, that should have worked. This sounds like a bug.