How and when effects of advancements are computed

The place to post your WML questions and answers.

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.
Post Reply
Ptitboul
Posts: 73
Joined: May 8th, 2021, 3:45 pm

How and when effects of advancements are computed

Post by Ptitboul »

The following piece of code has the same behaviour with 1.12 and 1.14.

Code: Select all

#ifver WESNOTH_VERSION >= 1.13.2
#define ADVANCEMENT
advancement#enddef
#else
#define ADVANCEMENT
advance#enddef
#endif

        {UNIT 1 "Royal Guard" 27 12 name="test1"}
        [object]
            name=darts
            [filter]
                x,y=27,12
            [/filter]
            [effect]
                apply_to=new_attack
                name=other_weapon
                type=pierce
                range=ranged
                damage=10
                number=3
            [/effect]
        [/object]
        [store_unit]
            [filter]
                x,y=27,12
            [/filter]
            variable=unit
        [/store_unit]
        [set_variables]
            name=unit.modifications.{ADVANCEMENT}
            mode=append
            [value]
                [effect]
                    apply_to=attack
                    [set_specials]
                        {WEAPON_SPECIAL_BACKSTAB}
                    [/set_specials]
                [/effect]
            [/value]
        [/set_variables]
        [unstore_unit]
            variable=unit
            find_vacant=no
        [/unstore_unit]

        [unit]
            name="test2"
            side=$unit.side
            x=$unit.x
            y=$unit.y
            type=$unit.type
            [insert_tag]
                name=modifications
                variable=unit.modifications
            [/insert_tag]
        [/unit]
The Royal Guard named "test1" has no attack with backstab.
The Royal Guard named "test2" has only his sword attack with backstab.

I would have expected that both have their two attacks with backstab... which means that there is something that I don't understand.

(edit) With 1.15.15, it is slightly different: "test1" has no backstab, and "test2" has his two attacks with backstab, which is the result I expected.
But I did not see this change documented in https://github.com/wesnoth/wesnoth/blob ... angelog.md
My campaign, Bloodlust, is is need of feedback!
Ptitboul
Posts: 73
Joined: May 8th, 2021, 3:45 pm

Re: How and when effects of advancements are computed

Post by Ptitboul »

No answer...

Does it mean that it is normal that the behaviour of this piece of WML is not consistent across versions, maybe because one should not add advancements by modifying the content of unit.modifications, and that one should not create a unit with a modifications tag?

Or does it mean that the behaviour of 1.12 and 1.14 is broken and that 1.15 corrects this bug?

Or does it mean something else?
My campaign, Bloodlust, is is need of feedback!
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: How and when effects of advancements are computed

Post by Pentarctagon »

The changelog doesn't document every change to WML's behavior. As for whether it's an intentional change or not, the answer is that it probably is, but without digging in and finding which specific commit caused this change it's hard to say for sure whether this specific scenario was one that was thought of or not.

One thing you could do for the future though is submit unit tests that cover functionality that you use. Those tests are run every time anyone changes anything in Wesnoth's code, so they'll catch changes to functionality you're depending on whether they're intentional or not.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Ptitboul
Posts: 73
Joined: May 8th, 2021, 3:45 pm

Re: How and when effects of advancements are computed

Post by Ptitboul »

Thanks.
I will make the assumption that the 1.15 behaviour is the right one (and submit a unit test).
I will also need to find how to emulate this behaviour with older versions...
My campaign, Bloodlust, is is need of feedback!
Ptitboul
Posts: 73
Joined: May 8th, 2021, 3:45 pm

Re: How and when effects of advancements are computed

Post by Ptitboul »

In my campaign I have emulated the behaviour of 1.15/1.16 in older versions (1.12 and 1.14) by moving advancement effects into objects.
I did not submit a unit test for 1.16 yet.
My campaign, Bloodlust, is is need of feedback!
Post Reply