• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • skiProfileSwitch - Automatically switch profiles based on Kills and Time [HB2][BETA]

    Discussion in 'Archives' started by ski, Apr 25, 2010.

    1. ski

      ski Well-Known Member

      Joined:
      Feb 12, 2010
      Messages:
      3,720
      Likes Received:
      48
      Trophy Points:
      48
      skiProfileSwitch will allow you to set up to 4 profiles that you want to swap between once a time or kills threshold is reached, ideally letting you choose from 4 different leveling areas to swap between so you don't spend 10+ hours in one spot.

      Spent yesterday writing this up because I wanted to see it made, I think it could be useful for a lot of people (and hopefully encourage some more profile creation).

      Interface:
      [​IMG]

      Instructions:
      Extract the Zip into your plugins folder. It should have its own folder inside plugins once extracted.

      Explanations:
      - Use Kills to Switch: Switch profiles based on number of kills
      - Use Timer to Switch: Switch profiles based on time elapsed since last switch
      - Use Random: Currently only supports linear profile switch (1 -> 2 -> 3 -> 4)
      - Profile Selection: Choose the profiles you want to switch between (max of 4)
      - Max Kills: Kills amount you want to switch profiles at
      - Max Minutes: Time you want to switch at (in minutes)
      - # of Profiles: The number of profiles you have selected (1-4)
      - Debug: Adds a lot of debug info to the log, usually kept off

      Known Issues:
      - Resets Info Panel on Profile Switch (feature?)
      - Use Random not implemented

      Source:
      skiProfileSwitch.cs
      Code:
      using System;
      using System.Collections.Generic;
      using System.Text;
      using Styx.Plugins.PluginClass;
      using System.Diagnostics;
      using Styx.Helpers;
      using Styx.WoWInternals;
      using Styx.WoWInternals.WoWObjects;
      using Styx.Logic.Profiles;
      using System.Windows.Forms;
      
      namespace SkiProfileSwitcher
      {
          public class SkiProfileSwitcher : HBPlugin
          {
              #region config
              private bool _useTimer = skiProfileSwitcher.Properties.Settings.Default.useTimer; //Change profiles based on Time
              private bool _useKills = skiProfileSwitcher.Properties.Settings.Default.useKills; //Change profiles based on Kills
              private bool _useRandom = skiProfileSwitcher.Properties.Settings.Default.useRandom; //Change profiles randomly instead of linearly
              private uint _maxKills = skiProfileSwitcher.Properties.Settings.Default.maxKills; //Change profiles after this many kills
              private int _maxTime = skiProfileSwitcher.Properties.Settings.Default.maxTime; //Change profiles after this long in seconds
              private string _profile1 = skiProfileSwitcher.Properties.Settings.Default.profile1; //Profile to start with
              private string _profile2 = skiProfileSwitcher.Properties.Settings.Default.profile2; //second profile
              private string _profile3 = skiProfileSwitcher.Properties.Settings.Default.profile3; //third profile
              private string _profile4 = skiProfileSwitcher.Properties.Settings.Default.profile4; //fourth profile
      
              private bool _debug = skiProfileSwitcher.Properties.Settings.Default.debug;
              #endregion
      
              private string _logspam;
              private bool _initialized = false;
              private int _count = skiProfileSwitcher.Properties.Settings.Default.profileNum - 1;
      
              public override void OnButtonPress()
              {
                  skiProfileSwitcher.SkiProfileSwitchGui form = new skiProfileSwitcher.SkiProfileSwitchGui();
                  form.ShowDialog();
              }
      
              public override string Author
              {
                  get { return "ski"; }
              }
      
              public override bool WantButton
              {
                  get { return true; }
              }
      
              public override Version Version
              {
                  get { return new Version(1, 0); }
              }
      
              public override string Name
              {
                  get { return "skiProfileSwitcher"; }
              }
      
              Stopwatch _sw = new Stopwatch();
              Stopwatch _timer = new Stopwatch();
      
              public override void Pulse()
              {
                  if (!_initialized)
                  {
                      _sw.Stop();
                      _sw.Reset();
                      _sw.Start();
      
                      if (_debug) { Slog("[SkiProfileSwitch] Initial profile switch to: " + _profile1); }
                      SwitchProfile(_profile1);
                      _initialized = true;
                      if (_debug) { Slog("[SkiProfileSwitch] Initialized."); }
                  }
      
                  if (_debug) { Slog("[SkiProfileSwitch] sw Elasped:" + _sw.ElapsedMilliseconds); }
      
                  if (!Styx.WoWInternals.ObjectManager.Me.Combat && _sw.ElapsedMilliseconds > 30000)
                  {
                      _useTimer = skiProfileSwitcher.Properties.Settings.Default.useTimer; //Change profiles based on Time
                      _useKills = skiProfileSwitcher.Properties.Settings.Default.useKills; //Change profiles based on Kills
                      _useRandom = skiProfileSwitcher.Properties.Settings.Default.useRandom; //Change profiles randomly instead of linearly
                      _maxKills = skiProfileSwitcher.Properties.Settings.Default.maxKills; //Change profiles after this many kills
                      _maxTime = skiProfileSwitcher.Properties.Settings.Default.maxTime; //Change profiles after this long in seconds
                      _profile1 = skiProfileSwitcher.Properties.Settings.Default.profile1; //Profile to start with
                      _profile2 = skiProfileSwitcher.Properties.Settings.Default.profile2; //second profile
                      _profile3 = skiProfileSwitcher.Properties.Settings.Default.profile3; //third profile
                      _profile4 = skiProfileSwitcher.Properties.Settings.Default.profile4; //fourth profile
      
                      string[] profiles = { _profile1.ToLower(), _profile2.ToLower(), _profile3.ToLower(), _profile4.ToLower() };
      
                      if (_useTimer && !_timer.IsRunning)
                      {
                          if (_debug) { Slog("[SkiProfileSwitch] Timer Started"); }
                          _timer.Stop();
                          _timer.Reset();
                          _timer.Start();
                      }
      
                      if (_useRandom)
                      {
                          //random profile selection here
                      }
      
                      else
                      {
                          if (_debug) { Slog("[SkiProfileSwitch] Current Elapsed Time: " + _timer.Elapsed); }
                          if (_debug) { Slog("[SkiProfileSwitch] Current kills = " + Styx.Helpers.InfoPanel.MobsKilled); }
                          if (_debug) { Slog("[SkiProfileSwitch] Max kills = " + _maxKills); }
      
                          if (CheckKills(_maxKills) || CheckTime(_maxTime))
                          {
                              if (_debug) { Slog("[SkiProfileSwitch] CheckKills = " + CheckKills(_maxKills).ToString()); }
                              if (_debug) { Slog("[SkiProfileSwitch] CheckTime = " + CheckTime(_maxTime).ToString()); }
                              if (_debug) { Slog("[SkiProfileSwitch] Current Profile Path = " + GetCurrentProfilePath()); }
                              if (_debug) { Slog("[SkiProfileSwitch] First Profile Path = " + _profile1); }
      
                              if (CheckTime(_maxTime))
                              {
                                  _timer.Stop();
                                  _timer.Reset();
                                  _timer.Start();
                              }
                              for (int i = 0; i <= _count; i++)
                              {
                                  if (_debug) { Slog("[SkiProfileSwitch] In For Loop, i = " + i); }
                                  if (_debug) { Slog("[SkiProfileSwitch] Profile: " + profiles[i]); }
                                  if (profiles[i] == GetCurrentProfilePath())
                                  {
                                      if (_debug) { Slog("[SkiProfileSwitch] Profiles[" + i + "] equals current profile path (" + GetCurrentProfilePath() + ")"); }
                                      if (i < _count)
                                      {
                                          if (profiles[i + 1] != "")
                                          {
                                              Slog("[SkiProfileSwitch] Switching to profile at index" + (i + 1) + " - " + profiles[i + 1]);
                                              SwitchProfile(profiles[i + 1]);
                                              Styx.Helpers.InfoPanel.Reset();
                                              break;
                                          }
      
                                      }
      
                                      else if (i == _count)
                                      {
                                          if (profiles[0] != "")
                                          {
                                              Slog("[SkiProfileSwitch] Switching to profile at index 0 - " + profiles[0]);
                                              SwitchProfile(profiles[0]);
                                              Styx.Helpers.InfoPanel.Reset();
                                              break;
                                          }
                                      }
                                  }
                              }
                          }
                      }
                      _sw.Stop();
                      _sw.Reset();
                      _sw.Start();
                  }
              }
      
              private void SwitchProfile(string _path)
              {
                  ProfileManager.LoadNew(_path);
              }
      
              private bool CheckKills(uint _kills)
              {
                  if (!_useKills)
                  {
                      return false;
                  }
                  else if (Styx.Helpers.InfoPanel.MobsKilled >= _kills)
                  {
                      return true;
                  }
      
                  else return false;
              }
      
              private bool CheckTime(int time)
              {
                  if (!_useTimer)
                  {
                      return false;
                  }
                  else if ((time * 1000 * 60) <= _timer.ElapsedMilliseconds)
                  {
                      return true;
                  }
      
                  else return false;
              }
      
              private string GetCurrentProfilePath()
              {
                  return StyxSettings.HBSettings.LastUsedPath.ToLower();
              }
      
              public void Slog(string msg)
              {
                  if (msg != _logspam)
                  {
                      Logging.Write(msg);
                      _logspam = msg;
                  }
              }
          }
      }
      
      Current Version: 0.9
      If you have issues, please post a log with DEBUG ENABLED
       

      Attached Files:

      exfelon likes this.
    2. dayloon

      dayloon Active Member

      Joined:
      Mar 5, 2010
      Messages:
      1,046
      Likes Received:
      3
      Trophy Points:
      38
      Great idea !!!
       
    3. Mess1337

      Mess1337 Active Member

      Joined:
      Jan 15, 2010
      Messages:
      1,385
      Likes Received:
      23
      Trophy Points:
      38
      Nice one Ski ;) Will prob use when I hit 80 on my mage :D
       
    4. Synik

      Synik Active Member

      Joined:
      Jan 30, 2010
      Messages:
      995
      Likes Received:
      42
      Trophy Points:
      28
      Interesting ski, I am sure I could find a use for this whilst leveling. Nice work :)
       
    5. wozoki

      wozoki Banned

      Joined:
      Jan 15, 2010
      Messages:
      580
      Likes Received:
      5
      Trophy Points:
      0
      Wow, awesome idea. I will for sure test this
       
    6. jawn

      jawn Member

      Joined:
      Jan 15, 2010
      Messages:
      698
      Likes Received:
      4
      Trophy Points:
      18
      hell of an idea there :) great plugin... ya know i get the strange feeling ski has a whole lot of plugins waiting to be released LOL
       
    7. Nomfather

      Nomfather Member

      Joined:
      Jan 28, 2010
      Messages:
      440
      Likes Received:
      3
      Trophy Points:
      18
      Cheers ski!
       
    8. ski

      ski Well-Known Member

      Joined:
      Feb 12, 2010
      Messages:
      3,720
      Likes Received:
      48
      Trophy Points:
      48
      I'll release one every week until my demands are met...


      Wait, what?
       
    9. Nomfather

      Nomfather Member

      Joined:
      Jan 28, 2010
      Messages:
      440
      Likes Received:
      3
      Trophy Points:
      18
      Dont You Dare! ;)
       
    10. sosna

      sosna New Member

      Joined:
      Mar 12, 2010
      Messages:
      8
      Likes Received:
      0
      Trophy Points:
      0
      Ski = Legend.
       
    11. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      Nice ! ski thanks
       
    12. alexf

      alexf New Member

      Joined:
      Mar 2, 2010
      Messages:
      296
      Likes Received:
      1
      Trophy Points:
      0
      Jesus is born
       
    13. panYama

      panYama Community Developer

      Joined:
      Jan 15, 2010
      Messages:
      2,629
      Likes Received:
      49
      Trophy Points:
      0
      finally one of the ideas I had is pushed trough, good job ski.
       
    14. khurune

      khurune Member

      Joined:
      Jan 15, 2010
      Messages:
      836
      Likes Received:
      4
      Trophy Points:
      18
      good work ski, nice idea, will use it when i cbf
       
    15. Tony

      Tony "The Bee" Staff Member Moderator

      Joined:
      Jan 15, 2010
      Messages:
      128,834
      Likes Received:
      571
      Trophy Points:
      113
      nice work Ski,well done
       
    16. bigboyinlove

      bigboyinlove New Member

      Joined:
      Feb 21, 2010
      Messages:
      32
      Likes Received:
      0
      Trophy Points:
      0
      NICE SKI!! Glad to see you liked my suggestion :) Glad you wrote it too, I just didnt have the time to do it. Thanks.
       
    17. dottzor

      dottzor Member

      Joined:
      Jan 15, 2010
      Messages:
      786
      Likes Received:
      6
      Trophy Points:
      18
      Would be great if the pathing worked for longer distances.
      It doenst for me atm.
       
    18. MDurner11

      MDurner11 Member

      Joined:
      Jan 15, 2010
      Messages:
      201
      Likes Received:
      0
      Trophy Points:
      16
      B E A U T I F U L

      My gnome was getting tired of killing ogres and lynxes for 12+ hours straight xD
       
    19. letsgo2u

      letsgo2u New Member

      Joined:
      Jan 15, 2010
      Messages:
      252
      Likes Received:
      0
      Trophy Points:
      0
      great now only a FP addon or feat is missing to get to the new profile area quickly ^^
       
    20. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      Ever so often I get an error on the changer after i die, anyone gettign this?
       

    Share This Page