Pseudo-float regeneration of armor
This commit is contained in:
parent
ef51805cb8
commit
1acc685861
@ -18,8 +18,8 @@ namespace pdHealth
|
||||
//SETTINGS
|
||||
//Regeneration
|
||||
int armorRegen = 25; //How far to regenerate the armor. Set to 0 to disable regenaration entirely.
|
||||
int armorRegenSpeed = 1; //How much armor to regenerate per second.
|
||||
int armorRegenDelay = 5000; //Delay after damage before recharging armor. Set to 0 to disable delay.
|
||||
float armorRegenSpeed = 5f; //How much armor to regenerate per second.
|
||||
float armorRegenDelay = 5f; //Delay after damage before recharging armor. Set to 0 to disable delay.
|
||||
|
||||
//Max Armor/Health
|
||||
int overrideHealth = 50; //Set your max health to balance the regenerating armor. Values over 100 don't do anything (unless max health is altered by a trainer). Set to -1 to use default health.
|
||||
@ -32,7 +32,8 @@ namespace pdHealth
|
||||
//VARIABLES (DO NOT TOUCH)
|
||||
int armorVal = -1;
|
||||
int healthVal = -1;
|
||||
int timeUntilRegen = 0;
|
||||
float timeUntilRegen = 0.0f;
|
||||
float armorDecimalRegen = 0.0f;
|
||||
|
||||
private void doHealthTick(object sender, EventArgs e)
|
||||
{
|
||||
@ -51,7 +52,8 @@ namespace pdHealth
|
||||
if (pl.isAlive == false) {
|
||||
armorVal = -1;
|
||||
healthVal = -1;
|
||||
timeUntilRegen = 0;
|
||||
timeUntilRegen = 0.0f;
|
||||
armorDecimalRegen = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -75,15 +77,20 @@ namespace pdHealth
|
||||
}
|
||||
|
||||
if (armorRegen > 0) {
|
||||
if (pl.Armor < armorVal) { timeUntilRegen = armorRegenDelay; }
|
||||
if (pl.Health < healthVal) { timeUntilRegen = armorRegenDelay; }
|
||||
if (pl.Armor < armorVal) { armorDecimalRegen = 0.0f; timeUntilRegen = armorRegenDelay; }
|
||||
if (pl.Health < healthVal) { armorDecimalRegen = 0.0f; timeUntilRegen = armorRegenDelay; }
|
||||
|
||||
if (timeUntilRegen > 0) {
|
||||
timeUntilRegen = timeUntilRegen - 17;
|
||||
timeUntilRegen = timeUntilRegen - ((1000.0f/GTA.Game.FPS)/1000.0f);
|
||||
if (timeUntilRegen < 0) { timeUntilRegen = 0; }
|
||||
} else {
|
||||
if (pl.Armor < armorRegen) {
|
||||
pl.Armor = pl.Armor + armorRegenSpeed;
|
||||
armorDecimalRegen = armorDecimalRegen + (((1000.0f/GTA.Game.FPS)*armorRegenSpeed)/1000.0f);
|
||||
while (armorDecimalRegen >= 1.0f) {
|
||||
pl.Armor = pl.Armor + 1;
|
||||
armorDecimalRegen = armorDecimalRegen - 1.0f;
|
||||
}
|
||||
|
||||
if (pl.Armor > armorRegen) { pl.Armor = armorRegen; }
|
||||
}
|
||||
}
|
||||
@ -91,6 +98,7 @@ namespace pdHealth
|
||||
|
||||
armorVal = pl.Armor;
|
||||
healthVal = pl.Health;
|
||||
Game.DisplayText("Armor:\n " +pl.Armor.ToString(), 1000);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user