Heavenfall Heavenfall

[eLIB] UnitStat Background Mod v.M for LH 1.8

[eLIB] UnitStat Background Mod v.M for LH 1.8

 

This library mod is for other modders to include in their mods. There is no point downloading this on its own as a player.

 

LH UnitStat Background Mod v.M = LH 1.8

(not compatible with leader pack DLC)


As part of making the game have greater depth, which is the purpose of any mod, I will be releasing a UnitStat Background mod. The purpose of this library-type mod is to flag unittypes, items and traits with certain UnitStats that will allow the modders to identify them in various scenarios. It is a bit difficult to explain, so I will simply give an example: Imagine a dragon has UnitStat_BG_IsDragon = 1. Then we put this modifier on a weapon:

            <GameModifier>
                <ModType>Unit</ModType>
                <Attribute>AdjustUnitStat</Attribute>
                <StrVal>UnitStat_Accuracy</StrVal>
                <StrVal2>UnitStat_BG_IsDragon</StrVal2>
                <Value>10</Value>
                <vsHigher>1</vsHigher>
            </GameModifier>

The result is a weapon that gains +10 accuracy whenever it attacks against a dragon. Voilá, a dragon-slaying weapon. Or a trait. Such UnitStats can also be referred to in Calculate tags in spells, for example to make a damage spell deal even more damage against a dragon.

Note that this mod will only function as a library of back-ground unitstats. It will be up to the modders to use the unitstats as they see fit.

 

This is my planned list of unitstats. Note that these unitstats will not have defaultvalue set to 0 for all units, they will simply have 0 by virtue of not having it. 

Equipment UnitStats:

UnitStat_BG_IsUsingMount - 1 for mounted units, 0 for un-mounted units

Unit UnitStats: (stats marked ^ are given through traits to help players understand what is what)

UnitStat_BG_IsChampion - 1 for champions and sovereigns
UnitStat_BG_IsSovereign - 1 for sovereigns, 0 for others (note that everyone with IsSovereign also have IsChampion)
UnitStat_BG_IsMilitia^ - 1 for city militia, 0 for all others
UnitStat_BG_IsHumanoid - 1 for any unit that resembles a human in shape, not necessarily in size
UnitStat_BG_IsNotAlive^ - 1 for any unit that does not have blood pumping in its veins, is incapable of consuming nutrition, and is incapable of reproduction
UnitStat_BG_IsEmpire - 1 for sovereigns, champions and designed units from empire factions. 0 for others
UnitStat_BG_IsKingdom - 1 for sovereigns, champions and designed units from Kingdom factions. 0 for others
UnitStat_BG_IsRace_ - These unitstats are given to mark all champions, sovereigns and designed units from certain racetypes. These are the "races" that appear in Unit Details when you create a normal unit. The wildcard (*) is replaced by the name of the race as it appears in-game. The vanilla game contains 10 races that have the following names: Altarians, Mancers, Ironeers, Amarians, Tarthans, Krax, Wraiths, Trogs, Urxen, Quendar. For example, all of the race Altarians have UnitStat_BG_IsRace_Altarians = 1
UnitStat_BG_IsMonster - for all units considered monsters. Note that this applies to recruited monsters as well. Anything that is not humanoid is considered a monster.
UnitStat_BG_IsDragon - 1 for dragon monsters, 0 for others
UnitStat_BG_IsElemental - 1 for elementals, 0 for others
UnitStat_BG_IsBeast - 1 for beasts, 0 for others
UnitStat_BG_IsTwisted - 1 for Twisted creatures, 0 for others
UnitStat_BG_IsUndead - 1 for Undead creatures, 0 for others
UnitStat_BG_IsConstruct - 1 for construct creatures, 0 for others (basically golems)
UnitStat_BG_IsDemon^ - 1 for demons, 0 for others
UnitStat_BG_IsGod^ - 1 for the 5 elemental gods found in the wildlands and other godtype units at your discretion, 0 for others
UnitStat_BG_IsSummoned^ - 1 for units that are specifically summoned through magical spells, and NOT those trained. 0 for others
UnitStat_BG_IsImmortal^ - 1 for certain units that cannot die from old age. In the core game, these include: Titans, Dragons and Butchermen, Elemental gods (NOT all elementals!). 0 for all others. Keep in mind constructs are not immortal and may die from old age (they basically turn to dust after a few thousand years), but they are also UnitStat_BG_IsNotAlive^ 1.
UnitStat_BG_IsOversized^ - It is 1 for units that are substantially larger than a single human-sized mounted man. Note that this indicates that a singular unit of this sort is oversized - a unit does not become oversized if it goes from 1 to 9 members. Dragons, Giant Slags, Giant Drakes, elemental gods, and so on. It is 0 for all others.
UnitStat_BG_IsMale - 1 for units specifically marked male. 0 for others. Note: This is only applied to champions and sovereigns and troops. Practically noone else has a gender. It is perfectly possible for a unit to have 0 in both _IsMale and _IsFemale.
UnitStat_BG_IsFemale - 1 for units specifically marked female. 0 for others. Note: This is only applied to champions and sovereigns and troops. Practically noone else has a gender. It is perfectly possible for a unit to have 0 in both _IsMale and _IsFemale.
UnitStat_BG_IsFlying^ - 0 (default) = incapable of flight. 1 = Capable of Flying (does not need to be constantly flying)

Other Custom UnitStats:

UnitStat_BG_HasInjuries - 0 for all, each injury suffered by a champion adds +1. Note that there are many "flaws" that are NOT injuries. This tag is specifically for champion injuries suffered due to incapacitation in combat.
UnitStat_BG_Spellbooks - between 0 and 5, depending on how many spellbooks this champion/sov/unit has. It is enough to have rank 1 in a spellbook to get +1 in this unitstat.
UnitStat_BG_GreyMagic - Between 0 and 25+, depending on how many spelltraits this champion/sov/unit has. Each spelltrait adds 1, so a champion with Death2 Fire3 would have UnitStat_BG_GreyMagic = 5. Note that many (but not all) traits which unlock spells now grant Grey magic in LH.
 

 

 

 

388,843 views 61 replies
Reply #26 Top

This is amazing!

Reply #27 Top

Correct!

Reply #28 Top

So I was trying to update some of my mods to use this. Except looking at the CoreSpells.xml file in the Replacement folder it only contains summons. Shouldn't this replace the existing CoreSpells.xml and contain all spells? 

Reply #29 Top

No, for the purpose of the mod there would be no point. And installation folder core files are not overwritten by clashing filenames.

Reply #30 Top

So Heavenfall, I don't remember installing this (been trying to keep my install relatively clean for my own modding, although this mod is a good idea), but it looks like part of it has crept into the code (seeing Is Immortal, etc. in the code that is outputted from custom Sovereign creation).  Am i imagining things?

Reply #31 Top

It crept into DLC xml files, thanks to Derek. By any chance was your custom sovereign undead?

Reply #32 Top

Why yes, it WAS a few Undead custom Sovs that saw this code!

Sounds like we are part way there.  So now we just need to get it embedded into the 'rest' of the code!

I haven't created a 'non-undead' Sov since I downloaded the DLCs, so I have no idea if said tags would show up with regular Sovs if you have DLC04.

Reply #33 Top

Custom sovereigns are made from "generic" sovereign xml. In the unmodded game, only DLC 04 undead sovereigns have those tags. However, if you have this library installed it will appear for other factions as well.

 

Reply #34 Top

Hi HF,

Just been trawling through you modified CoreMonsterUnitTypes.xml making some edits.... and i've noticed that you have flagged thse guys as counting as "Demons"....

- Crow Demon

- Cyndrum Demon

But not the Burning Wraith, Mirror Elementals or Grave Elementals.

 

