kwm1800

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

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

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.

48,179 views 50 replies
Reply #26 Top


it looks like you have two spells there, do you need both ?

you have tame and tame ability.

there are other spells that use spelltargetcreaturetype properly, i think the mistake is somewhere else.

i will play with it tomorrow and see what i can find.

Reply #27 Top

Assuming you are using mana as the casting resource, instead of say gold, I think you might be able to use the tag that reduces mana cost.

if you decide to increase the spell by 5 mana per level, and the spell cost 40 as base, if you reduce the cost reduction by 12.5%*lvl, you will get that accomplished. Which do begs the question if it works on other resources as well, or just mana.

Reply #28 Top

Can you set 40 mana as a prerequisite for casting, and have it cost 0 mana to cast? Then just expend the mana during spell resolution (subtract the dynamic amount from the caster)?

Reply #29 Top

it is possible to charge a negative mana during a spell cast chich is supplied at the end of the cast.

harpo

 

Reply #30 Top

Are you sure that you are not overcomplicating this.

Have you tried working this code into a spell:

 

 <GameModifier>

                 <ModType>Unit</ModType>

                 <Attribute>AdjustUnitStat</Attribute>

                 <StrVal>UnitStat_TacticalSpellManaCost_Multiplier</StrVal>

                 <Value>-0.25</Value>

                 <Provides>-25% mana cost for tactical spells</Provides

</GameModifier>

 

You can probably switch tactical for strategic.:

 <StrVal>UnitStat_StrategicSpellManaCost_Multiplier</StrVal>

 

Reply #31 Top

Definitely you cannot switch them like that.

Reply #32 Top

I did some more testing and I think I found the issue. Not that it helps you in any way, but it also means we can't have calculations in modifiers that are <ApplyToCaster>1.

When you run a modifier like this

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

the TargetUnit is actually the caster, not the target. When we added that the target had to be Beast the spell failed because the caster was not a beast.

Reply #33 Top

I can get this spell to work within the current system. You will have to add a background stat to every beast (and creature) similar to what heavenfall does. Then you remove the <SpellTargetCreatureType> altogether.

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

In essence if the unit is a beast then Unit_BG_IsBeast] is 1 and if they are not it is 0, and so the tame won't work unless it is 1. The only drawback is that one has to be careful who they try to tame, as the UI won't provide that feedback. You could always add another modifier that will refund the cost of the spell if the unit is not the target unit by using the same technique. Namely calculate <![CDATA[1 - [Unit_BG_IsBeast]]]> and then compute the appropriate multiplication. Be wary about spell cost reductions. You might have to add some calculations to account for those costs if you chose such a route.

+1 Loading…
Reply #34 Top

Nice, useful code that cheers.

:beer:

 

Reply #35 Top

Congratulations on your good work parrottmath   :thumbsup:

Reply #36 Top

Thank you for the work, I will definitely test this out.

Reply #37 Top

I did some more testing and it appears that Heavenfall is correct in the fact that "TargetUnit" on the apply to caster tag is equivalent to "CastingUnit", I'm going to do more testing to get the same result, currently my only thoughts are to use an area effect spell that will tame only at the centers radius and give mana to all units around it equivalent to the creatures level by applying the modifier to the tile. This will be the only other work around that I can think of at the time being, until I get this figured correctly... or Stardock fixes that problem directly. I'm posting a bug report with a list of spells that don't work correctly because of it.

Reply #38 Top

Quoting parrottmath, reply 37

I did some more testing and it appears that Heavenfall is correct in the fact that "TargetUnit" on the apply to caster tag is equivalent to "CastingUnit", I'm going to do more testing to get the same result, currently my only thoughts are to use an area effect spell that will tame only at the centers radius and give mana to all units around it equivalent to the creatures level by applying the modifier to the tile. This will be the only other work around that I can think of at the time being, until I get this figured correctly... or Stardock fixes that problem directly. I'm posting a bug report with a list of spells that don't work correctly because of it.

 

I know I sound so cynical right now... but see the date of the thread.... I really do not think Stardock will fix this, along with so many other things.

Reply #39 Top

I will figure out a work-around to the problem. One issue is that this is a modding thread, but the other more important issue is that they have in-game spells that are literally broken because of this problem. The modding threads I do not think they get viewed as much, but there is a more serious issue of they have a spell that is broken because of the <ApplyToCaster> tag.

I'm more confident that they can get this fixed without a patch like they have done for other spells because they couldn't track down the problem. We'll see if what I say will hold true or not. Right now the variable cost for mana is only dependent on the caster type. I've also not given up on all my ideas at the moment on how to get this to work... I'm sure I'll find a work around in the near future, even if I have to summon a creature that specifically autocasts 1 spell to drain you for mana equal to its value gotton from the creature you just tamed or something along those lines.... I do not give up that easily.

Reply #40 Top

Quoting parrottmath, reply 39

I will figure out a work-around to the problem. One issue is that this is a modding thread, but the other more important issue is that they have in-game spells that are literally broken because of this problem. The modding threads I do not think they get viewed as much, but there is a more serious issue of they have a spell that is broken because of the <ApplyToCaster> tag.

I'm more confident that they can get this fixed without a patch like they have done for other spells because they couldn't track down the problem. We'll see if what I say will hold true or not. Right now the variable cost for mana is only dependent on the caster type. I've also not given up on all my ideas at the moment on how to get this to work... I'm sure I'll find a work around in the near future, even if I have to summon a creature that specifically autocasts 1 spell to drain you for mana equal to its value gotton from the creature you just tamed or something along those lines.... I do not give up that easily.

 

Please so. If you can do this, a lot of things become possible for the rest of the us.

Reply #41 Top

What exactly are you trying to do here, perhaps I can help.

Reply #42 Top

He's trying to fix a broken tag ApplyToCaster tag. I've not been successful in circumventing the tag at the moment.


 

Reply #43 Top

Ah I see, I thought he was trying to do some kind of variable cost for mana. I don't see how you would be able to get around the applytocaster tag. Maybe if someone could explain in more detail what is trying to be done.

Reply #44 Top

What he is trying to do is get the information from the target entity and apply this as a cost to oneself in terms of mana. Problem is when you use the ApplyToCaster tag, the target creature changes to that of the caster. Thus, any sort of calculation from the ApplyToCaster tag that actually needs to calculate data from target creature will not work. There are two instances where the tag apply to caster is used, and is trying to grab information from the target unit. This fails in the BloodCurse spell and there is a drain spell where it is suppose to take the same amount of attack from the unit and apply to yourself. But this actually doesn't work either.

The point is in order for a variable mana cost of the spell to deal with the target creature, you need to find a work around. The one idea of creating a summons that will cast a mana draining spell didn't pan out because summons will not use their battle autocast spells, when summoned. By all means come up with a spell that works it would be nice to see it happen.

Reply #45 Top

So he is trying to get a variable mana cost by multiplying it by the level of the monster, am I understanding this correctly?

Reply #46 Top

Yes, or other stats in general.

Reply #47 Top

Let me ask a question, has anyone used the spell Consume yet, I haven't used it before but it is supposed to destroy a shard and give 200 mana. It uses the applytocaster tag. Assuming it works, perhaps the applytocaster tag only currently works on the strategic map.

Reply #48 Top

Quoting BlackRainZ, reply 47

Let me ask a question, has anyone used the spell Consume yet, I haven't used it before but it is supposed to destroy a shard and give 200 mana. It uses the applytocaster tag. Assuming it works, perhaps the applytocaster tag only currently works on the strategic map.

No... bloodcurse is a strategic spell. In fact, tremor is another strategic spell whose calculation didn't work, and I fixed by avoiding the calculation portion of the spell. The Consume spell will work since there are no calculations involving anything but the caster.

The problem lies in the fact with calculating the following tags

        <GameModifier>
            <ModType>Unit</ModType>
            <Attribute>AdjustUnitStat</Attribute>
            <StrVal>UnitStat_HitPoints</StrVal>
            <ApplyToCaster>1</ApplyToCaster>
            <Duration>-1</Duration>
            <Effect>E_BloodCurse_Particle</Effect>
            <Calculate InternalName="Calc" ValueOwner="TargetCity">
                <Expression><![CDATA[[CityPopulation] / 2]]></Expression>
            </Calculate>
            <Calculate InternalName="Value">
                <Expression><![CDATA[[Calc]]]></Expression>
            </Calculate>
        </GameModifier>

This is the game modifier from the Bloodcurse spell.

It is an apply to caster tag which means now the target of the spell is the caster. Thus, the ValueOwner="TargetCity" is void, since the target is not a city. Even though the original target was a city. I can change this spell to say double the caster's hitpoints, because the target is the caster whenever you choose the ApplyToCaster tag.

Thus, any spell that has the tag ApplyToCaster... it is therefore assumed that for that particular modifier that the target of the spell is in fact that Caster and nothing else. (Consume works fine, I tested it out to be sure)

Reply #49 Top

I understand. Makes sense. This is something they need to fix then. This is a legitimate bug, has it been reported?

 

Reply #50 Top

Quoting BlackRainZ, reply 49

I understand. Makes sense. This is something they need to fix then. This is a legitimate bug, has it been reported?

 

It has been reported a long time ago, and I've reported it with all this extra information provided on the problem, as well as their spell that is broken because of it.

https://forums.elementalgame.com/443955/page/1/#3354337