What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

skiProfileSwitch - Automatically switch profiles based on Kills and Time [HB2][BETA]

ski

Well-Known Member
Joined
Feb 12, 2010
Messages
3,720
Reaction score
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:
profileswitchgui.png


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
 

Attachments

Nice one Ski ;) Will prob use when I hit 80 on my mage :D
 
Interesting ski, I am sure I could find a use for this whilst leveling. Nice work :)
 
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
 
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

I'll release one every week until my demands are met...


Wait, what?
 
finally one of the ideas I had is pushed trough, good job ski.
 
NICE SKI!! Glad to see you liked my suggestion :) Glad you wrote it too, I just didnt have the time to do it. Thanks.
 
Would be great if the pathing worked for longer distances.
It doenst for me atm.
 
B E A U T I F U L

My gnome was getting tired of killing ogres and lynxes for 12+ hours straight xD
 
great now only a FP addon or feat is missing to get to the new profile area quickly ^^
 
Ever so often I get an error on the changer after i die, anyone gettign this?
 
Back
Top