c310e17754
Getting ready for health regen implementation.
104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
//Payday Health Script 1.0 by Fierelier
|
|
//Donate: https://www.paypal.me/Fierelier/
|
|
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using GTA;
|
|
|
|
namespace pdHealth
|
|
{
|
|
public class pdHealth : Script
|
|
{
|
|
|
|
public pdHealth()
|
|
{
|
|
this.Tick += new EventHandler(this.doHealthTick);
|
|
}
|
|
|
|
//SETTINGS
|
|
//Regeneration
|
|
int armorRegen = 25; //How far to regenerate the armor. Set to 0 to disable regenaration entirely.
|
|
float armorRegenSpeed = 10f; //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.
|
|
int overrideArmor = -1; //Set your max armor. Basically the same as above.
|
|
|
|
//Other armor options
|
|
bool allDamageArmor = true; //The armor soaks up all the damage, even fall and explosion-damage.
|
|
float armorDefense = 1.0F; //How much damage should the armor soak up while active? Set to 1.0 (default) to make it soak up all damage, set to 0.5 to make it soak up half damage, etc.
|
|
|
|
//VARIABLES (DO NOT TOUCH)
|
|
int armorVal = -1;
|
|
int healthVal = -1;
|
|
float timeUntiArmorlRegen = 0.0f;
|
|
float armorDecimalRegen = 0.0f;
|
|
|
|
private void doHealthTick(object sender, EventArgs e)
|
|
{
|
|
Ped pl = Player.Character;
|
|
|
|
if (overrideHealth != -1) {
|
|
//if (pl.Health > overrideHealth) { Player.MaxHealth = overrideHealth; pl.Health = overrideHealth; }
|
|
if (pl.Health > overrideHealth) { pl.Health = overrideHealth; }
|
|
}
|
|
|
|
if (overrideArmor != -1) {
|
|
//if (pl.Armor > overrideArmor) { Player.MaxArmor = overrideArmor; pl.Armor = overrideArmor; }
|
|
if (pl.Armor > overrideArmor) { pl.Armor = overrideArmor; }
|
|
}
|
|
|
|
if (pl.isAlive == false) {
|
|
armorVal = -1;
|
|
healthVal = -1;
|
|
timeUntiArmorlRegen = 0.0f;
|
|
armorDecimalRegen = 0.0f;
|
|
return;
|
|
}
|
|
|
|
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 + pl.Armor;
|
|
pl.Armor = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pl.Armor < armorVal) {
|
|
if (armorDefense < 1.0F) {
|
|
pl.Health = (int)Math.Round(pl.Health - ((armorVal - pl.Armor)*1.0f-armorDefense));
|
|
}
|
|
}
|
|
|
|
if (armorRegen > 0) {
|
|
if (pl.Armor < armorVal) { armorDecimalRegen = 0.0f; timeUntiArmorlRegen = armorRegenDelay; }
|
|
if (pl.Health < healthVal) { armorDecimalRegen = 0.0f; timeUntiArmorlRegen = armorRegenDelay; }
|
|
|
|
if (timeUntiArmorlRegen > 0) {
|
|
timeUntiArmorlRegen = timeUntiArmorlRegen - ((1000.0f/GTA.Game.FPS)/1000.0f);
|
|
if (timeUntiArmorlRegen < 0) { timeUntiArmorlRegen = 0; }
|
|
} else {
|
|
if (pl.Armor < armorRegen) {
|
|
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; }
|
|
}
|
|
}
|
|
}
|
|
|
|
armorVal = pl.Armor;
|
|
healthVal = pl.Health;
|
|
Game.DisplayText("Armor:\n " +pl.Armor.ToString(), 1000);
|
|
}
|
|
}
|
|
} |