View Full Version : HitPoints, MaxHitpoints (Help needed)


Grey Fox
Jun 13, 2007, 05:25 PM
I know you can change the max hit points with this GlobalDefine:


<Define>
<DefineName>MAX_HIT_POINTS</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>

But would it be possible to make the MaxHP individual to the unit? So one unit can have MaxHP 250 while another has MaxHP 4678? And also so that Promotions could increase this amount?

I'm thinking that an easy way would be to just create an attribute for the unit, call it MaxHP, and then force the game to never Regen over that amount, and make the unit start at that amount. The thing however would be that the Combat Power would calculate the Global Max HP (10000 for example) as 100% HP, so it would cut down on the units combat power - maybe this can be worked around though by making the current power calculation be based on your units individual MaxHP value.

The HealRate calculations would have to take the current units MaxHP value into consideration as well instead of the Global Max HP.

Anyone think it's possible, or has it been done/tried before? Is there even a point to do this?

Any help, or opinions is appreciated. I'm pretty sure I could implement this, but maybe its just not possible.

Gerikes
Jun 13, 2007, 05:48 PM
I know you can change the max hit points with this GlobalDefine:


<Define>
<DefineName>MAX_HIT_POINTS</DefineName>
<iDefineIntVal>100</iDefineIntVal>
</Define>

But would it be possible to make the MaxHP individual to the unit? So one unit can have MaxHP 250 while another has MaxHP 4678? And also so that Promotions could increase this amount?

I'm thinking that an easy way would be to just create an attribute for the unit, call it MaxHP, and then force the game to never Regen over that amount, and make the unit start at that amount. The thing however would be that the Combat Power would calculate the Global Max HP (10000 for example) as 100% HP, so it would cut down on the units combat power - maybe this can be worked around though by making the current power calculation be based on your units individual MaxHP value.

The HealRate calculations would have to take the current units MaxHP value into consideration as well instead of the Global Max HP.

Anyone think it's possible, or has it been done/tried before? Is there even a point to do this?

Any help, or opinions is appreciated. I'm pretty sure I could implement this, but maybe its just not possible.

In Civcraft, I gave each unit their own HP. But, of course, I changed the combat a ton and the standard "strength value" of Civ4 wasn't in my way.

It looks like in most of the cases in the SDK, one of three things are happening when the SDK checks for the MAX_HIT_POINTS...

1.) CvUnit::maxHitPoints is called. This is good for you, since you can change this function to return something based on the unit's type and/or promotions. Right now, it just gets that value from the XML. Unfortunately, since the SDK assumes that all units have the same hit points, this function isn't called in all places.

2.) GC.getMAX_HIT_POINTS(). This is sprinkled throughout the SDK, but in most places, you can probably replace it with CvUnit::maxHitPoints, since I would think in all the places, a specific unit is in mind when the function is called.

3.) GC.getDefineINT("MAX_HIT_POINTS"). I don't believe this is called anywhere but in the Global Context class (which is used to set the value that GC.getMAX_HIT_POINTS() should return).

I would imagine that if you were to change all the references of GC.getMAX_HIT_POINTS to CvUnit::maxHitPoints, you would be well on your way to what you want.