Creating a mana capacity

I'm trying to create a variable mana capacity system, and so far have this rough code:

     

<Calculate InternalName="Calc" ValueOwner="player">                

<Expression><![CDATA[[GetMana] - [Capacitance]]></Expression>            

</Calculate>            

<Calculate InternalName="Value" ValueOwner="player">                

<Expression><![CDATA[[Calc] > 0]]></Expression>            

</Calculate>  OR

if (calc < 0)

{calc = 0}

I don't know how to do a value check.

<ModType>Resource</ModType>            

<Attribute>Mana</Attribute>           

<PerTurn>1</PerTurn>                                                 

<Calculate InternalName="Value" ValueOwner="player">                

<Expression><![CDATA[[-Calc]]]></Expression>            

</Calculate>

 

Hopefully, this would check the current mana against the maximum, and dump any excess, if I can check that the calc is a positive number. But I have no idea where this code would go where it would be run at the end of every turn. Can anyone help?

9,890 views 16 replies
Reply #1 Top

Generally this type of scripting doesn't really work. We have no way to check ifs like that except in rare cases with unitstats.

 

Reply #2 Top

Really? No way to check a value at all?

Reply #3 Top

You can read in values and perform basic operations on them (+ - * / ) but we have no real conditional statements to work with. There is no way to access any resource except mana or gildar (oh yeah, the shards work as well).

Reply #4 Top


What if I could create a new shard type, dump the excess mana into it, check if positive or negative, then subtract its value from the mana pool or drop it?

Reply #5 Top

I don't see any of those 4 steps as doable.

Reply #6 Top

You might be able to do something along the lines of a shard resource, and have +X custom mana per turn which doesn't accumulate. If the game permits you to spend this resource the same way normal mana is spent and you have Y sources of custom mana, then you would have a limit of X*Y custom mana to use per turn (assuming that spending the custom mana doesn't cost you the production).

This doesn't allow you to build up to some cap of mana, though, and would (assuming it works) replace used mana instantly on the next turn.

You could also use this custom mana as a limiter on the amount of mana you can spend per turn by having spells use some amount of custom mana for each cast, allowing you to have a mana stockpile that continually builds up and a cap on the amount you can spend at any given moment, which is similar to having a cap on mana storage. Not quite what you asked for, but similar.

Reply #7 Top


Damn it all. Having no logic statements sucks.

Reply #8 Top

IF statements don't really work? 80% of my programing base comes from nested IF functions! OH THE HORROR!

Would any of the programing in world generation help? Probably the only thing I can think of that could have caps (limits to certain features perhaps). :S

Games with no limits are fun :D

Reply #9 Top

Just to mention it, I have a sort of work-around for if/else for unitstats at least. By treating them as boolean, I can multiply their value and the result is of course an if else. But that is practically limited to spells.

The other work-around I have is that we can use unit vs unit modifiers that have a couple of extra tags for > and <. For example we can do this

     <GameModifier>
        <ModType>Unit</ModType>
        <Attribute>AdjustUnitStat</Attribute>
        <StrVal>UnitStat_Dodge</StrVal>
        <StrVal2>UnitStat_CombatSpeed</StrVal2>
        <Value>10</Value>
        <vsLower>1</vsLower>
        <Provides>If this unit's Initiative is higher than any attacker, this unit gains +10 dodge</Provides>
      </GameModifier>

the <vsLower> being the key for comparison. There is also <vsHigher>. Again, both these solutions only really work for unitstats.

The unitstat background mod https://forums.elementalgame.com/417871 was built to facilitate these unitstats.

Reply #10 Top

Could Mana be 'stored' in the sovereign?

So sovereigns begin with a default number in 'max mana'. Then they have a stat called 'faction mana' which updates along with your mana, then if the vsLower/vsHigher triggers it stunts mana gain for the kingdom? Or is creating stats off limits also?

Edit: 'Max mana' would be modified by the various methods OP would like to increase the cap. I'm not implying everyone gets a default amount and it stays that way.

Reply #11 Top

We can create new stats.

Take note of how the vslower was used above, it only functions in a unit vs unit scenario.

I considered the idea of making mana a global shared unitstat instead, but it gives no solution to the problem of building a cap and it introduces additional problems by disabling existing mechanics.

 

Reply #12 Top

Is it possible to make a unit hidden off the map that spawns on game load or something?

Reply #13 Top

Can't think of a way.

Reply #14 Top

Maybe have the tower of dominion spawn a unit with 0 moves?

Reply #15 Top


I found a logic statement.

 

            <ValueType>IsTargetWorthy</ValueType>            

<Calculate InternalName="Calc" ValueOwner="TargetUnit">                

<Expression><![CDATA[[Unit_GetHPCurrent]]]></Expression>            

</Calculate>            

<Calculate InternalName="Value">                

<Expression><![CDATA[[Calc] < 30]]>

</Expression>            

</Calculate>

 

If I can somehow spawn a dummy unit with 1 health, and again somehow make it calculate a mana overflow every turn, I could dump excess.

Maybe the unit could autocast a spell on itself every turn, costing mana equivalent to the excess mana, if it passes a worth it test. I don't know how to do any of those things.

Reply #16 Top

You can't auto cast a spell unless you enter battle. So that option is out.