Can recuit loyal units

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
bernado_pampa
Posts: 6
Joined: December 12th, 2017, 1:41 pm

Can recuit loyal units

Post by bernado_pampa » December 12th, 2017, 2:26 pm

Hello,

I need recuit loyal units to my campaing, but i dont get this.

Look my code please:

Code: Select all

[unit_type]
    id=Adolescente Femea
    name= _ "Adolescente"
    race=elf
    ignore_race_traits=yes
    [race]
    num_traits=2
    [trait]
        [effect]
            apply_to=loyal
        [/effect]
    [/trait]
    [/race]
    gender=female
    image="units/elves-wood/adolescente.png"
    {MAGENTA_IS_THE_TEAM_COLOR}
    profile="portraits/elves/adolescente.png"
    hitpoints=10
...
[/unit_type]
Could you help me please?

Thanks

Shiki
Developer
Posts: 232
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Can recuit loyal units

Post by Shiki » December 12th, 2017, 2:48 pm

This looks ok.
The trait has no name, so it won't be shown. It had no description / help_text either, so it won't be shown in the trait list in the help (1.13).
Eventually this unit is already having free upkeep, try to monitor the impact on upkeep.
I don't know if having an id is mandatory.

Btw, if you give availaibility=mustehave you don't have to ignore race traits.
Maintainer of Era of Myths.
Introduction to WML filtering and WML variables.

bernado_pampa
Posts: 6
Joined: December 12th, 2017, 1:41 pm

Re: Can recuit loyal units

Post by bernado_pampa » December 12th, 2017, 3:19 pm

Shiki wrote:This looks ok.
The trait has no name, so it won't be shown. It had no description / help_text either, so it won't be shown in the trait list in the help (1.13).
Eventually this unit is already having free upkeep, try to monitor the impact on upkeep.
I don't know if having an id is mandatory.

Btw, if you give availaibility=mustehave you don't have to ignore race traits.

Thank you for your response

I change my code, but the trait loyal not work and not show in unit.

Did I do something wrong?

Code: Select all

[unit_type]
    id=Adolescente Femea
    name= _ "ElfaAdolescente"
    race=elf
    #ignore_race_traits=yes
    availaibility=mustehave
    [race]
        num_traits=2
        [trait]
            id=loyal
            male_name= _ "loyal"
            female_name= _ "female^loyal"
            description= _ "Zero upkeep"
            [effect]
                apply_to=loyal
            [/effect]
        [/trait]
    [/race]
    gender=female
...
[/unit_type]

Shiki
Developer
Posts: 232
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Can recuit loyal units

Post by Shiki » December 12th, 2017, 3:30 pm

I'm sorry, I overlooked that before, the problem is there should be no [race] tag in [unit_type]. [unit_type] accepts [trait], so just place it directly there. availability is part of [trait].
And it is possible to have not visible traits if you want them, without name or description.
Maintainer of Era of Myths.
Introduction to WML filtering and WML variables.

bernado_pampa
Posts: 6
Joined: December 12th, 2017, 1:41 pm

Re: Can recuit loyal units

Post by bernado_pampa » December 12th, 2017, 8:29 pm

Shiki wrote:I'm sorry, I overlooked that before, the problem is there should be no [race] tag in [unit_type]. [unit_type] accepts [trait], so just place it directly there. availability is part of [trait].
And it is possible to have not visible traits if you want them, without name or description.

Thank you Shiki! And I'm sorry in on tag "availability" :D

I believe that this is the way.

See Code:

Code: Select all

[unit_type]
    id=Adolescente Femea
    name= _ "ElfaAdolescente"
    race=elf
        [trait]
            availaibility="musthave"
            id=loyal
            male_name= _ "loyal"
            female_name= _ "female^loyal"
            description= _ "Zero upkeep"
            [effect]
                apply_to=loyal
            [/effect]
        [/trait]
    gender=female
...
[/unit_type]
But in this way, the trait loyal is included in the "Randon" when recruited. This had to be a characteristic of this unit.

What happens with the above code is that the unit is recruited with loyal only sometimes.

I gave a searched, and found the code below, which works 100%, but as it disables the traits, the unit only stays loyal. :x

My desire is for unity to be loyal and some random.

See Code:

Code: Select all

[unit_type]
    id=Elvish Adolescente Femea
    name= _ "ElfaAdolescente"
    race=elf
    ignore_race_traits=yes
    {TRAIT_LOYAL}
    gender=female
...
[/unit_type]

I tried "num_traits=2", but not successful


Would you or anyone else have any tips to help me? :mrgreen:

User avatar
zookeeper
WML Wizard
Posts: 9739
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Can recuit loyal units

Post by zookeeper » December 12th, 2017, 10:52 pm

Might want to to try this (untested):

Code: Select all

[unit_type]
    {TRAIT_LOYAL}
    [+trait]
        availability=musthave
    [/trait]
[/unit_type]

bernado_pampa
Posts: 6
Joined: December 12th, 2017, 1:41 pm

Re: Can recuit loyal units

Post by bernado_pampa » December 14th, 2017, 4:18 pm

zookeeper wrote:Might want to to try this (untested):

Code: Select all

[unit_type]
    {TRAIT_LOYAL}
    [+trait]
        availability=musthave
    [/trait]
[/unit_type]

Thanks zookeeper.

But don't worked =/

Still looking the solution

User avatar
octalot
Code Contributor
Posts: 214
Joined: July 17th, 2010, 7:40 pm

Re: Can recuit loyal units

Post by octalot » December 14th, 2017, 6:08 pm

You could do it in your campaign's recruit event. I've tested this on v1.13.10, putting it in a scenario's .cfg file (hence why it's working on spearmen). This gives the loyal trait, and affects the upkeep, but it doesn't add the gold UI hint that the unit is loyal.

For Wesnoth 1.12 you'd have to convert [modify_unit] back to the v1.12 method (hopefully someone will tell both of us what the v1.12 method is :) ).

Code: Select all

    [event]
        name=recruit
        first_time_only=no
        [filter_side]
            side=1
        [/filter_side]
        [filter]
            type=Spearman
        [/filter]
        [modify_unit]
            [filter]
                id=$unit.id
            [/filter]
            {TRAIT_LOYAL}
        [/modify_unit]
    [/event]
Currently updating the SurvivalXtreme Collection, and the SXC Pressure scenario. That's about a mermish necromancer, who's just found out that her Tentacles Of The Deep have been nerfed.

User avatar
Ravana
Moderator
Posts: 1887
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Can recuit loyal units

Post by Ravana » December 14th, 2017, 6:14 pm

It doesnt look like anything 1.13 specific.

Shiki
Developer
Posts: 232
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Can recuit loyal units

Post by Shiki » December 14th, 2017, 6:27 pm

I bet the reason why it didn't work is the spelling of availability - I misspelled it.
Maintainer of Era of Myths.
Introduction to WML filtering and WML variables.

bernado_pampa
Posts: 6
Joined: December 12th, 2017, 1:41 pm

Re: Can recuit loyal units

Post by bernado_pampa » December 14th, 2017, 7:30 pm

octalot wrote:You could do it in your campaign's recruit event. I've tested this on v1.13.10, putting it in a scenario's .cfg file (hence why it's working on spearmen). This gives the loyal trait, and affects the upkeep, but it doesn't add the gold UI hint that the unit is loyal.

For Wesnoth 1.12 you'd have to convert [modify_unit] back to the v1.12 method (hopefully someone will tell both of us what the v1.12 method is :) ).

Code: Select all

    [event]
        name=recruit
        first_time_only=no
        [filter_side]
            side=1
        [/filter_side]
        [filter]
            type=Spearman
        [/filter]
        [modify_unit]
            [filter]
                id=$unit.id
            [/filter]
            {TRAIT_LOYAL}
        [/modify_unit]
    [/event]
Thank you octalot!! It's work :D

Ravana wrote:It doesnt look like anything 1.13 specific.
You're right, it's work in 1.12 :D


Shiki wrote:I bet the reason why it didn't work is the spelling of availability - I misspelled it.
Oh no! :doh:
Sorry Shiki, I'm kind of dumb :whistle: hehehehe

After writing it right, it worked

See Code Working:

Code: Select all

[unit_type]
    id=Adolescente Femea
    name= _ "ElfaAdolescente"
    race=elf
    [trait]
        availability="musthave"
        id=loyal
        male_name= _ "loyal"
        female_name= _ "female^loyal"
        description= _ "Zero upkeep"
        [effect]
            apply_to=loyal
        [/effect]
    [/trait]
...
[unit_type]
Thank you all guys! :mrgreen:

User avatar
Celtic_Minstrel
Developer
Posts: 1277
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Can recuit loyal units

Post by Celtic_Minstrel » December 29th, 2017, 4:38 pm

There's no need to write your own [trait] code though. Just use {TRAIT_LOYAL}! I'm pretty sure that even already has availability=musthave, but if not you can augment it as zookeeper demonstrated.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply