Possible to make units regenerate HP in a city by a percentage?

Is it possible to have a unit regenerate their health when stationed in a city by a percentage, rather than a set number? I am looking into the code right now to see if it is possible. I have been able to make a spell which gives HP back by a percentage but I am not sure exactly how to make units regen hp by a percentage while stationed in a town. I have put in some code but not tested it yet, curious if anyone has figured this out.




Also, is it possible to get the regen tactical or strategic spell to regen by a percentage rather then a set number? Have only looked into it briefly but I am not sure if it is possible.


Actually, now that I think about it, maybe like this for tactical regen:

<GameModifier>
<ModType>Unit</ModType>
<Attribute>CurHealth</Attribute>
<PerTurn>1</PerTurn>
<Calculate InternalName="Calc" ValueOwner="TargetUnit">
<Expression><![CDATA[[Unit_GetHPCurrent] * .25]]></Expression>
</Calculate>
<Calculate InternalName="Value">
<Expression><![CDATA[[Calc]]]></Expression>
</Calculate>
<Calculate InternalName="ValueForFormattedDescription">
<Expression><![CDATA[[Calc]]]></Expression>
</Calculate>
</GameModifier>

19,059 views 21 replies
Reply #1 Top

I don't think buildings can calc "targetunit". I've tried this before some time ago, and I don't think it has changed since.

Although it might be possible to set the tactical regen part via an autocast spell.

Reply #2 Top

Yeah, I knew that buildings could not calc. That code I put is for a tactical regen spell used in combat which I am curious if it will work.

 

I was curious if there was possibly another way to do it with cities. As in using a multiplier. For example I have seen resources multiplied like this:

<GameModifier>
<ModType>ResourceMultiplier</ModType>
<Attribute>Gold</Attribute>
<Value>1.2</Value>
<PerTurn>1</PerTurn>
<Provides>+20% Gildar</Provides>
<UpgradeComparisonID>2</UpgradeComparisonID>
</GameModifier>

 

Regen looks like this:

<GameModifier>
<ModType>City</ModType>
<Attribute>AdjustDefendingUnit</Attribute>
<StrVal>UnitStat_HealthRegen</StrVal>
<Value>5</Value>
<Operator>+</Operator>
<PerTurn>1</PerTurn>
<Provides>Heals 5 Hit Points per Week to all stationed units</Provides>
</GameModifier>

 

 

So maybe if a UnitStat_HealthRegenMultiplier could be made, not sure.

 

So if that could be made somehow then maybe:

<GameModifier>
<ModType>City</ModType>
<Attribute>AdjustDefendingUnit</Attribute>
<StrVal>UnitStat_HealthRegenMultiplier</StrVal>

<Value>1.25</Value>

<PerTurn>1</PerTurn>

<Provides>Heals 25% health per week</Provides>
</GameModifier>

 

But yeah, I don't think that is possible heh.

Reply #3 Top

I think you can use Health Regen Multiplier just by sticking a <Multiplier> tag into the GameModifer... like this:

        <GameModifier>
            <ModType>City</ModType>
            <Attribute>AdjustDefendingUnit</Attribute>
            <StrVal>UnitStat_HealthRegen</StrVal>
            <Multiplier>2</Multiplier>
        </GameModifier>

The problem is that would just double the regen rate, so you'd get (1+level) x2 HP per turn. But I thought you were trying to get it to regen as a percentage of max HP?

Reply #4 Top

I am trying to get it to regen as a percentage of max hp. That was a silly mistake, heh. I am playing around with a bunch of things, hmm.

Reply #5 Top

Would an auto-cast spell work with a building, I've never tried it.

Reply #6 Top

If it doesn't, you can just make an ability to auto cast the spell, assign it to a custom unit, have the building summon that unit as a defender. Then have the ability cast a second spell that kills the units. XD

Reply #7 Top

yeah but that would only be during battles. That defeats the purpose. I could most likely make it as an enchantment I suppose.

Reply #8 Top

I tried to do it as an enchantment but it didn't work, blah.

Reply #10 Top

No idea.

Reply #11 Top

Figured. I think it isn't possible sadly. However, I will have to find another way to work around it. I have been doing pretty good at working around the impossible so far heh.

Reply #12 Top

I have no idea if this will work, but try to put a code to pull the units max health and multiply it by 0.1. Pretty straight forward, and it entirely depends on the logic of the original programmers, but it might work.

Reply #13 Top

You know, buildings can use Calc in the code, but it doesn't work for regen for some reason. I can try just pulling the units max health and multiplying it (I might have already tried, I forgot)

Reply #14 Top

<GameModifier>
<ModType>City</ModType>
<Attribute>AdjustDefendingUnit</Attribute>
<StrVal>Unit_GetHPCurrent</StrVal>
<Multiplier>1.4</Multiplier>
<PerTurn>1</PerTurn>

</GameModifier>

 

<GameModifier>
<ModType>City</ModType>
<Attribute>AdjustDefendingUnit</Attribute>
<StrVal>Unit_GetHPCurrent</StrVal>
<Multiplier>.4</Multiplier>
<PerTurn>1</PerTurn> 
</GameModifier>

 

Neither works. I have tried other things too but I just can't get it to work.

 

<GameModifier>
<ModType>City</ModType>
<Attribute>AdjustDefendingUnit</Attribute>
<StrVal>UnitStat_HitPoints</StrVal>
<Multiplier>.4</Multiplier>
<PerTurn>1</PerTurn>

</GameModifier>

 

Tried other things too

Reply #15 Top

Is it possible to make a building that applies an enchantment on units? If so, it might work that way.

Another option is to try and make a trait that checks for the a background stat. If your building increase that stat by 10, then the unit will restore extra 10% health.

If both don't work, I have no idea.

Reply #16 Top

Honestly not sure if those are possible. I wouldn't know how to code it off the top of my head

Reply #17 Top

Not entirely sure how to work with city specific resources yet, Heavenfall might know.

When thinking about it, not even sure if it's currently possible, as in general pulling most of the data from the player don't work, so doubt if the city does.

Reply #18 Top

You could perhaps track the issues which give the city hp or which are based on issues which give hp and give a regeneration bonus based on each of them?  This would not be perfect, but it might be acceptable?

However, note that high level regeneration can be frustrating to deal with.

Reply #19 Top

I am not really sure what you are saying dihir.

Reply #20 Top

For example... one of the things that increases the total hp of a city is its population -- you get units based on population, but also population is what gives you city levels, so you could approximate some of this gameplay effect by giving each subsequent city level a certain amount of regeneration.

Reply #21 Top

Of course, cities already give regeneration by level. However, this does not help me. That is a set number. I need to be able to do it by percentage. This is what I have been trying to do. I know how to make a city give regeneration, just can't figure out how to get it to do it by percentage.