Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Guide to (probably) safely transforming creatures during worldgen  (Read 1409 times)

squamous

  • Bay Watcher
    • View Profile

So, as some of you other modders are aware, permanent transformation into other creatures during worldgen is finicky and difficult, often leading to crashes. I have collated several methods of doing it in such a way that these crashes don't happen, and have decided to organize them here for use by other modders.

NOTE: This is all the result of me fumbling through experimentation and my own experiences. I would say this is mostly correct and I am mostly certain these are the rules, and these are the rules I go by when making my own mods. However, I might be wrong. Testing this stuff is hard and what I think is 100% safe might only be 99% safe. Any sort of confirmation of one or the other would be greatly appreciated.

Terminology:
Color- a color as defined in the dwarf fortress descriptor_color_standard.txt file and associated files
Color set- the total amount of potential colors a given body part can have. All the skin colors a human has constitutes a color set
Color slot- a single instance of a color in a color set. BLUE:1:BLUE:1:BLUE:1 is three color slots, even if they are all filled with the same color.


A creature can be safely transformed into a new creature if one of these conditions are met

1. The transformed end result has no color sets in the creature file, and coloration is instead described in the description itself. Like werewolves and night trolls for example. A human, for example, has a color set for eyes, skin, and hair. If those are not present on the transformed creature, there will be no issue. All vanilla transformed creatures work like this.

2. The transformed end result has the same color sets and color slots within those sets as the creature to be transformed. For example, you could safely transform a human into a giant during worldgen because a human and a giant have the same amount of potential eye, hair, and skin colors and number of color slots/sets. You would have to add graying and white hair to the giant though, or remove graying from humans, since that counts towards the total amount of sets.

3. The transformed end result has different colors but the same amount of color slots in each set. For example, if you took a giant, changed their potential skin colors from this

[TL_COLOR_MODIFIER:BROWN:1:BURNT_UMBER:1:CINNAMON:1:COPPER:1:DARK_BROWN:1:DARK_PEACH:1:DARK_TAN:1:ECRU:1:PALE_BROWN:1:PALE_CHESTNUT:1:PALE_PINK:1:PEACH:1:PINK:1:RAW_UMBER:1:SEPIA:1:TAN:1:TAUPE_PALE:1:TAUPE_SANDY:1]

to this

[TL_COLOR_MODIFIER:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1]

a human could safely become one in worldgen, their skin changing to one of the three new colors, because the number of color slots for the skin of both creatures is the same. If you did this:

[TL_COLOR_MODIFIER:RED:1:YELLOW:1:GREEN:1]

and tried to transform a human into a giant with the above color set, the game would crash.

4. The transformed creature has a greater amount of color slots in a set than the creature it transformed into. For example, if we took the above red/yellow/green-skinned giant and added this:

[TL_COLOR_MODIFIER:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:RED:1:YELLOW:1:GREEN:1:PURPLE:1000000]

All humans transformed into giants would have red, yellow, or green skin, because those color slots are the ones equivalent to the color slot of the human creature, while purple is not. However, all natural-born giants would have purple skin because of how I tweaked the ratio to increase the odds of being born purple, and if you added another color past purple, no human would transform into a giant of that color either, but natural born giants could also be born with it.

5. The transformed creature has less color sets than the original, but the remaining sets still have a matching amount of slots. For example, lets take our colorful giants, and make them eyeless, and then delete the color set pertaining to eye coloration. A human could safely transform into one of these giants so long as the skin and hair still followed the rules described above. If the eye color set was kept but the amount of color slots were reduced, the game would crash, but eliminating all references to eye coloration does not cause a crash, and the same applies to any transformation of a creature into one with less color sets than the original. You could make a hairless, eyeless giant, with both color sets pertaining to those body parts removed, and so long as the remaining skin color set of the giant had an equivalent or greater amount of color slots as the human skin color set, it would be safe.

6. The transformed creature has different body parts, but the shares the amount of color slots between both sets. Let's say we then decided to take our colorful giants and replace their hair with feathers, and then replaced the hair color set with feathers so it looked like this:


      [SET_TL_GROUP:BY_CATEGORY:ALL:FEATHER]
[TL_COLOR_MODIFIER:AMBER:1:AUBURN:1:BLACK:1:BROWN:1:BUFF:1:BURNT_SIENNA:1:BURNT_UMBER:1:CHARCOAL:1:CHESTNUT:1:CHOCOLATE:1:CINNAMON:1:COPPER:1:DARK_BROWN:1:DARK_CHESTNUT:1:DARK_TAN:1:ECRU:1:FLAX:1:GOLD:1:GOLDEN_YELLOW:1:GOLDENROD:1:LIGHT_BROWN:1:MAHOGANY:1:OCHRE:1:PALE_BROWN:1:PALE_CHESTNUT:1:PUMPKIN:1:RAW_UMBER:1:RUSSET:1:SAFFRON:1:SEPIA:1:TAN:1:TAUPE_DARK:1:TAUPE_GRAY:1:TAUPE_MEDIUM:1:TAUPE_PALE:1:TAUPE_SANDY:1]
            [TLCM_NOUN:feathers:PLURAL]
         [TL_COLOR_MODIFIER:GRAY:1]
            [TLCM_NOUN:feathers:PLURAL]
            [TLCM_TIMING:ROOT:40000:0:70000:0]
         [TL_COLOR_MODIFIER:WHITE:1]
            [TLCM_NOUN:feathers:PLURAL]
            [TLCM_TIMING:ROOT:70000:0:90000:0]

A human turning into a feather-haired, colorful, eyeless giant would be fine, because as you can see, the amount of color slots for the feathers matches up with the amount of hair color slots humans have. Note how you also have to include graying hair if the original creature has it, but you can make it not appear by increasing the amount of years it takes to show up. Realistically no feathered giant should have gray or white feathers in-game because it would take too long.


In addition, you cannot transform a creature into another creature that has more color sets. If we gave our colorful, eye-having, feather-haired giants a layer of scales over their skin, and defined the color of the scales as we do with skin, then a human transforming into one would crash the game. However, a scaled, feather-haired, skin-having, eye-having giant being transformed into a human would not crash the game, because a creature with more color sets can safely transform into a creature with less color sets, provided the color slots of the remaining sets are equal to or greater than the color slots of the original sets.

Furthermore, a creature can transform more than once in worldgen, but ONLY ONCE in gameplay. If you make interactions so a human turns into an ogre who can turn into a giant, then it is possible for a human to become a giant in worldgen. However, a human could only become an ogre during gameplay, and would not transform again after becoming an ogre.

Lastly, though I am not entirely certain of this, I believe the tissues must match up when transformation happens. If you were to transform a human into another human, then for both creatures the hair set must be the first set, the skin color set the second, and eyes the third. if you switched the hair and eye color sets of the end result human around, I don't know what would happen, but it would probably result in a crash. So if you make a new creature, like a three-eyed, red-skinned feather-haired demigod that humans can transform into, then if you make his skin the first color set, it must have as many slots as the HAIR of humans, since that is the first color set humans have, and so on. The first color set of a creature must match the first color set as the transformation end result creature, the second to the second, and so on. Not matching tissue to tissue. This may benefit from testing however.
« Last Edit: December 31, 2021, 10:14:59 pm by squamous »
Logged
I make huge and comprehensive overhaul mods, consider supporting me on Patreon so I can do this full-time:
https://www.patreon.com/themodsmith
Have questions? Need to report bugs? Post them in the discord:  https://discord.gg/dGzGr5svS2

Enemy post

  • Bay Watcher
  • Modder/GM
    • View Profile

This is great. With how often new modders seem to trip over transformations, I think I'd like to see this stickied.
Logged
My mods and forum games.
Enemy post has claimed the title of Dragonsong the Harmonic of Melodious Exaltion!

squamous

  • Bay Watcher
    • View Profile

This is great. With how often new modders seem to trip over transformations, I think I'd like to see this stickied.

