Expression functions

Hi all,

Does anyone know if it's possible to specify an upper/lower bound in <Expression> tags for spells? I'm creating a new blood type that reflects 10% of damage per death shard but I want to cap the value at 30. I have <![CDATA[[UnitOwner_GetNumDeathShards] * 10]]> so far but I'm not sure where to go from there. I see some <MaxValue> params but I'm thinking that's only for random numbers, is that the case?

6,818 views 9 replies
Reply #1 Top

Not sure if there is a maximum function. I suppose you would have to simulate one with just the four operators + - * /

Not sure if the % is valid...

Reply #2 Top

I believe maxvalue minvalue only works for damage modifiers. You'll have to simulate it with a non-linear function. Actually I've never tried if ^ is a valid operator.

How exactly are you casting the spell? If it is coming from a trait, ie battleautocastspell in battle, you can work with 3 spells instead of 1 and have them trigger only if 1, 2 or 3 death shards are available. Then you'd have a trait that gives you 10%, 20% or 30% in battle.

Reply #3 Top

How do you modders do it? I see all these workarounds for simple conditional statements. It is mind-boggling how creative you are to get things to work that would be easy with logic, but you only have data to define and work with, and data that was almost always meant for some other function that what you are trying to make work. It seems if programming were a boxing match, modding this game is like fighting with one arm and one foot.

Reply #4 Top

It basically comes down to "encyclopedical" knowledge of the XML and how the game interprets it, that you get from modding the game and its predecessors for a long time. No joke, I probably spent 1000+ hours modding Elemental games.

That, and it just so happens that someone else probably tried to do something similar at one point.

This is an effect I have in Children of Storm: Angels get +1 Moves in battle if the faction controls 3 or more life shards. In the bloodline I have

      <GameModifier>
        <ModType>Unit</ModType>
        <Attribute>BattleAutoCastSpell</Attribute>
        <Provides>.</Provides>
        <StrVal>Ef_NewFaith2</StrVal>
        <Value>100</Value>
      </GameModifier>

and the spell looks like this

  <SpellDef InternalName="EF_NewFaith2">
    <DisplayName>New Faith: Moves</DisplayName>
    <Description>+1 Moves for controlling 3 Life shards.</Description>
    <IconFG>Icon_ManaToMaintain.png</IconFG>
    <IconColor>210,110,210</IconColor>
    <CanStack>0</CanStack>
    <SpellBookSortCategory>Unit</SpellBookSortCategory>
    <SpellBookSortSubCategory>UnitEnchantment</SpellBookSortSubCategory>
    <SpellType>Tactical</SpellType>
    <SpellClass>Defensive</SpellClass>
    <SpellSubClass>Buff</SpellSubClass>
    <SpellTargetType>Self</SpellTargetType>
    <HideInHiergamenon>1</HideInHiergamenon>
    <IgnoreCastAnim>1</IgnoreCastAnim>
    <IsCastable>0</IsCastable>
    <LifeShards>3</LifeShards>
    <GameModifier>
      <ModType>Unit</ModType>
      <Attribute>AdjustUnitStat</Attribute>
      <StrVal>UnitStat_Moves</StrVal>
      <Duration>-1</Duration>
      <Value>1</Value>
    </GameModifier>
    <HitSoundFX>Spell_Enchant_01</HitSoundFX>
  </SpellDef>

So you could easily make copies of this and give it reflect damage instead, making it "10% per death shard up to a max of 30%"

Reply #5 Top

Quoting Heavenfall, reply 2

I believe maxvalue minvalue only works for damage modifiers. You'll have to simulate it with a non-linear function. Actually I've never tried if ^ is a valid operator.

How exactly are you casting the spell? If it is coming from a trait, ie battleautocastspell in battle, you can work with 3 spells instead of 1 and have them trigger only if 1, 2 or 3 death shards are available. Then you'd have a trait that gives you 10%, 20% or 30% in battle.

Yep, it's an autocasted ability. So that'll work!

Reply #6 Top


That heavenfall... was that something in WOM or a good programming guess

Reply #7 Top

It was just something I happened upon by luck and random testing.

This type of limiting spells per shards owned was only ever used in E:wom, and battleautocastspell wasn't added until FE. I was looking for ways to limit battleautocastspell, even if the modifier was in place. So I went through everything that limits spells from being cast, and that was the only thing that stopped it. Edit: At least, that used to be true. I have a foggy memory of spellresourcecost also working as a limiter for that.

Reply #8 Top

Ahhh.. well lets  continue our boxing with one arm and leg :)

Reply #9 Top


now if only we could copy heavenfall's brain and use it as a reference book....