I'm far from an expert on the lore, but my understanding is that these were all pretty much created the same way.. by corrupting Elementals... so i'm wondering if they should either all count as "Demon" or not, despite the names of them.

Just comes down to whether or not the corrupting process essentially turns the elementals into a demonic creature or not.

What do you think?

 

Reply #35 Top

For the base stuff I wanted to avoid making such decisions as much as possible. If it didn't explicitly say it was a demon I didn't add it. But if you have a list of suggested changes I'd be very interested in seeing it.

Reply #36 Top

I don't so much have a list, but I have quite a few spells and other things in Demons and Wizards that affect "Demons" and/or "Celestial" so i'm just checking out what you have flagged as these.

I've been thinking about these bound elementals and I think (in D&W) i'm going to make them all count as Demons, to be consistent.  The Backstory for Cyndrums mention them as "demons" so i'm going to go ahead and assuming that whatever Ceresa did to these elementals... they are all now are corrupted to the point of possessing demon qualities.

So they'll all suffer extra damage from Holy stuff and be immune to some things.

 

That's the only tweak to the BG stats i've done, i've got a few other minor things but they're more balances changes

Reply #37 Top

Quoting Heavenfall, reply 35
UnitStat_BG_IsEmpire - 1 for sovereigns, champions and designed units from empire factions. 0 for others
UnitStat_BG_IsKingdom - 1 for sovereigns, champions and designed units from Kingdom factions. 0 for others

 

Hi HF,

I'm using this library with my new mod that extra races, and i'm thinking these 2 unitstats might not work correctly for user created factions, if the faction uses a race for an allegiance it was not originally intended.  What I mean is....

The unitstats UnitStat_BG_IsEmpire and UnitStat_BG_IsKingdom are attached the the UnitType.

The UnitType(s) are attached to the RaceType.

But we can't restrict a RaceType so that it is only available to Kingdom or Empire.  Even default races like Altarian can be Kingdom or Empire when used in a users created Faction (using the front end Faction Creator).

So the problem is if the user creates a new "Empire" Altarian faction... the units will have UnitStat_BG_IsKingdom attached, which is "wrong".

 

Does that sound correct ?

 

 

Reply #38 Top

Yeah, they'd have to create new unittypes then. I should clarify that the unitstats are not inherent from the faction but from the race. Altarian race is considered kingdom no matter what your faction is.

Reply #39 Top

OK, so I'm trying to use a BG Stat (one I added for my faction) to check against before a spell adds an ability to a unit.

Essentially UnitStat_BG_IsRevenant is the stat I've made.

I have an Ability, RevenantWays, which unlocks some Revenant Abilities for Champions not of the Revanant race.

Essentially my Revenant Champs/Sovs already have access to different versions of these abilities (depending on race subtype), so they don't need access to the 'Generic Perks' (This is a Fire vs Ice vs Pierce thing).  This would just clutter up the tree.  This 'RevenantWays' ability is to unlock some generic perks for 'normals' whom are essentially still living.

I'm trying to contemplate the gamemodifier tag, but not sure about the syntax/if this would even work.


        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>UnlockUnitAbility</Attribute>
            <StrVal>RevenantPerks</StrVal>
            <StrVal2>UnitStat_BG_IsRevenant</StrVal2>
                <Value>This Is Where I Get Lost, already mentioned RevenantPerks above</Value>
                <vsLower>1</vsLower>
            </GameModifier>

My thought was that (since I defaulted UnitStat_BG_IsRevenant to 0.0 in the stat definition for it in PlayerAbilityTypes) that pretty much everyone besides Revenants would have a value of 0, which is lower than 1.  Revenants are assigned a value of 1 via the 'FactionRevenant' ability I have for them.

