Added allDamageArmor

This commit is contained in:
Fierelier 2018-04-17 21:55:04 +02:00
parent e19094ff65
commit 66102c8025

View File

@ -18,6 +18,8 @@ namespace pdHealth
int armorRegen = 25; //How far to regenerate the armor
int armorRegenSpeed = 1; //How much armor to regenerate per tick
int armorRegenDelay = 5000; //Delay before recharging armor
bool allDamageArmor = true; //The armor soaks up all the health, even for fall and explosion-damage.
bool ditchDamage = false; //Ditch damage, if hit depletes armor completely
//Vars
int armorVal = -1;
@ -28,9 +30,6 @@ namespace pdHealth
{
Ped pl = Player.Character;
if (pl.Armor < armorVal) { timeUntilRegen = armorRegenDelay; }
if (pl.Health < healthVal) { timeUntilRegen = armorRegenDelay; }
if (pl.isAlive == false) {
armorVal = -1;
healthVal = -1;
@ -38,6 +37,22 @@ namespace pdHealth
return;
}
if (pl.Armor < armorVal) { timeUntilRegen = armorRegenDelay; }
if (pl.Health < healthVal) { timeUntilRegen = armorRegenDelay; }
if (allDamageArmor == true) {
if (pl.Health < healthVal) {
int damageTaken = healthVal - pl.Health;
if (damageTaken < pl.Armor) {
pl.Health = pl.Health + damageTaken;
pl.Armor = pl.Armor - damageTaken;
} else {
pl.Health = pl.Health + (damageTaken - pl.Armor);
pl.Armor = 0;
}
}
}
if (timeUntilRegen > 0) {
timeUntilRegen = timeUntilRegen - tickTime;
if (timeUntilRegen < 0) { timeUntilRegen = 0; }