abilities, events, and other black magic [SOLVED]

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
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

abilities, events, and other black magic [SOLVED]

Post by KanoFromMK »

ok, I give up
some months ago i posted a wrongfully named question about abilities that i named traits
in which i tried to understand how does it work and why it doesn't work on me
good people here helped me, thanks a lot, but then i tried to copy an ability from one campaign to the main game
I failed, and wiki.wesnoth didn't help me, i mean it tried but i'm apparently dumb enough to not understand.
So here I am, with humility, asking the good people here to help me again:
There is an UTBS-campaign-only ability named Disengage
As an example the Quenoth Archer has it. In utils\abilities.cfg it looks like this

Code: Select all

#define ABILITY_DISENGAGE
    [dummy]
        id=disengage
        name= _ "disengage"
        female_name= _ "female^disengage"
        description= _ "If this unit doesn’t move before attacking, it will retain its movement points after the attack."
        special_note=_"This unit can move either before or after attacking."
    [/dummy]
#enddef
and this

Code: Select all

#define ABILITY_DISENGAGE_EVENTS
    [event]
        name=attack end
        first_time_only=no

        [filter]
            ability=disengage

            [not]
                [filter_wml]
                    moves=$this_unit.max_moves
                [/filter_wml]
            [/not]
        [/filter]

        {VARIABLE unit.moves 0}

        [unstore_unit]
            variable=unit
            find_vacant=no
        [/unstore_unit]
    [/event]
#enddef
What i want is to port this ability to the main game, for it to be "global", and to add it to all undead units;
adding to undeads is trivial, what is not trivial for me is the first part.
Last edited by KanoFromMK on July 8th, 2024, 12:01 pm, edited 1 time in total.
User avatar
Ravana
Forum Moderator
Posts: 3314
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: abilities, events, and other black magic

Post by Ravana »

Main solutions are
1) have event in [era] or [campaign], that is probably what UTBS does
2) use +tag syntax to include copy of the event in each unit that has such ability, example https://github.com/ProditorMagnus/Agele ... ad.cfg#L10
white_haired_uncle
Posts: 1456
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: abilities, events, and other black magic

Post by white_haired_uncle »

Is that event meant to stand on its own, or is there some other event(s) that it is affecting?

Seems to me, after an attack your moves are set to 0 anyway. Or perhaps you can't move if attacks=0, and so some this makes it so only units with disengage that didn't move will have moves>0, so some other event will not enable them to move. Or something. I can come up with some pretty out there theories, but nothing that doesn't involve some code not shown above.

What am I missing?
Speak softly, and carry Doombringer.
User avatar
octalot
General Code Maintainer
Posts: 818
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: abilities, events, and other black magic

Post by octalot »

white_haired_uncle: the missing piece is every attack of every unit with that ability has [attack]movement_used=0.

KanoFromMK: that's an old version of the WML, because of the Tailwind ability it now needs to check for formula = "self.moves<self.max_moves" instead.
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: abilities, events, and other black magic

Post by KanoFromMK »

octalot wrote: July 1st, 2024, 4:20 pm white_haired_uncle: the missing piece is every attack of every unit with that ability has [attack]movement_used=0.

KanoFromMK: that's an old version of the WML, because of the Tailwind ability it now needs to check for formula = "self.moves<self.max_moves" instead.
Thanks for your time. Where can I update the WML? And will the updated WML help me with my problem? If yes, how?
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: abilities, events, and other black magic

Post by KanoFromMK »

Ravana wrote: July 1st, 2024, 2:26 pm Main solutions are
1) have event in [era] or [campaign], that is probably what UTBS does
2) use +tag syntax to include copy of the event in each unit that has such ability, example https://github.com/ProditorMagnus/Agele ... ad.cfg#L10
Thank for answering. For 2) I'm not that good with coding, can you help me understand what am I looking at? Or if the first solution is simpler can you please help me implement it?
User avatar
Ravana
Forum Moderator
Posts: 3314
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: abilities, events, and other black magic

Post by Ravana »

I will not. I am not good at explaining. I might answer if you ask something specific.
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: abilities, events, and other black magic

Post by KanoFromMK »

Ravana wrote: July 2nd, 2024, 8:43 pm I will not. I am not good at explaining. I might answer if you ask something specific.
Can I write you in private to not litter the forum?
User avatar
Ravana
Forum Moderator
Posts: 3314
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: abilities, events, and other black magic

Post by Ravana »

No.
User avatar
octalot
General Code Maintainer
Posts: 818
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: abilities, events, and other black magic

Post by octalot »

KanoFromMK wrote: July 2nd, 2024, 10:49 pm Can I write you in private to not litter the forum?
It's already possible to rename threads, which might avoid the need to create new ones. If you're the author of the first post of a thread, editing that post's title also renames the thread AFAIK.
It might make sense to merge this thread into https://r.wesnoth.org/t58084 , but merging threads can only be done by moderators.
KanoFromMK wrote: July 2nd, 2024, 8:34 pm Where can I update the WML? And will the updated WML help me with my problem?
Update it by getting a new copy it from the current version of UtBS. However, no, that won't solve any problems except for "disengage doesn't work when the unit was healed by a Quenoth Shaman (with the Tailwind ability) that turn".

Part of the problem is that UtBS has implemented the ability by putting [attack]movement_used=0 into the unit definitions, for example into data/campaigns/Under_the_Burning_Suns/units/quenoth/Outrider.cfg, instead of putting it into the ability. To apply it to other units, you need some EffectWML:

Code: Select all

    [effect]
        apply_to=attack
        set_movement_used=0
That, on its own, ought to make the attacks never use up movement. Once that's working, add in the ABILITY_DISENGAGE_EVENTS to make it work as it does in UtBS.
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: abilities, events, and other black magic

Post by KanoFromMK »

Oh My God
it was so simple
thanks man you're F-ing hero
yes indeed, adding movement_used=0 into [attack][/attack] solved the problem
i dont understand how events work its still black magic to me, but its not that hard either to add this movement_used=0 to every unit in undead, certainly easier than to try to make it as a normal person would
again i dont know how to close the subject and label it as solved, is that also the forum moderator's job?
Thanks again and good luck to all that tried to help me and you who managed to helped me
User avatar
lhybrideur
Posts: 454
Joined: July 9th, 2019, 1:46 pm

Re: abilities, events, and other black magic

Post by lhybrideur »

You can change the name of the post to add SOLVED by editing the first message.
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: abilities, events, and other black magic

Post by KanoFromMK »

oh thanks, i will
Post Reply