naming a new unique character

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

naming a new unique character

Post by KanoFromMK »

Good day to you ladies and gents. So basically i made a character that is unique (in a sense that he is an important character for me at least) so it should have a name and one name only.
But he is of race human. So every time i create it with (DEBUG -> create unit) or any other way really (like recruiting), his name is generated as a random human name.
My question is, is it possible to make his name constant, right in the unit's .cfg? Because when I put there

Code: Select all

[unit_type]
    id=Badass
    name= _ "notNicholasCage"
    unrenamable=yes
    race=human
    ...
it gives me a character with type notNicholasCage, with a randomly generated human name, and in the unit description in game is notNicholasCage(Badass)
I want him to be race human, type badass, with the constant name notNicholasCage.
I tried "unrenamable=yes" since in this way the units are called in scenarios and there is required to have the unique name every time.
Do i need to create another totally unique race just for this character? I mostly sure there should be something less redundant than that.
BTW, is it possible in the data\core\macros\names.cfg to put an if/then clause that checks the id for example and give it always the same name?
And if yes, can you please show how? bc im not good with WML
User avatar
Ravana
Forum Moderator
Posts: 3288
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: naming a new unique character

Post by Ravana »

You should use [unit] for such use case.
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: naming a new unique character

Post by KanoFromMK »

Ravana wrote: April 12th, 2025, 4:14 pm You should use [unit] for such use case.
How? And where?
User avatar
Spannerbag
Posts: 735
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: naming a new unique character

Post by Spannerbag »

[unit_type] defines a type of unit (such as Dwarvish Fighter or Elvish Marksman) not a specific [unit] (also mentioned here).

Here's an example of unit creation from one of my campaigns, hope it helps!

Code: Select all

    [unit]
      side=2
      type=Orcish Ruler
      id=Bohsun
      x,y=10,12
      name=_"Bohsun"
      unrenamable=yes
      canrecruit=yes
      [modifications]
        {TRAIT_QUICK}
        {TRAIT_RESILIENT}
      [/modifications]
      generate_name=no
      random_traits=no
      animate=no
    [/unit]
Good luck!

Cheers,
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.18, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
beetlenaut
Developer
Posts: 2863
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: naming a new unique character

Post by beetlenaut »

KanoFromMK wrote: April 12th, 2025, 4:23 pm How? And where?
Answering this question fully means explaining the structure of a Wesnoth add-on. Nobody is likely to do that since you can just follow the "Create" link at the top of the page to find a thorough description. Maybe if you had some more information, you could ask a more targeted question...

[unit_type] creates a class of units. It allows you to create any number of units of that type later (even if you only plan to recruit one). It sets some basic properties like race, description, animations, abilities, maximum HP, and so on.

[unit] creates a new unit on the map. It will inherit the basic properties from its [unit_type], plus it will have its own individual properties. The individual properties include things like side, name, location, traits, current HP, and so on.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
KanoFromMK
Posts: 26
Joined: April 1st, 2024, 10:35 pm

Re: naming a new unique character

Post by KanoFromMK »

thank you for your answer, this cleared things up for me
Post Reply