custom names based on unit type
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.
custom names based on unit type
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.
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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: custom names based on unit type
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.
Place the event into every scenario.
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]
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
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
- 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
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
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: custom names based on unit type
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.
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.
The code looks great, WhiteWolf. Thanks!
Hmm. That solution could actually work story-wise, as both groupings are giant bugs.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.
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
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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: custom names based on unit type
Easy, as in short, it's just a couple of lines, not a 600 lines long external library
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:That way, if a designer wanted a totally different kind of name for, say, Dwarvish Thunderers, they could do it, no problem.
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.
Yes, that's an alternative solution, but as you guessed here, it would impose severe limitations regarding future expansions to your race.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.
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
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
Re: custom names based on unit type
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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: custom names based on unit type
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.
Re: custom names based on unit type
There is a very good reason that I did not make two races with the same name, Celtic_Minstrel.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.
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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.