To be fair, this is just me working around currently existing bugs and crashes present in the game, I imagine this whole thing will be outdated sooner or later once they're ironed out during the magic update.
Logged
I make huge and comprehensive overhaul mods, consider supporting me on Patreon so I can do this full-time:
https://www.patreon.com/themodsmith
Have questions? Need to report bugs? Post them in the discord:  https://discord.gg/dGzGr5svS2

Enemy post

  • Bay Watcher
  • Modder/GM
    • View Profile

Could always take it down later, but I learned some new stuff from this and I’ve been modding for eight years.
« Last Edit: August 17, 2021, 07:23:26 am by Enemy post »
Logged
My mods and forum games.
Enemy post has claimed the title of Dragonsong the Harmonic of Melodious Exaltion!

squamous

  • Bay Watcher
    • View Profile

Could always take it down later, but I learned some new stuff from this and I’ve been modding for nine years.
I'll leave it up to whoever is in charge
Logged
I make huge and comprehensive overhaul mods, consider supporting me on Patreon so I can do this full-time:
https://www.patreon.com/themodsmith
Have questions? Need to report bugs? Post them in the discord:  https://discord.gg/dGzGr5svS2

Eric Blank

  • Bay Watcher
  • *Remain calm*
    • View Profile

If you haven't already, you should post this on the mantis tracker page for this bug. Might help Toady fix it, if he hasn't already figured it out and is just waiting for an opportunity to mess with the hist fig ID code again.

I've got a lot of transformation effects in spellcrafts that work both during and after worldgen, I'll have a lot to go through to prevent this happening. I noticed a consistent crash when transformed into creatures and fast travelling away; when dropping out of fast travel again the game would crash if the transformation was due to end. But I hadn't connected it to body tissue coloration.
« Last Edit: August 16, 2021, 06:07:03 pm by Eric Blank »
Logged
I make Spellcrafts!
I have no idea where anything is. I have no idea what anything does. This is not merely a madhouse designed by a madman, but a madhouse designed by many madmen, each with an intense hatred for the previous madman's unique flavour of madness.

squamous

  • Bay Watcher
    • View Profile

If you haven't already, you should post this on the mantis tracker page for this bug. Might help Toady fix it, if he hasn't already figured it out and is just waiting for an opportunity to mess with the hist fig ID code again.

I've got a lot of transformation effects in spellcrafts that work both during and after worldgen, I'll have a lot to go through to prevent this happening. I noticed a consistent crash when transformed into creatures and fast travelling away; when dropping out of fast travel again the game would crash if the transformation was due to end. But I hadn't connected it to body tissue coloration.

The main issue is that there is no example in vanilla of a creature transforming into a new creature with any color sets at all. Night trolls, experiments, and werebeasts all have their coloration described in the description instead. So this sort of interaction would never happen in the normal game and it isn't surprising that it wouldn't be noticed. I might add it to the tracker, but I made this thread primarily because I want to make sure I'm actually right about all this. Very little research seems done on this subject so I'd appreciate other people investigating it as well.
« Last Edit: August 16, 2021, 09:22:02 pm by squamous »
Logged
I make huge and comprehensive overhaul mods, consider supporting me on Patreon so I can do this full-time:
https://www.patreon.com/themodsmith
Have questions? Need to report bugs? Post them in the discord:  https://discord.gg/dGzGr5svS2

squamous

  • Bay Watcher
    • View Profile

I've edited it somewhat as you can see here. I would like to clarify that while I am very sure these are safe methods, I am not completely sure, and before things are stickied or submitted as bugs it would be useful if anyone else could confirm or deny this is all correct. I use these methods myself so I am reasonably confident in their efficacy, but alternate viewpoints can reveal flaws or even as-yet-undiscovered new methods that I would have missed.
Logged
I make huge and comprehensive overhaul mods, consider supporting me on Patreon so I can do this full-time:
https://www.patreon.com/themodsmith
Have questions? Need to report bugs? Post them in the discord:  https://discord.gg/dGzGr5svS2