From 66102c80256b3c15d839d28857a2c1776bb9e908 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Tue, 17 Apr 2018 21:55:04 +0200 Subject: [PATCH] Added allDamageArmor --- paydayHealth.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/paydayHealth.cs b/paydayHealth.cs index 185a863..45033d6 100644 --- a/paydayHealth.cs +++ b/paydayHealth.cs @@ -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; }