Preventing a unit from healing

you can create a promotion that has a high negative effect on healing rate (anti medic) and then give it to the unit via python.
 
you can create a promotion that has a high negative effect on healing rate (anti medic) and then give it to the unit via python.

Well actually I was looking to create a specified amount of damage each time a unit event occurs. Say 25% damage, which would make the unit last for 4 events: then expire. I just don't want the unit to begin to heal and throw off the numbers.
 
(Not SDK)

That's a shame, as that would be the easy way in this case ;). At any rate, I can see one option. The code determining under normal conditions wether a unit heals or not is as follows in the CvUnit::doTurn() function:

Code:
if (hasMoved())
{
	if (isAlwaysHeal())
	{
		doHeal();
	}
}

If you want the unit to not heal, then you'll have to tell the game at some point before the unit doTurn loop that the unit 'hasMoved'. This can be done with the pUnit.finishMoves() function (where pUnit is your unit you don't want to heal). If you can find an appropriate event entry point to call this on your unit(s) before the unit doTurn runs (but after the player gets to move his units, otherwise this would immobilize the unit), you're in business.

edit: looking over it, I *think* endPlayerTurn might work, but no guarantees.

Chris
 
That's a shame, as that would be the easy way in this case ;). At any rate, I can see one option. The code determining under normal conditions wether a unit heals or not is as follows in the CvUnit::doTurn() function:

Code:
if (hasMoved())
{
	if (isAlwaysHeal())
	{
		doHeal();
	}
}

If you want the unit to not heal, then you'll have to tell the game at some point before the unit doTurn loop that the unit 'hasMoved'. This can be done with the pUnit.finishMoves() function (where pUnit is your unit you don't want to heal). If you can find an appropriate event entry point to call this on your unit(s) before the unit doTurn runs (but after the player gets to move his units, otherwise this would immobilize the unit), you're in business.

edit: looking over it, I *think* endPlayerTurn might work, but no guarantees.

Chris

Believe it or not I used 2 promotions combined with some Python coding to solve the issue. The promotions are called dissipation 1 and 2, which indicate 1/3 and 2/3 damage, respectively. With these 2 promotions, healing is out of the equation. With a qualifying event, I do the following:


1st event: If the Mine Field unit does not have a Dissipation promotion, then give promotion: Dissipation 1
2nd Event: If the Mine Field unit has Dissipation 1; then give promotion: Dissipation 2
3rd event: If the Mine Field unit has Dissipation 2; Then blow up the mine (self destruct).

It works!
 
Back
Top Bottom