(Stats Based) Auto Heal & Auto Recover Mana
💡
4
After my post of “Auto Heal & Auto Recover Mana”, i’m sharing a “stats” based approach. It’s exactly the same implementation has the previous one, with some small changes. WARNING: IT WILL DELETE YOU CURRENT STATS OF (SAVES, HERO, MONSTERS, ETC).
Last post: https://discord.com/channels/1090763611938496553/1322798151362547775
Remove “recoverManaInterval” and “healInterval” variables from CharacterBase.cs;
Replace method in CharacterBase.cs
private IEnumerator StartPeriodicalRecoverMana()
{
int interval = m_currentStats[EStat.MagicalRecovery];
while (!this.dead && this.ManaMissing() > 0 && interval > 0)
{
yield return new WaitForSeconds(interval); // Recover every X seconds
RecoverMana(1);
}
}
private IEnumerator StartPeriodicalHealing()
{
int interval = m_currentStats[EStat.HealingRecovery];
while (!this.dead && this.HealMissing() > 0 && interval>0)
{
yield return new WaitForSeconds(interval); // Heal every 2 seconds
Heal(1);
}
}
public enum EStat
{
...
MagicalRecovery = 8, // add this
HealingRecovery = 9, // add this
}
[SerializeField] private int[] m_values = new int[StatCount] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //included 2 rows ", 0, 0"
public Stats() : this(new int[StatCount] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }) //included 2 rows ", 0, 0"
{
}
Then: - 1º Change the status of all your assets (heroes, monsters) - 2º If interval is (0), recover is not applied - 3º Recomended high values if you intend to have abilities to increase the speed of the interval

💬 Comments (0)
Be the first to comment! Join our Discord to share your thoughts.
Want to continue the conversation?