• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Self & Tank Health Tracking

    Discussion in 'Archives' started by Wildice, Jun 1, 2011.

    1. Wildice

      Wildice New Member

      Joined:
      May 15, 2011
      Messages:
      19
      Likes Received:
      1
      Trophy Points:
      0
      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:
      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;
      }
       
    2. CodenameG

      CodenameG New Member

      Joined:
      Jan 15, 2010
      Messages:
      38,369
      Likes Received:
      231
      Trophy Points:
      0
      first things first, think about getting rid of the other thread, you shouldn't need another one, and the easiest way to monitor the health of different wow units is just to make a method to put the wowunits on a list that you want to watch, then just run though the list, with a 4each loop or whatever to update the values to ones that are already predefined. again if you need another thread, you might wanna rethink how your implementing this.
       
    3. Wildice

      Wildice New Member

      Joined:
      May 15, 2011
      Messages:
      19
      Likes Received:
      1
      Trophy Points:
      0
      How do i Delete this thread ?
       

    Share This Page