[eINFO] Modding Auto-defend

I've noted earlier that the Maul mechanic is actually semi-moddable: https://forums.elementalgame.com/417078

As it turns out, the Auto-defend that occurs when a unit "passes" his action without doing anything is also moddable. In CoreSpells.xml we find

    <SpellDef InternalName="AutoDefend">
        <DisplayName>Defending</DisplayName>
        <Description>When a unit passes their attack action, their Defense is automatically doubled until their next action.</Description>
        <IconFG>Ability_Defend_Icon.png</IconFG>
        <IconColor>32,45,243</IconColor>
        <SpellType>Tactical</SpellType>
        <SpellClass>Defensive</SpellClass>
        <SpellSubClass>Buff</SpellSubClass>
        <SpellTargetType>Self</SpellTargetType>
        <HideInHiergamenon>1</HideInHiergamenon>
        <IsCastable>0</IsCastable>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_Defense_Blunt</StrVal>
            <Duration>1</Duration>
            <UpdateDurationAtTurnStart>1</UpdateDurationAtTurnStart>
            <Effect>Y_Defend_Particle</Effect>
            <Calculate InternalName="Calc" ValueOwner="CastingUnit">
                <Expression><![CDATA[[UnitStat_Tactical_Auto_Defense_Boost]]]></Expression>
            </Calculate>
            <Calculate InternalName="Value">
                <Expression><![CDATA[[Calc]]]></Expression>
            </Calculate>
        </GameModifier>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_Defense_Cutting</StrVal>
            <Duration>1</Duration>
            <UpdateDurationAtTurnStart>1</UpdateDurationAtTurnStart>
            <Calculate InternalName="Calc" ValueOwner="CastingUnit">
                <Expression><![CDATA[[UnitStat_Tactical_Auto_Defense_Boost]]]></Expression>
            </Calculate>
            <Calculate InternalName="Value">
                <Expression><![CDATA[[Calc]]]></Expression>
            </Calculate>
        </GameModifier>
        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_Defense_Pierce</StrVal>
            <Duration>1</Duration>
            <UpdateDurationAtTurnStart>1</UpdateDurationAtTurnStart>
            <Calculate InternalName="Calc" ValueOwner="CastingUnit">
                <Expression><![CDATA[[UnitStat_Tactical_Auto_Defense_Boost]]]></Expression>
            </Calculate>
            <Calculate InternalName="Value">
                <Expression><![CDATA[[Calc]]]></Expression>
            </Calculate>
        </GameModifier>
    </SpellDef>
End of quote

I've bolded the stat which the ability draws its strength from - UnitStat_Tactical_Auto_Defense_Boost. The value is by default 5, and can be boosted by Defender traits and shields of various types.

Knowing the spell is moddable allows us to put new stuff in there. For example, currently the Auto-defend only boosts physical defenses. We could add effects that also increase spell resist or magical attack resists (fire, cold, lightning, poison, arcane). Or we could do other things like have a unit heal if it passes the turn. A melee monk that gains dodge instead. A wizard that prepares the next spell by reducing its mana cost. Of course it would all have to be inside the same SpellDef but it's doable.

10,932 views 11 replies
Reply #1 Top

it's really going to be neat to see what all ya'll modders come up with as this is pretty cool by itself

Reply #2 Top

Could you elaborate on using it for multiple abilities in the same spell def?

Would it be a simple matter of creating booleans like "Is_Monk = 1" and then for example, have passing a turn modify dodge as follows "5 * Is_Monk" on down the list to capture all the abilities you want affected for different classes/unit types by passing a turn?

Reply #3 Top

Yes.

Reply #4 Top

Excellent. I can think of some awesome ways to use this :andrew: . Dwarven Defenders with defensive bonuses based on the number of earth shards if they pass a turn for example. 

Reply #5 Top

That opens up so many cool abilities. 

 

Judo Master: When unit passes turn he gets +100 Dodge and 10 Counterattacks.

Reply #7 Top

No it wouldn't. Any ability is balanced as long as it is placed correctly. Judo Master would be a level 20 trait at the end of a long Path of the Monk. Show me an ability and I will show you balance. 

 

 

Meditation:

Passing turn gives this unit +50 Spell Resistance for one action.

Reply #8 Top

How was I to know Judo Master was a L20 trait? ;-)  But I get what you mean about "Show me an ability and I will show you balance."  :)

Reply #9 Top

Quoting jshores, reply 2
Would it be a simple matter of creating booleans like "Is_Monk = 1" and then for example, have passing a turn modify dodge as follows "5 * Is_Monk" on down the list to capture all the abilities you want affected for different classes/unit types by passing a turn?
End of jshores's quote

 

Wait, we can create our own variables?

 

Interesting find by the way. As old as it is.

Reply #10 Top

We can create new, hidden unitstats. Because spelldefs (such as Auto-defend above) have some very crude, basic calculation possibilies, they can effectively be used as variables.

For example my Infinite Healing Potion has this side-effect when drunk:

Each time drunk, max hitpoints of the inbiber is permanently reduced by 1 at the end of battle. This does not apply to Immortal users
End of quote

Reply #11 Top


would it be easier to autodefend into each consumable, such as potions and scrolls, or would it be easier to enter a consumable flag into a potion, scroll etc and then put in a boolean for consumable in autodefend. I'm thinking the latter option, but then mod compatibility could be a problem.

Have to be careful with basic functions used all the time. I don't see why a custom mod-specific version could not be used though, ie "stormworld autodefend", dragonlance autodefend", "Thievesworld autodefend", "Discworld autodefend" "Startrek Redshirt defence" - no wait, that last ones not autodefend and is limited by available resources...