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

How to make a CC use Mana Gem

Venus112

New Member
Joined
Jun 17, 2010
Messages
1,509
Reaction score
13
Hey Guys.

So i've been playing around with CodenameG's code for using Mana Gem, but i can't get the code to work properly

Right now, the CC is actually using the Mana Gem, but it also keep spamming it afterwards.


Code:
        //Thank you to CodenameG for this Mana Gem code
        private WoWItem HaveItemCheck(List<int> listId)
        {
            foreach (WoWItem item in ObjectManager.GetObjectsOfType<WoWItem>(false))
            {
                if (listId.Contains(Convert.ToInt32(item.Entry)))
                {


                    return item;
                }
            }
            return null;
        }


        private WoWItem ManaGem;
        public bool HaveManaGem()
        {
            if (ManaGem != null)
            {
                foreach (WoWItem item in Me.BagItems)
                {
                    if (item.Entry == 36799)
                    {
                        ManaGem = item;
                        return true;
                    }


                }
                return false;
            }
            else
            {
                return true;
            }
        }


        public bool ManaGemNotCooldown()
        {
            if (ManaGem != null)
            {
                if (ManaGem.Cooldown == 0)
                {
                    return true;
                }


            }
            return false;
        }



                {
                    if (Me.ManaPercent < 90 && ManaGem == null && !ManaGemNotCooldown())
                    {
                        Lua.DoString("RunMacroText('/Use Mana Gem');"); ;
                    }
                }


This is the code that i've taken from CodenameG (with his permission) and the last is how i activate it. It's not 100 % correct, but i couldn't get the CC to even fire the use of Mana Gem without it

Anyone got any suggestions or ideas on how to make the CC only use Mana Gem once, when appropriate? (Cause i dont)
 
I don't know what is going on with the method call !ManaGemNotCooldown() but it makes me want to murder myself and/or a herd of children. This will probably work, untested though.

Code:
private WoWItem mManaGem;

private void UpdateManaGem()
{
    var manaGem = StyxWoW.Me.BagItems.FirstOrDefault(item => item.Entry == 36799);

    if (manaGem != null && manaGem.Cooldown == 0)
    {
        mManaGem = manaGem;
    }
    else
    {
        mManaGem = null;
    }
}

In an actual CC, you could apply the code this way.

Code:
private WoWItem mManaGem;

public override void Combat()
{
    UpdateManaGem()

    ...
    ...
    ...
    ...

    if (StyxWoW.Me.ManaPercent < 90 && mManaGem != null)
    {
        Logging.Write("Using mana gem.");
        mManaGem.Use();
    }
}

private void UpdateManaGem()
{
    var manaGem = StyxWoW.Me.BagItems.FirstOrDefault(item => item.Entry == 36799);

    if (manaGem != null && manaGem.Cooldown == 0)
    {
        mManaGem = manaGem;
    }
    else
    {
        mManaGem = null;
    }
}

edit: quick edit, fixed up a line
 
Last edited:
Back
Top