Jump to content

[Wotlk][Source] GetSpecialization


iMod

Recommended Posts

Since there is no method to get the specialization of the character in wotlk i took another way to find it out.
It wont be 100% accurate if you use mixed talends but for the most spec's it should work.

        /// <summary>
        /// Returns the talent tree with the most invested points
        /// </summary>
        /// <returns>Returns the tree index</returns>
        public static int GetSpecialization()
        {
            KeyValuePair<int, int> highestPointTree = new KeyValuePair<int, int>(0, 0);

            // Process talent trees
            for (int i = 1; i <= 3; i++)
            {
                // Get current talent points
                int treePointValue = Lua.LuaDoString<int>($"local _, _, talentPoints = GetTalentTabInfo({i}); return talentPoints;");

                // Bigger than old value?
                if (treePointValue > highestPointTree.Value)
                {
                    // Set new value
                    highestPointTree = new KeyValuePair<int, int>(i, treePointValue);
                }
            }

            // Return
            return highestPointTree.Key;
        }

This will give you the the talent tree with the most invested points.

 

Now you just need to define each talent tree based on the wow class

For example DK:

	    if(ObjectManager.Me.WowClass != WoWClass.DeathKnight)
            {
            	throw new NotSupportedException("You need to be a DK to use this rotation.");
            }

	    // Get the main talent tree
            int mainTalent = GetSpecialization();

            // Choose the right rotation
            switch (mainTalent)
            {
                case 1:
                    {
                        // Set rotation
                        this._rotation = new Blood();
                        Logging.WriteDebug("Choosing Blood rotation.");
                        break;
                    }
                case 2:
                    {
                        // Set rotation
                        this._rotation = new Frost();
                        Logging.WriteDebug("Choosing Frost rotation.");
                        break;
                    }
                case 3:
                    {
                        // Set rotation
                        this._rotation = new Unholy();
                        Logging.WriteDebug("Choosing Unholy rotation.");
                        break;
                    }
                default:
                    {
                        this._rotation = null;
                        throw new NotSupportedException("Your spec is not supported.");
                    }
            }

This is just a small and fast coded example but hope it helps some ppl.

Greez iMod

Link to comment
Share on other sites

  • 4 years later...

To help-out you could also use lua to do the same thing with less lines of code

public static string GetSpec()
    {
        string SpecName = @"    
        local highest_tab, highest = 0, 0;
        for i=1, 3 do 
        local name, _, points = GetTalentTabInfo(i);
        if points > highest then
            highest = points;
            highest_tab = i;
            highest_name = name
        end
        end
        return highest_name";

        return Lua.LuaDoString<string>(SpecName);
    }

 

Link to comment
Share on other sites

  • 1 month later...

While i was working on my own copy of AIO, i made a simple way to check spec by string, its more Accurate then the method @iMod used, 

public static class ToolHelper_Rotation
{
    public static void Spec()
    {
        string MainTalents = GetSpec();
        if (ObjectManager.Me.WowClass == WoWClass.Priest)
        {
            switch (MainTalents)
            {
                case ("Shadow"):
                    {
                        MessageBox.Show("Your spec is Shadow");
                        break;
                    }
                case ("Holy"):
                    {
                        MessageBox.Show("Your spec is Holy");
                        break;
                    }
                case ("Disco"):
                    {
                        MessageBox.Show("Your spec is Disco");
                        break;
                    }
                default:
                    {
                        MessageBox.Show("Your spec is Shadow");
                        break;
                    }
            }
        }
    }

    public static string GetSpec()
    {
        string SpecName = @"    
        local highest_tab, highest = 0, 0;
        for i=1, 3 do 
        local name, _, points = GetTalentTabInfo(i);
        if points > highest then
            highest = points;
            highest_tab = i;
            highest_name = name
        end
        end
        return highest_name";
        return Lua.LuaDoString<string>(SpecName);
    }
}

 

Link to comment
Share on other sites

Nice to see some progress even on that pc of old code ;)
One thing i don't understand is how can it be more accurate if you still loop over the tabs and take the one with the highes points? Is is because you read out the name? If so how about multi language can that cause some issues?

I know its just a sample code but you may should check if its not a priest because you don't got any else block. (2cents)

Link to comment
Share on other sites

3 minutes ago, TheSmokie said:

i simple just used priest for a fightclass, i havent really use much, my code gets the highest talents spec instead of if 2 talent trees etc.

My code does the same if i'm not total wrong. It just gets the highes talent and returns a "Number/ID" instead of the name.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...