Remove random objects if amount dealt in a time frame equals or is greater than the health
Hi everyone,
It was quite tricky to come up with a title for this and I apologise if it makes no sense.
I'm not after code, but after a way to go about it.
Let's say there's a building containing various amount and types of troops, each type having different health.
The house has the total health of the troops:
totalHealth=(troop1Amount * troop1Health) + (troop2Amount * troop2Health) + etc
...
There's an army shooting at this house and every time the house is hit, the totalHealth decreases by the damage amount set for the army.
I am trying to figure out a way to also remove troops from the house if the damage dealt in a time frame equals the health of a troop in the house.
Of course, I can use:
amountDealtSinceLastCheck= amountDealtAtLastCheck-totalHealthNow; troopsKilled = amountDealtSinceLastCheck%troop1Health;
And destroy troopsKilled amount of troops.
But I would like it to be somewhat random in deciding which troops to remove as in the code above it only checks against troop1.
Hope this makes sense and thank you in advance for your help!
Regards.