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

Is there a way to rebuild spell book while HB is running ?

wulf

Community Developer
Joined
Dec 29, 2010
Messages
1,832
Reaction score
118
Hi guys,

Is there a way to rebuild spell book while HB is running ?

I want to call this method from within my CC

Please wait a few seconds while Honorbuddy initializes.
ItemForAura - Questhelper - Version 2.0 Loaded.
Building spell book
Spell book built

Initialization complete.
Honorbuddy is up-to-date

or here in Bold.

Code:
[9:05:20 PM:860] Activity: Initializing.
[9:05:20 PM:861] Activity: Loading memory management & tables
[9:05:20 PM:873] [B][COLOR="#0000FF"]Activity: Loading Spells[/COLOR][/B]
[9:05:20 PM:898] H: 7B-8B-C6-74-2A-94-01-6B-82-85-1A-EB-F4-C8-6D-CD-67-5E-9A-27
[9:05:20 PM:899] V: 2.0.0.5800
[9:05:20 PM:900] [B][COLOR="#0000FF"]Activity: Initializing Spell Manager[/COLOR][/B]
[9:05:20 PM:913] Activity: Initializing Plugins
[9:05:20 PM:914]

I can update the current rotationbase of CLU on active spec change but because the spell book is initialized during startup, it does not contain the *new* spec spells (swapping from BM to survival, it will not execute Explosive shot as it does not have the spell.)

Code:
static CLU()
        {
            Lua.Events.AttachEvent("CHARACTER_POINTS_CHANGED", UpdateActiveRotation);
            Lua.Events.AttachEvent("ACTIVE_TALENT_GROUP_CHANGED", UpdateActiveRotation);
        }

        private static void UpdateActiveRotation(object sender, LuaEventArgs args)
        {
           [COLOR="#0000FF"][B]// I need a re-build spell book in here!![/B][/COLOR]
            rotationBase = null; //This will force CLU to update its active rotation (which it does!)
        }

Any help would be appreciated as this is the only piece of the puzzle missing.

cheers.
 
Last edited:
I was gonna ask the same question, but i could not have put it better myself.

Bump in the hope anyone can answer this query!!
 
Bump, Anyone able to help ?
 
edit: I did a quick test. If I pause Honorbuddy and change spec, I get this log output.

Code:
Building spell book
Adding: Adrenaline Rush
Adding: Ambidexterity
Adding: Blade Flurry
Adding: Killing Spree
Adding: Revealing Strike
Adding: Vitality
Spell book built

If I change spec whilst Honorbuddy is running I get no log output, but functionally the spell book seems to be automatically rebuilt anyway.

Hey wulf, I'm not sure how you're doing things in CLU, but in my experience, calling SpellManager.HasSpell returns true if the spell is available in your current talent spec even when the spec has changed previously -- at least this is the behavior I have observed in MutaRaidBT. I'm using the same two Lua hooks (CHARACTER_POINTS_CHANGED and ACTIVE_TALENT_GROUP_CHANGED) to update an attribute named mCurrentSpec if either of the two events are fired, and the rotations change flawlessly when the spec is changed. I don't have an answer to your question but I can point out how it works for me which might help you.

Relevant code:

GetCurrentSpecLua() and GetSpecGroupLua(), these two methods use Lua to determine the character's spec.
PHP:
         static private Enumeration.TalentTrees GetCurrentSpecLua()
        {
            int group = GetSpecGroupLua();

            var pointsSpent = new int[3];
           
            for (int tab = 1; tab <= 3; tab++)
            {
                List<string> talentTabInfo = Lua.GetReturnValues("return GetTalentTabInfo(" + tab + ", false, false, " + group + ")");
                pointsSpent[tab - 1] = Convert.ToInt32(talentTabInfo[4]);
            }

            if (pointsSpent[0] > (pointsSpent[1] + pointsSpent[2]))
            {
                return Enumeration.TalentTrees.Assassination;
            }

            if (pointsSpent[1] > (pointsSpent[0] + pointsSpent[2])) 
            {
                return Enumeration.TalentTrees.Combat;
            }

            if (pointsSpent[2] > (pointsSpent[0] + pointsSpent[1]))
            {
                return Enumeration.TalentTrees.Subtlety;
            }

            return Enumeration.TalentTrees.None;
        }

        // Returns the index of the current active dual spec -- first or second.
        static private int GetSpecGroupLua()
        {
            return Lua.GetReturnVal<int>("return GetActiveTalentGroup(false, false)", 0);
        }

Hooks
PHP:
            Lua.Events.AttachEvent("CHARACTER_POINTS_CHANGED", delegate
                {
                    Logging.Write(Color.Orange, "Your spec has been updated. Rebuilding behaviors...");
                    mCurrentSpec = GetCurrentSpecLua();
                }
            );

            Lua.Events.AttachEvent("ACTIVE_TALENT_GROUP_CHANGED", delegate
                {
                    Logging.Write(Color.Orange, "Your spec has changed. Rebuilding behaviors...");
                    mCurrentSpec = GetCurrentSpecLua();
                }
            );

Rotations (a small example -- my tree extends over several files, this is just where the spec rotation is decided.)
PHP:
        static public Composite BuildCombatBehavior()
        {
            return new Switch<Helpers.Enumeration.TalentTrees>(ret => Helpers.Rogue.mCurrentSpec,

                new SwitchArgument<Helpers.Enumeration.TalentTrees>(Helpers.Enumeration.TalentTrees.None,
                    Context.None.BuildCombatBehavior()
                ),

                new SwitchArgument<Helpers.Enumeration.TalentTrees>(Helpers.Enumeration.TalentTrees.Assassination,
                    Context.Assassination.BuildCombatBehavior()
                ),

                new SwitchArgument<Helpers.Enumeration.TalentTrees>(Helpers.Enumeration.TalentTrees.Combat,
                    Context.Combat.BuildCombatBehavior()
                ),

                new SwitchArgument<Helpers.Enumeration.TalentTrees>(Helpers.Enumeration.TalentTrees.Subtlety,
                    Context.Subtlety.BuildCombatBehavior()
                )

            );
        }

CanCast method, which is called and must evaluate to true before every cast. This will evaluate true on spec-specific abilities even if my spec has changed. Key observation is the inclusion of HasSpell here.

PHP:
        static public bool CanCast(string spellName)
        {
            return SpellManager.HasSpell(spellName) && ((GetSpellCooldown(spellName) < 0.2) || (SpellManager.GlobalCooldown && GetSpellCooldown(spellName) < 1)) && Rogue.mCurrentEnergy >= SpellManager.Spells[spellName].PowerCost - 10;
        }
 
Last edited:
Back
Top