traits

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

traits

Post by KanoFromMK »

How can i convert traits from specific campaigns to those traits that come by default (like skirmisher or submerge)
I wanted to just copy everything (imo) relevant to "disengage" trait but it doesn't work properly (actually it doesn't work at all, only the description)
also why this doesn't work, its a dumb question but i need to know why it doesn't work
#define ABILITY_NINJA
[hides]
id=ninja
name= _ "ninja"
description= _ "This unit can hide like a true ninja"
special_note=_"This unit can hide in the forest or in villages, except water ones. And can become almost invisible at night."
affect_self=yes
[filter]
[filter_location]
terrain=*^V*,*^F*,D*^*
[/filter_location]
[filter_location]
time_of_day=chaotic
[/filter_location]
[/filter]
[/hides]
#enddef
User avatar
Ravana
Forum Moderator
Posts: 3018
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: traits

Post by Ravana »

You should clarify what you mean by doesnt work.
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: traits

Post by white_haired_uncle »

Yeah, "doesn't work" isn't much to go on. I wonder if this will help (from a [unit] declaration):

Code: Select all

        [modifications]
            [advancement]
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_NINJA}
                    [/abilities]
                [/effect]
            [/advancement]
        [/modifications]
Speak softly, and carry Doombringer.
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2365
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: traits

Post by Lord-Knightmare »

What you mean by traits are "abilities" (submerge/skirmisher).

Disengage is not the ability definition itself, rather has a global event which is used in every scenario of that campaign (UtbS) to make it work.

Also, ability Ninja might now work since you have two "[filter_location]" tags. You might wish to combine them into one:

Code: Select all

[filter_location]
    terrain=*^V*,*^F*,D*^*
    [or]
        time_of_day=chaotic
    [/or]
[/filter_location]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

white_haired_uncle wrote: April 16th, 2024, 2:37 am Yeah, "doesn't work" isn't much to go on. I wonder if this will help (from a [unit] declaration):

Code: Select all

        [modifications]
            [advancement]
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_NINJA}
                    [/abilities]
                [/effect]
            [/advancement]
        [/modifications]
sorry) didn't know how to put it otherwise, bc the only thing i see is it doesn't work, i don't know why or what else can i add to be more specific
UPD: thank you a lot for helping me out, your code wasn't actually needed at all and all i need to do was what Lord-Knightmare has written, i.e. to combine two filters into one, i added this update bc you wondered if your code helped and i thought an answer might be welcomed from me
Last edited by KanoFromMK on April 16th, 2024, 11:11 am, edited 1 time in total.
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

Lord-Knightmare wrote: April 16th, 2024, 8:13 am What you mean by traits are "abilities" (submerge/skirmisher).

Disengage is not the ability definition itself, rather has a global event which is used in every scenario of that campaign (UtbS) to make it work.

Also, ability Ninja might now work since you have two "[filter_location]" tags. You might wish to combine them into one:

Code: Select all

[filter_location]
    terrain=*^V*,*^F*,D*^*
    [or]
        time_of_day=chaotic
    [/or]
[/filter_location]
sorry, yes you're right, i was thinking about abilities, not traits
UPD: yes, this indeed has worked, now "my" ninja ability works properly, thank you very much, take this +200 to your karma
UPD2: btw, if this disengage ability is tied to every scenario in UTBS campaign, is it possible to create an analog ability with the same effect to add it to undead units? if yes can you help me please with it?
Last edited by KanoFromMK on April 16th, 2024, 11:39 am, edited 2 times in total.
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

Ravana wrote: April 15th, 2024, 11:30 pm You should clarify what you mean by doesnt work.
it meant exactly that, didn't clarify because i didn't know what else to add and/or what is relevant
i know its dumb to come to people and ask for help not specifying what the problem is in the first place but i really didn't know what else to add
thanks for advice though, ill try to be more clear and attentive in the future, if possible
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2365
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: traits

Post by Lord-Knightmare »

UPD2: btw, if this disengage ability is tied to every scenario in UTBS campaign, is it possible to create an analog ability with the same effect to add it to undead units? if yes can you help me please with it?
I mean sure. If you can describe what you want the ability to do, I am sure me or some other dev/veteran coder here would be very happy to lend a hand.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Ravana
Forum Moderator
Posts: 3018
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: traits

Post by Ravana »

From code review, unit should be hidden during night on specific terrain. You did not say what situations you tested.
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

Ravana wrote: April 16th, 2024, 2:28 pm From code review, unit should be hidden during night on specific terrain. You did not say what situations you tested.
that's true, my bad, i've tested on village OR at night OR in the forest, but not anything combined
sorry about that
btw a good Knight here helped me with it so no more questions about that))
Last edited by KanoFromMK on April 16th, 2024, 5:10 pm, edited 1 time in total.
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

Lord-Knightmare wrote: April 16th, 2024, 2:12 pm
UPD2: btw, if this disengage ability is tied to every scenario in UTBS campaign, is it possible to create an analog ability with the same effect to add it to undead units? if yes can you help me please with it?
I mean sure. If you can describe what you want the ability to do, I am sure me or some other dev/veteran coder here would be very happy to lend a hand.
ill try to explain
so this ability works only in one campaign (UTBS specifically) because it is somehow linked to it, so how can i make an ability that have the exactly same effect but is not tied in any way to a specific campaign, like usual abilities that work in every scenario by default (submerge and fearless for example)
If i create through debug command a unit in any campaign normal abilities work, the Ninja ability that is mentioned above works too, how to create an "disengage" ability that works as a normal one?
UPD: the other thing i want to do is to give it to all undead creatures, but that is easy to do so no questions about that
User avatar
Ravana
Forum Moderator
Posts: 3018
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: traits

Post by Ravana »

All abilities that are "somehow linked" rely on [event] or their Lua equivalent. You need to locate where they are, and bring them over to your addon. Search by ability id help to find them.
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

Ravana wrote: April 16th, 2024, 11:32 pm All abilities that are "somehow linked" rely on [event] or their Lua equivalent. You need to locate where they are, and bring them over to your addon. Search by ability id help to find them.
we have 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
though, i dont know what dummy is for or where to find the [event] i need, is it "attack_end"?
if yes, where do i find it and how can i use it? is there a wesnoth-wiki page about "events and how to use them"?
if not, what's the event i'm looking for? you said it is related to every scenario in that campaign, is this event somehow defined in the .cfg of those scenarios or is it somewhere else?
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: traits

Post by white_haired_uncle »

Speak softly, and carry Doombringer.
KanoFromMK
Posts: 17
Joined: April 1st, 2024, 10:35 pm

Re: traits

Post by KanoFromMK »

white_haired_uncle wrote: April 17th, 2024, 12:23 pm https://wiki.wesnoth.org/EventWML
oh hey, thanks, ill return someday with the results, thanks again
Post Reply