[BUG][1.3 BETA] Custom Designed Units Not Inheriting Creature Types, Weirdness Ensues

When going through to add some spell effects to my mod, I realized that something wasn't working right, so I did some exploring. Here's a synopsis:

 

With a custom Wraith faction, if I design a unit it comes out as Race: Wraith, as expected. If I close the game and start a new game, I can train that unit now (cause it saves it in the mods folder), and it shows up as Race: Wraith again, no surprises there.

The weirdness occurs when I use trainable skeletons. If I design a skeleton unit, it shows up as Race: Undead, as expected. If I restart the game, and start a new game, I can train the custom skeleton unit I created earlier, only now when it shows up it is Race: Men. I looked in the automatically generated XML file for the custom creature and noticed that the <CreatureType>Undead</CreatureType> entry is not inherited. I would assume that it would then defer to racetype of the faction that generated it, but that would have made it a Wraith. I'm not sure why it's showing up as Men...

7,039 views 7 replies
Reply #1 Top

This is a mod issue and you shouldn't post this in the support section.

By default, unit designs inherit <RaceType> which the game then uses to display what type of "Race:" the unit is. Because your unit design has a non-existent racetype, it defaults to Race:Men.

If you wish for your undead units to retain their Race: Undead status, give them a <RaceType> tag and set up a racetype (as found in CoreRaceTypes.xml).

Unfortunately, this means they don't "count" as Undead for the purposes of Angelic swords and other "vs undead" abilities/weaponry. As you said, the creaturetype is not inherited and that's a big problem. Check out the Unitstat lib background mod https://forums.elementalgame.com/444737 if you are interested in a work-around.

Reply #2 Top

Ugh, the Racetypes thing constantly returns to haunt me.

 

Right, I see the problem, cause you can't invoke a <TargetRaceType> like you can a <TargetCreatureType>. Maybe the best workaround would be a combination. I could make a RaceType just to keep the Race: Undead, but keep using the WraithMale ModelType to determine the usable items. Then add in the UnitStats to filter the targets (which is the function I was using the CreatureType for in my mod). Not sure the UnitStats will work for all of the spell effects though.

 

Or, they could make it so CreatureType is inherited for custom units? Pretty please, Stardock?!?!

Reply #3 Top

Heavenfall, is it possible to use an "on hit" effect, and multiply it by a "IsUndead" unitstat, so there would be either 10 (if IsUndead is 1) or 0 added as an on hit effect?  If you edited the item that does +10 attack against undead, it might work.  Even if the +10 attack is not guaranteed in the usual vanilla process, it might be possible to add 10 damage as in the example I just mentioned which would be good enough I think.

Not sure about spell effects, but is there anything that can be done with them to give extra damage to undead or target undead with the IsUndead unitstat?

Reply #4 Top

StevenAus, the unitstat background library already does this - it converts all items targeting CreatureType Undead into items that target enemies with unitstat IsUndead that is higher than the user's (so no effect if both are undead).

Reply #6 Top

I was using the creaturetype in explosive deanimation to target only undead. Right now I'm working on another spell that only targets undead, and I realized that the creaturetype doesn't inherit while I was testing it to make sure it was targeting correctly.

 

Heavenfall, do you have any idea why the designed units would show up as Undead in the correct manner in the game that they are created? They only show up as Men in subsequent games. Maybe the cause of that is a loophole I can use.

Reply #7 Top

Possibly the creaturetype gets stored in memory but not comitted to file. Can't think of a way to use it.