Any thoughts on how one might accomplish this with a BG stat (Add an ability via a spell to a unit that doesn't already have a similar but slightly different ability/BG Stat value is 0 & disallow if 1 or higher)?

 

Reply #40 Top

What are you trying to do? If I'm reading you right, you have a spell that you want to use to check a stat, and if that stat exists apply a perk. I do not think this is possible with current XML.

Reply #41 Top

I'm using a spell to create a perk for a Champion (spell shows up fine), but I don't want to create/add the perk if that unit has a value of of over 0 in a specific stat.  I.E.. if UnitStat_BG_IsRevenant equals 1 (or higher), then don't apply the GameModifier/Unlock the noted ability.  Essentially, if you are already the Race in guestion, you have other stats that address said ability, which work slightly differently.  I just want to make sure that the ability doesn't get added to the Revenant Champions/Sovs using this spell.  This would 'stack' some abilities, and cause a bunch of disorder on the General Trait tree to boot as abilities from both parent abilities would then populate the tree, which isn't the plan.

The other option is to add the ability to every other faction in the game, which gets problematic with custom factions and such.  No sense changing a bunch of files if I can just accomplish this with one or two Gamemodifiers...

Reply #42 Top

It's been a while since I modded FE:LH, but as far as I remember there's no way to do that based on a unitstat.

What I would try is have this in your trait that gets applied through the spell:

      <Prereq>
        <Type>RestrictedAbilityBonusOption</Type>
        <Attribute>youroriginaltrait</Attribute>
        <Target>Unit</Target>
      </Prereq>

If you are lucky this may prevent the trait from being applied.

 

 

Reply #43 Top

Tjashen, I think there's a different way to approach your spell. Instead of casting it on a champion, why not have the champion cast it on himself? This would enable you to make all kinds of restrictions about WHEN he can cast the spell. The spell would simply not show up unless certain conditions were met. This is how I did my Eternal Ressurection spell for champions serving my undead faction:

 

  <SpellDef InternalName="TurnUndead">
    <DisplayName>Eternal Resurrection</DisplayName>
    <Description>This spell begins the process of turning the caster into an undead soldier by feeding dark magic into the Champion's soul.

Champion will from now on gain experience at half normal rate, and receives no benefit from any bonuses that increases experience gain. Champion suffers -5 Initiative and is capped at 3 Strategic Health regeneration.

All Injuries are removed. Champion cannot suffer any new Injuries.

Champion drains 1 Death Shard power. Champion counts as Immortal, Undead and as if it belonged to the Race: Undead. Champion also maintains its old Race.</Description>
    <DeathShards>1</DeathShards>
    <AlwaysPromptForCaster>1</AlwaysPromptForCaster>
    <Image>Ability_GreaterCurse_Icon.png</Image>
    <IconFG>Ability_GreaterCurse_Icon.png</IconFG>
    <IconBG>Ability_GreaterCurse_Icon.png</IconBG>
    <IconColor>216,45,17</IconColor>
    <SpellType>Strategic</SpellType>
    <AutoUnlock>1</AutoUnlock>
    <SpellClass>Defensive</SpellClass>
    <SpellSubClass>Buff</SpellSubClass>
    <SpellTargetType>Self</SpellTargetType>
    <Cooldown>5000</Cooldown>
    <SpellResourceCost>
      <Resource>Mana</Resource>
      <Amount>100</Amount>
    </SpellResourceCost>
    <Prereq>
      <Type>UnitStat</Type>
      <Attribute>UnitStat_BG_HasInjuries</Attribute>
      <Value>1</Value>
    </Prereq>
    <Prereq>
      <Type>AbilityBonusOption</Type>
      <Attribute>DominionOfTheDead4</Attribute>
      <Target>Player</Target>
    </Prereq>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>HealInjuries</Attribute>
    </GameModifier>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>SetUnitStat</Attribute>
      <StrVal>UnitStat_ExpBonus</StrVal>
      <Value>-50</Value>
    </GameModifier>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>SetUnitStat</Attribute>
      <StrVal>UnitStat_BG_IsImmortal</StrVal>
      <Value>1</Value>
    </GameModifier>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>SetUnitStat</Attribute>
      <StrVal>UnitStat_BG_IsUndead</StrVal>
      <Value>1</Value>
    </GameModifier>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>SetUnitStat</Attribute>
      <StrVal>UnitStat_BG_IsRace_Undead</StrVal>
      <Value>1</Value>
    </GameModifier>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>UnlockUnitAbility</Attribute>
      <StrVal>TurnedUndead</StrVal>
    </GameModifier>
    <AIData AIPersonality="AI_General">
      <AIPriority>0</AIPriority>
    </AIData>
    <HitSoundFX>Spell_Enchant_02</HitSoundFX>
    <SpellDefEffect>
      <EffectName>S_Sacrifice_Particle</EffectName>
      <LocalPosition>0,50,0</LocalPosition>
      <EffectScale>1.5</EffectScale>
      <EffectDelay>0</EffectDelay>
      <SnapToTerrain>1</SnapToTerrain>
    </SpellDefEffect>
  </SpellDef>

 

Reply #44 Top

Essentially that's what I saw in the Demilich abilitiy for Necromancy Revamped.  Sov cast spell on himself, Sov only spell.  In this case, some Champions will need it (depending on how many Undead/Revenant Champions I create).

I've been hammering away at this for a while again, so I'll look at your approach more closely when I get a chance later today.

 

 

Reply #45 Top

Heya HF,

I want to create a faction trait that provides a bonus to all faction units vs a particular unitstat (IsDemon etc).

I can add it to a blood trait easy enough (like the Revenge of the Forest for Elves where they get a bonus vs ExpandedTraits_FLAG_DefendingCityWithLumberMill), but i'm really trying to do it via a faction trait.

Any ideas?

Cheers.

 

Reply #46 Top

I don't believe you can add a trait to all units owned by a faction. There may be a way to do it for all TRAINED units though. I can look it up if you're still interested, but it'll take some digging because it was only used in early FE patches.

Reply #47 Top

Yeah it's a bit of a bugger, i'm working on some faction traits but there's a lot of limitations on what can be done. 

The only idea I have currently is to have an autocast applied to all blood traits... that boosts Attack vs Demons (or whatever) based on a new UnitStat_X.  Then have the faction trait increase the UnitStat_X for all the factions units using A_UnitStat_X.

So that would work for all units that have the blood but requires adding something to all blood traits.  So all blood traits would autocast the spell but only those with A_UnitStat_X would actually get the bonus.  Kinda messy.

I'd much prefer it applied to all units if possible.... and/or if there is an easier way to do it would be preferable I just can't think of anything.

 

No drama, just wondering if I was missing something obvious.... doesn't seem like it though.

Thanks.

 

 

 

 

 

 

 

 

Reply #48 Top

I thought you could set a trait to unlock when the unit is created to have a second trait as its prereq.  So for instance Dummy_trait1 auto-unlocks when you have blood_altair trait.

Reply #49 Top

Quoting halmal242, reply 48
I thought you could set a trait to unlock when the unit is created to have a second trait as its prereq.  So for instance Dummy_trait1 auto-unlocks when you have blood_altair trait.

Yep you can do that with a unit design trait... but what i'm trying to do is have a faction (Player) ability trait that automatically gives all units the bonus.  So for example you can use A_UnitStat_Accuracy to give all units for a faction an accuracy bonus.

But i'd like to be able to do something like:

<GameModifier>
  <ModType>Player</ModType>
  <Attribute>AbilityBonus</Attribute>
  <StrVal>A_UnitStat_Accuracy</StrVal>
  <StrVal2>UnitStat_BG_Demon</StrVal2>
  <vsHigher>1</vsHigher>
  <Value>10</Value>
  <Provides>All faction units are +10 Accuray vs Demons</Provides>
</GameModifier>

But that won't work.  Well actually I haven't tried it but i'm 99% sure it won't.

 

Reply #50 Top

Actually you can just make a new blood trait with that added in using the initial blood trait as a base.  Unless you are trying to avoid that then I am not sure what you can do.