Variable mana cost for a spell? Is this even possible?

By on November 11, 2012 11:51:13 PM from Elemental Forums Elemental Forums

kwm1800

Join Date 03/2008
+24

The closest related thing I can find is mana blast (which damage output being variable, not the amount needed.), which I found... non-related.

 

I just can't find it. I was trying to make a mod for balanced *Lord professions (Beast, Bandit, and adding Elemental). What I was trying to do was that make tame/bribe spell costing mana/influence based on the target unit's level and/or HP.

 

I guess this is yet another hard-coded one.

Locked Post 50 Replies
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 12:44:38 AM from Elemental Forums Elemental Forums


I'm not sure if you can detect any info from the target. Some dev input on this would be nice.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 1:23:00 AM from Elemental Forums Elemental Forums

It would be amazing if this is possible. This is probably only way to balance beast lord, diplomat or bandit lord's ability. They are broken in both ways if static value is used.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 3:08:26 AM from Elemental Forums Elemental Forums

You can't have a dynamic cost before casting, but you can subtract the gold/influence/mana after the cast, see Singing Forge for example.

 

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 3:24:16 AM from Elemental Forums Elemental Forums

Quoting Heavenfall,
You can't have a dynamic cost before casting, but you can subtract the gold/influence/mana after the cast, see Singing Forge for example.

 

 

Thanks for the input. To clear what you said.... so, I can't do dynamic cost before casting, but I can do it later? I want to make Tame spell costing additional mana based on the level of the monsters the champion tamed after he/she successfully did so.

 

(sorry for confusion, but I changed my user name. Not much better than old one tho. )

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 4:09:30 AM from Elemental Forums Elemental Forums

I believe you can, but you'll have to test it to make sure.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 4:50:00 AM from Elemental Forums Elemental Forums

I believe one of Magnar's spells gives mana with a counterspell.  Look to that for inspiration.

 

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:01:45 AM from Elemental Forums Elemental Forums

Is it Magnar, or Water-based? Something like... "Mana-drain"? Gives +40 mana on a successfull interrupt?

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:01:53 AM from Elemental Forums Elemental Forums

Quoting mqpiffle,
I believe one of Magnar's spells gives mana with a counterspell.  Look to that for inspiration.

 

 

Argh, you mean mana leech? I believe it's water spell and its value is static. (40 mana)

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:07:36 AM from Elemental Forums Elemental Forums

That's the one!

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:19:23 AM from Elemental Forums Elemental Forums

Here's some quick xml to give you an idea:

 

          <GameModifier>
            <ModType>Resource</ModType>
            <Attribute>Mana</Attribute>
            <ApplyToCaster>1</ApplyToCaster>
                     <Calculate InternalName="Value" ValueOwner="TargetUnit">
                <Expression><![CDATA[[Unit_GetLevel] * 5]]></Expression>
            </Calculate>
    </GameModifier>


               <GameModifier>
            <ModType>Resource</ModType>
            <Attribute>Mana</Attribute>
        <ApplyToCaster>1</ApplyToCaster>
        <IsForSpellResist>1</IsForSpellResist>
                     <Calculate InternalName="Value" ValueOwner="TargetUnit">
                <Expression><![CDATA[[Unit_GetLevel] * 10]]></Expression>
            </Calculate>
    </GameModifier>

 

If you put both these into a spelldef, it will give the caster Target's level * 5 in mana if the spell hits, and Target's level * 10 in mana if it gets resisted. Negative values would drain the resource instead. Keep in mind this can take you below 0 in a resource.

The point here is that you can make the spell cost dynamically AFTER it has been cast, and also based on if the spell is resisted or not.

For example: Recruit bandit: 10 gildar to cast the spell. If the spell is successful, it costs you another bandit's level * 5 gildar. If the spell isn't successful, it costs you bandit's level * 10 gildar. He was just stringing you along to make you raise the bid, then betrayed you.

Or you could turn it around, make the cost higher if you succeed, but much lower if you fail the takeover. You only have to pay him if he agrees to join you, after all.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:36:24 AM from Elemental Forums Elemental Forums

Quoting Heavenfall,
You can't have a dynamic cost before casting, but you can subtract the gold/influence/mana after the cast, see Singing Forge for example.

 

 

Nop, not working Still costing only 40 mana after the cast and after the battle. Maybe my coding is wrong, but I think this may not be possible.

 

Code: xml
  1. <SpellDef InternalName="Tame">
  2. <DisplayName>Tame</DisplayName>
  3. <Description>Take control of the targeted Beast.</Description>
  4. <Image>S_Domination_Painting.png</Image>
  5. <IconFG>T_Tame_Icon.png</IconFG>
  6. <IconColor>210,110,210</IconColor>
  7. <AutoUnlock>1</AutoUnlock>
  8. <CanStack>0</CanStack>
  9. <Cooldown>10</Cooldown>
  10. <SpellBookSortCategory>Unit</SpellBookSortCategory>
  11. <SpellBookSortSubCategory>Charm</SpellBookSortSubCategory>
  12. <SpellType>Tactical</SpellType>
  13. <SpellClass>Offensive</SpellClass>
  14. <SpellSubClass>Other</SpellSubClass>
  15. <SpellTargetType>EnemyUnit</SpellTargetType>
  16. <SpellTargetCreatureType>Beast</SpellTargetCreatureType>
  17. <IsResistable>0</IsResistable>
  18. <Range>1</Range>
  19. <Prereq>
  20. <Type>AbilityBonusOption</Type>
  21. <Attribute>BondMaker</Attribute>
  22. </Prereq>
  23. <SpellResourceCost>
  24. <Resource>Mana</Resource>
  25. <Amount>40</Amount>
  26. </SpellResourceCost>
  27. <GameModifier>
  28. <ModType>Unit</ModType>
  29. <Attribute>CharmTarget</Attribute>
  30. <Value>100</Value>
  31. </GameModifier>
  32. <GameModifier>
  33. <ModType>Resource</ModType>
  34. <Attribute>Mana</Attribute>
  35. <ApplyToCaster>1</ApplyToCaster>
  36. <Effect>-%d Mana</Effect>
  37. <Calculate InternalName="Calc" ValueOwner="TargetUnit">
  38. <Expression><![CDATA[[Unit_GetLevel]*-1]]></Expression>
  39. </Calculate>
  40. <Calculate InternalName="Value">
  41. <Expression><![CDATA[[Calc]]]></Expression>
  42. </Calculate>
  43. </GameModifier>
Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:45:41 AM from Elemental Forums Elemental Forums

I slightly modified your code and tried again, Nop. Still not working.

 

Code: xml
  1. <GameModifier>
  2. <ModType>Resource</ModType>
  3. <Attribute>Mana</Attribute>
  4. <ApplyToCaster>1</ApplyToCaster>
  5. <Calculate InternalName="Value" ValueOwner="TargetUnit">
  6. <Expression><![CDATA[[Unit_GetLevel] * -1]]></Expression>
  7. </Calculate>
  8. </GameModifier>

 

now, see if this works if I set value to positive. Just to see if there is any error on the game engine itself.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:45:51 AM from Elemental Forums Elemental Forums

The modifier works, I think maybe it just doesn't work like you think it does.

1) The spell costs 40 mana to cast. You see 40 mana in-game.

2) You cast the spell, it uses up 40 mana.

3) In your example, if the spell is successful, it drains target's level * -1 mana from the caster's pool

 

 Try setting the mana lost to a larger value such as 100.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:47:39 AM from Elemental Forums Elemental Forums

Quoting Heavenfall,
The modifier works, I think maybe it just doesn't work like you think it does.

1) The spell costs 40 mana to cast. You see 40 mana in-game.

2) You cast the spell, it uses up 40 mana.

3) In your example, if the spell is successful, it drains target's level * -1 mana from the caster's pool

 

 

 

Ok I will try again. But I think this is not working well.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:49:23 AM from Elemental Forums Elemental Forums

Also try setting the modifier before the charmtarget modifier. Maybe there's a bug there where the unit is charmed, and thus "lost" to the game engine. If you have the modifier in front you may prevent that.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:54:06 AM from Elemental Forums Elemental Forums

Tried positive value as well, still not working. I also increased mana lost to -10x. Not working at all.

 

Now I am trying original code used on that hammer and see if I get +1 metal. To see if my game itself is bugged or not.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 5:54:38 AM from Elemental Forums Elemental Forums

Quoting Heavenfall,
Also try setting the modifier before the charmtarget modifier. Maybe there's a bug there where the unit is charmed, and thus "lost" to the game engine. If you have the modifier in front you may prevent that.

 

Very good call. No wonder you are amazing modder. I will try that now...

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:05:56 AM from Elemental Forums Elemental Forums

Hmmm, I am not sure whether my game is bugged at this point.

 

The original code (that gives you +1 metal) does not work. I tried different way: I removed the charm modifier and just only mana drain/gain modifier. And it does not work.

 

I am very sorry Heavenfall, but can you check this code on your own game? Maybe my game is bugged.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:09:59 AM from Elemental Forums Elemental Forums

I have, it works for me. What version are you on? I'm on 1.01.

Post your whole XML please, not inside code, inside a quote.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:15:15 AM from Elemental Forums Elemental Forums

I am on 1.01 as well.

 

Here is the whole code.

 

With this code, I should had gotten level*10 mana after the battle, and it is not happening at all. 

<SpellDef InternalName="Tame">
<DisplayName>Tame</DisplayName>
<Description>Take control of the targeted Beast.</Description>
<Image>S_Domination_Painting.png</Image>
<IconFG>T_Tame_Icon.png</IconFG>
<IconColor>210,110,210</IconColor>
<AutoUnlock>1</AutoUnlock>
<CanStack>0</CanStack>
<Cooldown>10</Cooldown>
<SpellBookSortCategory>Unit</SpellBookSortCategory>
<SpellBookSortSubCategory>Charm</SpellBookSortSubCategory>
<SpellType>Tactical</SpellType>
<SpellClass>Offensive</SpellClass>
<SpellSubClass>Other</SpellSubClass>
<SpellTargetType>EnemyUnit</SpellTargetType>
<SpellTargetCreatureType>Beast</SpellTargetCreatureType>
<IsResistable>0</IsResistable>
<Range>1</Range>
<Prereq>
<Type>AbilityBonusOption</Type>
<Attribute>BeastLord</Attribute>
</Prereq>
<SpellResourceCost>
<Resource>Mana</Resource>
<Amount>40</Amount>
</SpellResourceCost>
<GameModifier>
<ModType>Resource</ModType>
<Attribute>Mana</Attribute>
<ApplyToCaster>1</ApplyToCaster>
<Calculate InternalName="Value" ValueOwner="TargetUnit">
<Expression><![CDATA[[Unit_GetLevel] * 10]]></Expression>
</Calculate>
</GameModifier>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>CharmTarget</Attribute>
<Value>100</Value>
</GameModifier>
<AIData AIPersonality="AI_General">
<AIPriority>5</AIPriority>
</AIData>
<HitSoundFX>Spell_SilverTongue_01</HitSoundFX>
<SpellDefEffect>
<EffectName>T_Tame_Particle</EffectName>
<LocalPosition>0,0,0</LocalPosition>
<EffectScale>1</EffectScale>
<EffectDelay>0</EffectDelay>
<SnapToTerrain>1</SnapToTerrain>
</SpellDefEffect>
</SpellDef>
<SpellDef InternalName="Tame_Ability">
<DisplayName>Tame</DisplayName>
<Description>Take control of the targeted Beast.</Description>
<Image>S_Domination_Painting.png</Image>
<IconFG>T_Tame_Icon.png</IconFG>
<IconColor>210,110,210</IconColor>
<CanStack>0</CanStack>
<SpellBookSortCategory>Unit</SpellBookSortCategory>
<SpellBookSortSubCategory>Charm</SpellBookSortSubCategory>
<SpellType>Tactical</SpellType>
<SpellClass>Offensive</SpellClass>
<SpellSubClass>Other</SpellSubClass>
<SpellTargetType>EnemyUnit</SpellTargetType>
<SpellTargetCreatureType>Beast</SpellTargetCreatureType>
<IsResistable>0</IsResistable>
<Range>1</Range>
<GameModifier>
<ModType>Resource</ModType>
<Attribute>Mana</Attribute>
<ApplyToCaster>1</ApplyToCaster>
<Calculate InternalName="Value" ValueOwner="TargetUnit">
<Expression><![CDATA[[Unit_GetLevel] * 10]]></Expression>
</Calculate>
</GameModifier>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>CharmTarget</Attribute>
<Value>100</Value>
</GameModifier>
<AIData AIPersonality="AI_General">
<AIPriority>5</AIPriority>
</AIData>
<HitSoundFX>Spell_SilverTongue_01</HitSoundFX>
<SpellDefEffect>
<EffectName>T_Tame_Particle</EffectName>
<LocalPosition>0,0,0</LocalPosition>
<EffectScale>1</EffectScale>
<EffectDelay>0</EffectDelay>
<SnapToTerrain>1</SnapToTerrain>
</SpellDefEffect>
</SpellDef>

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:41:31 AM from Elemental Forums Elemental Forums

Well, I did everything I could so far. Just in case, I am reinstalling the game see if that changes anything.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:42:16 AM from Elemental Forums Elemental Forums

For some stupid reason this line <SpellTargetCreatureType>Beast</SpellTargetCreatureType> is preventing the modifier from working. So yeah, you were right, it won't work.

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:50:03 AM from Elemental Forums Elemental Forums

Quoting Heavenfall,
For some stupid reason this line <SpellTargetCreatureType>Beast</SpellTargetCreatureType> is preventing the modifier from working. So yeah, you were right, it won't work.

 

Hehehehe, so I guess I am going to file another bug report, which probably be never fixed, right?   

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 6:52:27 AM from Elemental Forums Elemental Forums

And that's weird. This modifier indeed works on bandits (who are 'Men') right? Just bugged on 'Beast'? I shall try on Elementals as soon as I finish reinstalling the game (downloading from Steam ATM)

Reason for Karma (Optional)
Successfully updated karma reason!
November 12, 2012 8:36:36 AM from Elemental Forums Elemental Forums

No luck. <SpellTargetCreatureType> seems completely bursted. I guess since it was the one of the features Stardock struggled to get it at rather late, I assume it is full of bugs inside..

Reason for Karma (Optional)
Successfully updated karma reason!
Stardock Forums v1.0.0.0    #101114  walnut1   Server Load Time: 00:00:00.0001203   Page Render Time: