Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4

Author Topic: Dwarven Heritage Project, version 1.2.1  (Read 17527 times)

expwnent

  • Bay Watcher
    • View Profile
Dwarven Heritage Project, version 1.2.1
« on: June 29, 2012, 12:23:48 am »


Introduction:

In vanilla DF, last names are randomized. Dwarves do not inherit the last names of their ancestors. I just finished writing an lua script that changes that. It works on both historical figures and the dwarves in the current fort.

Here's the rules of the new system, in no particular order:

1. Suppose parent1 and parent2 have a child. The four possible last names for it are parent1.lastname1, parent1.lastname2, parent2.lastname1, and parent2.lastname2. The child inherits two of these names based on a pattern to be described later. The names inherited by the child depend on the child index of the child (first-born, second-born, etc), and the age of the names in question.

2. A name is considered to be "born" when it is FIRST used. Even if the first dwarf to have that name is dead, it still counts. Dwarves that were born before year 0 count. A name can be older than the world. Nothing special happens with that, though.

3. Let the four names in question of a dwarf and its spouse be A,B,C and D. First, sort these names based on age (of name), breaking ties alphabetically. Let's call sorted names, in order 1,2,3 and 4. The child last name pattern is (1 2), (1 3), (1 4), (2 3), (2 4), (3 4), then it repeats. This pattern is designed to make older names more frequent, leading to a small number of common last names.

4. No dwarf can have the same last name twice.

5. No dwarf can have the same full name as another dwarf.

6. A dwarf with no parents, or one with parents who are lost to history, must have both last names be unique.

7. In the event of a conflict due to the previous rules, the dwarf in question's second last name is randomly assigned to a new, unused last name until the conflict is resolved. This (should be) the only way new last names are created, other than the starting 7 dwarves in a fort.

8. Note that last names of dwarves will always be sorted in order of name age. Older last names will always come before younger last names.

9. Also note that gender is not taken into account, including gender of parents.

10. These rules apply only to dwarves. More accurately, they apply only to the primary race of the current fort.

11. In the event that there are so many dwarves that not all of them can have unique names, the system just gives up and allows repeats.


Possible improvements: I've considered giving royalty a special extra last name, like what happens with dwarves that kill a lot of enemies. This extra last name would always be passed on unless there's a conflict, so you can tell which dwarves are descended from a monarch, and if so, which ones. The only problem is I don't know how to determine who was a civilization leader and when in lua. Advice on this is very welcome. Doing the rest of it shouldn't be that hard.


Troubleshooting:

1. Save first. Keep a backup. You don't want to lose a save over this (though I never have).

2. In earlier versions, there was a problem where DFTherapist would crash after running this plugin, but saving and reloading the world fixed it.

3. It might mess up legends a little, especially with the names of leaders.

4. It's possible that it will print names and sort them alphabetically based on the wrong language. All of my language files are the same, so I didn't bother checking.

5. It works best if you do NOT cull unimportant historical figures, for obvious reasons.

6. Sometimes it confuses LegendsViewer into thinking that some dwarves are the same. I suspect this is because their last names don't have the right part of speech, and so they are treated as nonexistant. It should work fine in-game.


Thoughts:

A dwarf doesn't necessarily share a last name with a sibling, or even a parent.

This mod does not change any gameplay mechanics, but I think it adds some very interesting flavor to the game. Every dwarf has exactly two Families, one for each last name. In theory, the game should only generate only as many Families as necessary to prevent repeated last names, but I've seen it generate quite a few.


Installation:

Requires DFHack. Was written for DFHack 0.34.11 r1. Install that or a later version first.

The script itself is probably horribly illegible, but it should work. Just put it in hack\scripts\heritage.lua and run it with "lua hack/scripts/heritage.lua".

Load a save in dwarf mode first. Legends mode won't crash, but it also won't actually change anything because DF doesn't change save files in legends mode. It will run in adventure mode, but I think it doesn't actually do anything. I wouldn't try it.

After running, it should output all the last names that are present in your fort (among the living), most frequently-used names last.

You will, of course, need to rerun the script any time a dwarf has children in your fort. Fortunately, the script is very fast.

Github Page: https://github.com/expwnent/DFHeritage
Download link: https://github.com/expwnent/DFHeritage/zipball/master

Newest version: 2012 August 21. Fixed a few minor issues.
« Last Edit: August 21, 2012, 04:43:07 pm by expwnent »
Logged

Baijiu

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project
« Reply #1 on: June 29, 2012, 04:59:36 am »

This is SO cool. I wish that dwarves were able to share a family name though... Your naming system comes pretty close though, and looking at a dwarven family now, I can at least imagine they're related because their last names are pretty similar.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project
« Reply #2 on: June 29, 2012, 01:18:36 pm »

I could have done it that way. It would even have been a lot easier. I just thought this system was more interesting.
Logged

Pokon

  • Bay Watcher
  • [ETHICS:HAHAHAHA]
    • View Profile
Re: Dwarven Heritage Project
« Reply #3 on: June 29, 2012, 02:48:08 pm »

This is...very, very cool. Now to see how many of my Dwarves are directly related to a single fisherman and such.
Logged
A vile force of dark'ness has arrived, led by their champion Ebony Dark'ness Dementia Raven Way.

GreatWyrmGold

  • Bay Watcher
  • Sane, by the local standards.
    • View Profile
Re: Dwarven Heritage Project
« Reply #4 on: June 29, 2012, 04:00:26 pm »

What do you do with the thingy you download?
Does it happen in Legends Mode, or just once you load up a fortress?
Logged
Sig
Are you a GM with players who haven't posted? TheDelinquent Players Help will have Bay12 give you an action!
[GreatWyrmGold] gets a little crown. May it forever be his mark of Cain; let no one argue pointless subjects with him lest they receive the same.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Dwarven Heritage Project
« Reply #5 on: June 29, 2012, 04:12:52 pm »

Just wanted to say that this sound extremely awesome. Does it use the same tech as dfhack ? 
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project
« Reply #6 on: June 29, 2012, 05:59:40 pm »

What do you do with the thingy you download?
Does it happen in Legends Mode, or just once you load up a fortress?

Just put it in (df folder\hack\scripts\heritage.lua and run it with "lua hack/scripts/heritage.lua". Load a save in dwarf mode first. Requires DFHack, of course. I wrote it for DFHack 0.34.11 r1. I don't know if they do backwards compatibility or not but it should probably work with later versions.

Just wanted to say that this sound extremely awesome. Does it use the same tech as dfhack ?

Thanks! Yes, it uses and depends completely on DFHack. Would have been essentially impossible without it.
Logged

GreatWyrmGold

  • Bay Watcher
  • Sane, by the local standards.
    • View Profile
Re: Dwarven Heritage Project
« Reply #7 on: June 29, 2012, 08:50:04 pm »

Aw.
Well, this just might make me consider using DFhack.
Logged
Sig
Are you a GM with players who haven't posted? TheDelinquent Players Help will have Bay12 give you an action!
[GreatWyrmGold] gets a little crown. May it forever be his mark of Cain; let no one argue pointless subjects with him lest they receive the same.

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project, version 1.1
« Reply #8 on: July 01, 2012, 12:02:33 am »

Version 1.1 is up. Fixed many things. Now names are consistent, dwarves with no parents get new unique last names, and it correctly handles the case where you have more dwarves than last names. It should also be faster. In a world with about 200,000 historical dwarves, it took about two minutes for me.

Unfortunately, it has to run through every single historical dwarf in history to correctly measure the age of last names and deal with new dwarves. Fortunately, as long as you only have a few tens of thousands of historical dwarves it should be done in just a few seconds. Even if you have hundreds of thousands, it will only take a few minutes.

I also made it print out the founder of each name in your fort, the name of the eldest living dwarf in the world with that name, and the eldest living dwarf in your fort with that name.
« Last Edit: July 01, 2012, 12:06:16 am by expwnent »
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution
Re: Dwarven Heritage Project, version 1.1
« Reply #9 on: July 01, 2012, 12:20:47 am »

Got to give this a go once I find out what is causing my crashes, Probally half done alterations to my mod.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project, version 1.1
« Reply #10 on: July 01, 2012, 10:23:15 am »

Can you send me the save? It really shouldn't crash.
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution
Re: Dwarven Heritage Project, version 1.1
« Reply #11 on: July 01, 2012, 12:09:40 pm »

Oh I don't think it is an issue with your hack, heck I haven't even got to run it yet :P

It is probally some issues with unfinished castes in my Mod, once I finish those up ill try genning another world.

Btw it crashes during worldgen or as it is exporting the world for play, I don't think it is the 2gb limit (using LAA) and it was only a 18 world history.

EDIT:
it was a raw issue I believe, I had some castes missing a [DESCRIPTION] I guess the game doesn't like that, not at all.

Also do I have to run the script once? or everytime a child is born?
« Last Edit: July 01, 2012, 01:12:26 pm by Hugo_The_Dwarf »
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project, version 1.1
« Reply #12 on: July 01, 2012, 03:27:36 pm »

Every time a child is born.
Logged

Tierre

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project, version 1.1
« Reply #13 on: July 02, 2012, 02:56:51 am »

Need to add this to DFhack utils with automation:)
Logged

dav

  • Bay Watcher
    • View Profile
Re: Dwarven Heritage Project, version 1.1
« Reply #14 on: July 30, 2012, 03:21:44 pm »

Can I have explicit instructions on how to open this?

I have DFHack open and the script in the right folder: now what?

I can't get it to run by typing the whole link you provided; nor can I navigate to it without errors by typing directory commands. 

Sorry to be so ignorant.  Thanks.
Logged
Pages: [1] 2 3 4