custom names based on unit type

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
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

custom names based on unit type

Post by Helmet »

I figured-out how to give custom random names to my custom races. Here is the problem...

One particular race is actually composed of two different types of creatures: ones that fly and ones that don't. I would like the names within each group to be unique to that group.

Is there a way to designate a set of random names based on unit type rather than race?

Right now it looks like I'll have to split the single race into two different races if I want to apply two different sets of names. I'd rather not do that.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: custom names based on unit type

Post by WhiteWolf »

Directly in the [race] tag, I don't think so. This could be a useful future addition to WML maybe.

In the meantime, it's fairly easy to implement an event for this.

Code: Select all

# in your [race], implement the non-flying names.
[event]
    name=unit placed
    first_time_only=no
    id=flying_unit_renamer
    [filter]
        type=your,flying,types
        [filter_wml]
            [not]
                [variables]
                    has_been_renamed=yes
                [/variables]
            [/not]
        [/filter_wml]
    [/filter]
    
    {VARIABLE_OP names rand "your,list,of,flying,names"}
    {VARIABLE unit.name $names}
    {VARIABLE unit.variables.has_been_renamed yes}
    [unstore_unit]
        variable=unit
        find_vacant=no
    [/unstore_unit]
[/event]
Place the event into every scenario.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2360
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: custom names based on unit type

Post by Lord-Knightmare »

Hmm, one trick could be to assign different genders to the unit type. Flying units could all be female, while the non-flying are males.
male_name_generator (Version 1.13.5 and later only): Like name_generator, but specific for male names
female_name_generator (Version 1.13.5 and later only): Like name_generator, but specific for female names
male_names, female_names: lists of names (i.e. non-translatable strings). They are inputted into the Markov name generator to generate random names. male_names describes units with gender=male; female_names describes units with gender=female
off-topic
Given your recent flood of WML posts, I am very curious to see what campaign you are making, Helmet. Might give it a whirl. :p
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: custom names based on unit type

Post by Helmet »

WhiteWolf wrote: December 24th, 2020, 11:06 am Directly in the [race] tag, I don't think so. This could be a useful future addition to WML maybe.
I think it would be a nice addition to WML. That way, if a designer wanted a totally different kind of name for, say, Dwarvish Thunderers, they could do it, no problem.
WhiteWolf wrote: December 24th, 2020, 11:06 am In the meantime, it's fairly easy to implement an event for this...
That code you wrote is "easy"? While I was trying to figure it out, my brain overheated and almost caught on fire. Best Buy's "Geek Squad" had to rush to my house and install a heat sink on my cortex.

:lol:

The code looks great, WhiteWolf. Thanks!
Lord-Knightmare wrote: December 24th, 2020, 11:48 am Hmm, one trick could be to assign different genders to the unit type. Flying units could all be female, while the non-flying are males.
Hmm. That solution could actually work story-wise, as both groupings are giant bugs.

Right now, there are only two species of bug: the crawling kind and the flying kind. A gender-based division could work. But if I make another campaign in the future and include a third type of bug who needs its own list of unique names...that might create a complication.

Thanks for the idea Lord-Knightmare, I'm going to give it some thought.
off-topic
Given your recent flood of WML posts, I am very curious to see what campaign you are making, Helmet. Might give it a whirl. :p
I hope you do. It's basically done and in the playtest phase.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: custom names based on unit type

Post by WhiteWolf »

Helmet wrote: December 24th, 2020, 1:07 pm That code you wrote is "easy"?
:lol:
Easy, as in short, it's just a couple of lines, not a 600 lines long external library :D
That way, if a designer wanted a totally different kind of name for, say, Dwarvish Thunderers, they could do it, no problem.
Yes, so for the actual implementation I think the correct way to do this would be introduce a key to [unit_type], that allows to override the selection of names inherited from [race]. (ex: female_names= and male_names= sound like reasonable key names to me).

It would definitely be a convenience to have this, but because it can be event-implemented, I'm not sure if it's worth the effort though.

But if I make another campaign in the future and include a third type of bug who needs its own list of unique names...that might create a complication.
Yes, that's an alternative solution, but as you guessed here, it would impose severe limitations regarding future expansions to your race.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: custom names based on unit type

Post by Helmet »

WhiteWolf wrote: December 24th, 2020, 2:07 pm Yes, that's an alternative solution, but as you guessed here, it would impose severe limitations regarding future expansions to your race.
I decided to go with your solution, for that reason. I playtested the code and it works great. Thanks again!

I put the code in a macro, so it's just one little line in each scenario.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Celtic_Minstrel
Developer
Posts: 2211
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: custom names based on unit type

Post by Celtic_Minstrel »

Helmet wrote: December 24th, 2020, 2:56 am Right now it looks like I'll have to split the single race into two different races if I want to apply two different sets of names. I'd rather not do that.
Why not just make two races that have the same name? They'd have a different ID and a different name grammar, but everything else would be identical.

Whitewolf's example code is very simplistic and doesn't provide anything near the amount of variation that the built-in name generator, but with use of some Lua it would be possible to make it use the built-in generator.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: custom names based on unit type

Post by Helmet »

Celtic_Minstrel wrote: December 25th, 2020, 10:34 pm Why not just make two races that have the same name? They'd have a different ID and a different name grammar, but everything else would be identical.
There is a very good reason that I did not make two races with the same name, Celtic_Minstrel.

It never occurred to me (sigh).

WhiteWolf's code worked when naming new recruits, but I recently realized that when I created a new flying unit with a specific name, it renamed the unit to something else. I was contemplating a solution involving one of the variables when I read your post.

It took me maybe a minute to try-out your idea. It worked. Thank you.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply