So I'm trying to make a function that tracks your health and the tanks health so that we can use it healing behaviors but near as I can tell it always returns 0 someone help me spot what the problem is.
Relevant information:
I am Threading this function which means it should always be running Concurrently with the CC. I am not sure this is possible if this is the issue please do tell.
Feel free to ask another questions, and If you wanna look at the full code let me know.
Declarations:
Start the thread:
Monitor Function:
Get the mean of an Array Function:
Relevant information:
I am Threading this function which means it should always be running Concurrently with the CC. I am not sure this is possible if this is the issue please do tell.
Feel free to ask another questions, and If you wanna look at the full code let me know.
Declarations:
Code:
public double myhealth = 0;
public double tankhealth = 0;
public double myhealthcentlosspersecond = 0;
public double tankhealthcentlosspersecond = 0;
public int counter = 0;
public int counter2 = 0;
double[] myhealthcalc = new double[5];
double[] tankhealthcalc = new double[5];
private static Stopwatch healthmon = new Stopwatch();
Start the thread:
Code:
Thread hpmoniter = new Thread(healthmoniter);
hpmoniter.Start();
Monitor Function:
Code:
public void healthmoniter()
{
if (healthmon.ElapsedMilliseconds > 50)
{
List<double> myhealthtrack = new List<double>();
List<double> tankhealthtrack = new List<double>();
List<double> myhealthcalc1 = new List<double>();
List<double> tankhealthcalc1 = new List<double>();
if (!Me.Combat)
{
myhealthtrack.Clear();
myhealthcalc1.Clear();
tankhealthtrack.Clear();
tankhealthcalc1.Clear();
Array.Clear(myhealthcalc,0, myhealthcalc.Length);
Array.Clear(tankhealthcalc,0,tankhealthcalc.Length);
myhealthcentlosspersecond = 0;
tankhealthcentlosspersecond = 0;
counter = 0;
counter2 = 0;
}
myhealthtrack.Add(Me.HealthPercent);
tankhealthtrack.Add(tank.HealthPercent);
if (counter > 3)
{
for (int i = 0; i < myhealthtrack.Count(); i++)
{
myhealthcalc1.Add(i - (i + 1));
myhealthcalc[counter2] = myhealthcalc1.Average();
}
for (int i = 0; i < tankhealthtrack.Count(); i++)
{
tankhealthcalc1.Add(i-(i+1));
tankhealthcalc[counter2] = tankhealthcalc1.Average();
}
counter2 ++;
if (counter2 >= 5) {counter2 = 0;}
myhealthcentlosspersecond = GetMean(myhealthcalc);
tankhealthcentlosspersecond = GetMean(tankhealthcalc);
myhealthtrack.Clear();
tankhealthtrack.Clear();
counter = -1;
}
counter ++;
healthmon.Reset();
healthmon.Start();
}
}
Get the mean of an Array Function:
Code:
public static double GetMean(double[] Values)
{
double mean = 0;
foreach (double average in Values)
{
mean += average;
}
mean /= Values.Length;
return mean;
}